Skip to content

Commit b1c74a7

Browse files
committed
Add bot join leave messages toggle
1 parent 215b750 commit b1c74a7

File tree

4 files changed

+25
-2
lines changed

4 files changed

+25
-2
lines changed

lua/custom_chat/client/join_leave.lua

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ local JoinLeave = CustomChat.JoinLeave or {
88

99
leaveColor = { 244, 144, 12 },
1010
leavePrefix = ":small_orange_diamond:",
11-
leaveSuffix = "left!"
11+
leaveSuffix = "left!",
12+
13+
botConnectDisconnect = false,
1214
}
1315

1416
CustomChat.JoinLeave = JoinLeave
@@ -24,6 +26,8 @@ hook.Add( "player_connect_client", "CustomChat.ShowConnectMessages", function( d
2426
local steamId = data.networkid
2527
local isBot = data.bot == 1
2628

29+
if (isBot and (not JoinLeave.botConnectDisconnect)) then return end
30+
2731
-- Only use a player block if Custom Chat is enabled
2832
if CustomChat.IsEnabled() then
2933
name = {
@@ -53,6 +57,8 @@ hook.Add( "player_disconnect", "CustomChat.ShowDisconnectMessages", function( da
5357
local steamId = data.networkid
5458
local isBot = data.bot == 1
5559

60+
if (isBot and (not JoinLeave.botConnectDisconnect)) then return end
61+
5662
-- Only use a player block if Custom Chat is enabled
5763
if CustomChat.IsEnabled() then
5864
name = {
@@ -76,6 +82,8 @@ hook.Add( "player_disconnect", "CustomChat.ShowDisconnectMessages", function( da
7682
end, HOOK_LOW )
7783

7884
local function OnPlayerActivated( ply, steamId, name, color, absenceLength )
85+
if (ply:IsBot() and (not JoinLeave.botConnectDisconnect)) then return end
86+
7987
-- Only use a player block if Custom Chat is enabled
8088
if CustomChat.IsEnabled() then
8189
name = {

lua/custom_chat/client/main.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ end
476476
local function CustomChat_OnChatText( _, _, text, textType )
477477
if textType == "chat" then return end
478478

479-
local canShowJoinLeave = not ( CustomChat.JoinLeave.showConnect or CustomChat.JoinLeave.showDisconnect )
479+
local canShowJoinLeave = not ( CustomChat.JoinLeave.showConnect or CustomChat.JoinLeave.showDisconnect)
480480
if not canShowJoinLeave and textType == "joinleave" then return end
481481

482482
CustomChat:AddMessage( { Color( 0, 128, 255 ), text } )
@@ -657,6 +657,8 @@ hook.Add( "NetPrefs_OnChange", "CustomChat.OnServerConfigChange", function( key,
657657
JoinLeave.leaveColor = data.connection.leaveColor
658658
JoinLeave.leavePrefix = data.connection.leavePrefix
659659
JoinLeave.leaveSuffix = data.connection.leaveSuffix
660+
661+
JoinLeave.botConnectDisconnect = data.connection.botConnectDisconnect
660662
end
661663
end )
662664

lua/custom_chat/client/tags.lua

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,18 @@ function Tags:OpenEditor()
281281
panelConnectionTags:SetPaintBackground( false )
282282
sheet:AddSheet( L"tab.conn_disconn", panelConnectionTags, "icon16/group_go.png" )
283283

284+
local checkBotJoinLeave = vgui.Create( "DCheckBoxLabel", panelConnectionTags )
285+
checkBotJoinLeave:SetText( L"tags.show_bot_joinleave_messages" )
286+
checkBotJoinLeave:SetTextColor( Color( 255, 255, 255 ) )
287+
checkBotJoinLeave:SetValue( byConnection.botConnectDisconnect )
288+
checkBotJoinLeave:SizeToContents()
289+
checkBotJoinLeave:Dock( TOP )
290+
checkBotJoinLeave:DockPadding( 6, 6, 6, 6 )
291+
292+
checkBotJoinLeave.OnChange = function( _, val )
293+
byConnection.botConnectDisconnect = val
294+
end
295+
284296
-- Connect messages
285297
local panelConnect = vgui.Create( "DPanel", panelConnectionTags )
286298
panelConnect:Dock( LEFT )

resource/localization/en/custom_chat.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ custom_chat.tags.leave_suffix=Leave suffix
7777
custom_chat.tags.leave_color=Disconnected player color
7878
custom_chat.tags.apply=Apply all changes
7979
custom_chat.tags.apply_query=This action will apply the chat tags and join/leave messages to this server. Are you sure?
80+
custom_chat.tags.show_bot_joinleave_messages=Show Bots Join/Leave messages
8081
custom_chat.emojis.title=Server Emojis
8182
custom_chat.emojis.invalid=Invalid Emoji
8283
custom_chat.emojis.invalid_reason=Invalid emoji (%d): %s

0 commit comments

Comments
 (0)