/
modCommandsChat.bas
396 lines (330 loc) · 15.2 KB
/
modCommandsChat.bas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
Attribute VB_Name = "modCommandsChat"
Option Explicit
'This module will contain all the command code for commands that affect the chat environment
'Things like Say, DND, Squelch, etc...
Private m_AwayMessage As String
Public Sub OnAway(Command As clsCommandObj)
If (LenB(m_AwayMessage) > 0) Then
Call frmChat.AddQ("/away", PRIORITY.COMMAND_RESPONSE_MESSAGE)
If (Not Command.IsLocal) Then
If (m_AwayMessage = " - ") Then
Call frmChat.AddQ("/me is back.", PRIORITY.COMMAND_RESPONSE_MESSAGE)
Else
Call frmChat.AddQ("/me is back from (" & m_AwayMessage & ")", PRIORITY.COMMAND_RESPONSE_MESSAGE)
End If
End If
m_AwayMessage = vbNullString
Else
If (LenB(Command.Argument("Message")) > 0) Then
m_AwayMessage = Command.Argument("Message")
Call frmChat.AddQ("/away " & m_AwayMessage, PRIORITY.COMMAND_RESPONSE_MESSAGE)
If (Command.IsLocal) Then Call frmChat.AddQ("/me is away (" & m_AwayMessage & ")")
Else
m_AwayMessage = " - "
Call frmChat.AddQ("/away", PRIORITY.COMMAND_RESPONSE_MESSAGE)
If (Not Command.IsLocal) Then Call frmChat.AddQ("/me is away.")
End If
End If
End Sub
Public Sub OnBack(Command As clsCommandObj)
If (LenB(m_AwayMessage) > 0) Then
Call frmChat.AddQ("/away", PRIORITY.COMMAND_RESPONSE_MESSAGE, Command.Username)
If (Not Command.IsLocal) Then
If (m_AwayMessage = " - ") Then
Call frmChat.AddQ("/me is back.", PRIORITY.COMMAND_RESPONSE_MESSAGE)
Else
Call frmChat.AddQ("/me is back from (" & m_AwayMessage & ")", PRIORITY.COMMAND_RESPONSE_MESSAGE)
End If
m_AwayMessage = vbNullString
End If
End If
End Sub
Public Sub OnBlock(Command As clsCommandObj)
Dim FiltersPath As String
Dim Total As Integer
Dim TotalString As String
If (Command.IsValid) Then
FiltersPath = GetFilePath(FILE_FILTERS)
If (CheckBlock(Command.Argument("Username"))) Then 'Should prevent adding filters that are the same as other filters
Command.Respond "That username is already in the block list, or is under a wildcard block."
Else
TotalString = ReadINI("BlockList", "Total", FiltersPath)
If (LenB(TotalString) = 0) Then TotalString = "0"
If (StrictIsNumeric(TotalString)) Then
Total = Int(TotalString)
WriteINI "BlockList", "Filter" & (Total + 1), Command.Argument("Username"), FiltersPath
WriteINI "BlockList", "Total", Total + 1, FiltersPath
Command.Respond StringFormat("Added {0}{1}{0} to the username block list.", Chr$(34), Command.Argument("Username"))
Call frmChat.LoadArray(LOAD_BLOCKLIST, g_Blocklist())
Else
Command.Respond "Your filters file has been edited manually and is no longer valid. Please delete it."
End If
End If
End If
End Sub
Public Sub OnConnect(Command As clsCommandObj)
frmChat.DoConnect
End Sub
Public Sub OnCQ(Command As clsCommandObj)
g_Queue.Clear
Command.Respond "Queue cleared."
End Sub
Public Sub OnDisconnect(Command As clsCommandObj)
frmChat.DoDisconnect
End Sub
Public Sub OnExpand(Command As clsCommandObj)
Dim sMessage As String
Dim tmpSend As String
Dim i As Integer
If (Command.IsValid) Then
sMessage = Command.Argument("Message")
If (Len(tmpSend) > 223) Then tmpSend = Left$(tmpSend, 223)
For i = 1 To Len(sMessage)
tmpSend = StringFormat("{0}{1}{2}", tmpSend, Mid$(sMessage, i, 1), IIf(i = Len(sMessage), vbNullString, Space$(1)))
Next i
If (Not Command.Restriction("RAW_USAGE")) Then tmpSend = StringFormat("{0} Says: {1}", Command.Username, tmpSend)
If (Len(tmpSend) > 223) Then
tmpSend = Left$(tmpSend, 223)
End If
Command.PublicOutput = True
Command.Respond tmpSend
End If
End Sub
Public Sub OnFAdd(Command As clsCommandObj)
If (Command.IsValid) Then
Call frmChat.AddQ("/f a " & Command.Argument("Username"), PRIORITY.COMMAND_RESPONSE_MESSAGE, Command.Username)
Command.Respond StringFormat("Added user {0}{1}{0} to this account's friends list.", Chr$(34), Command.Argument("Username"))
End If
End Sub
Public Sub OnFilter(Command As clsCommandObj)
Dim FiltersPath As String
Dim Total As Integer
Dim TotalString As String
If (Command.IsValid) Then
FiltersPath = GetFilePath(FILE_FILTERS)
If (CheckMsg(Command.Argument("Filter"))) Then 'Should prevent adding filters that are the same as other filters
Command.Respond "That filter is already in the list, or is under a wildcard."
Else
TotalString = ReadINI("TextFilters", "Total", FiltersPath)
If (LenB(TotalString) = 0) Then TotalString = "0"
If (StrictIsNumeric(TotalString)) Then
Total = Int(TotalString)
WriteINI "TextFilters", "Filter" & (Total + 1), Command.Argument("Filter"), FiltersPath
WriteINI "TextFilters", "Total", Total + 1, FiltersPath
Command.Respond StringFormat("Added {0}{1}{0} to the message filter list.", Chr$(34), Command.Argument("Filter"))
Call frmChat.LoadArray(LOAD_FILTERS, gFilters())
Else
Command.Respond "Your filters file has been edited manually and is no longer valid. Please delete it."
End If
End If
End If
End Sub
Public Sub OnForceJoin(Command As clsCommandObj)
If (Command.IsValid) Then
Call FullJoin(Command.Argument("Channel"))
End If
End Sub
Public Sub OnFRem(Command As clsCommandObj)
If (Command.IsValid) Then
Call frmChat.AddQ("/f r " & Command.Argument("Username"), PRIORITY.COMMAND_RESPONSE_MESSAGE, Command.Username)
Command.Respond StringFormat("Removed user {0}{1}{0} from this account's friends list.", Chr$(34), Command.Argument("Username"))
End If
End Sub
Public Sub OnHome(Command As clsCommandObj)
If (LenB(Config.HomeChannel) = 0) Then
' do product home join instead
Call DoChannelJoinProductHome
Else
' go home
Call FullJoin(Config.HomeChannel, 2)
End If
End Sub
Public Sub OnReturn(Command As clsCommandObj)
If (LenB(BotVars.LastChannel) > 0) Then
' go to last channel
Call FullJoin(BotVars.LastChannel, 2)
End If
End Sub
Public Sub OnIgnore(Command As clsCommandObj)
If (Command.IsValid) Then
If (Command.IsLocal) Then
Command.Respond StringFormat("Ignoring messages from {0}{1}{0}.", Chr$(34), Command.Argument("Username"))
frmChat.AddQ "/ignore " & Command.Argument("Username"), PRIORITY.COMMAND_RESPONSE_MESSAGE
Else
Dim dbTarget As udtUserAccess
Dim dbCaller As udtUserAccess
dbTarget = Database.GetUserAccess(Command.Argument("Username"))
dbCaller = Database.GetUserAccess(Command.Username)
If (dbTarget.Rank > dbCaller.Rank) Then
Command.Respond "That user has a higher rank then you."
ElseIf (dbTarget.Rank = dbCaller.Rank) Then
Command.Respond "That user has the same rank as you."
Else
Command.Respond StringFormat("Ignoring messages from {0}{1}{0}.", Chr$(34), Command.Argument("Username"))
frmChat.AddQ "/ignore " & Command.Argument("Username"), PRIORITY.COMMAND_RESPONSE_MESSAGE
End If
End If
End If
End Sub
Public Sub OnIgPriv(Command As clsCommandObj)
Call frmChat.AddQ("/o igpriv", PRIORITY.COMMAND_RESPONSE_MESSAGE, Command.Username)
Command.Respond "Ignoring messages from non-friends in private channels."
End Sub
Public Sub OnJoin(Command As clsCommandObj)
If (Command.IsValid) Then
Call frmChat.AddQ("/join " & Command.Argument("Channel"), PRIORITY.COMMAND_RESPONSE_MESSAGE, Command.Username)
End If
End Sub
Public Sub OnUnBlock(Command As clsCommandObj)
Dim i As Integer
Dim Total As Integer
Dim TotalString As String
Dim FiltersPath As String
If (Command.IsValid) Then
FiltersPath = GetFilePath(FILE_FILTERS)
TotalString = ReadINI("BlockList", "Total", FiltersPath)
If (LenB(TotalString) = 0) Then TotalString = "0"
If (StrictIsNumeric(TotalString)) Then
Total = Int(TotalString)
For i = 0 To Total
If (StrComp(Command.Argument("Username"), ReadINI("BlockList", "Filter" & (i + 1), FiltersPath), vbTextCompare) = 0) Then
Exit For
ElseIf (i = Total) Then
Command.Respond StringFormat("{0}{1}{0} is not blocked.", Chr(34), Command.Argument("Username"))
Exit Sub
End If
Next i
If (i < Total) Then
For i = i To (Total - 1)
WriteINI "BlockList", "Filter" & (i + 1), ReadINI("BlockList", "Filter" & (i + 2), FiltersPath), FiltersPath
Next i
WriteINI "BlockList", "Total", (Total - 1), FiltersPath
Command.Respond StringFormat("Removed {0}{1}{0} from the blocked users list.", Chr$(34), Command.Argument("Username"))
Call frmChat.LoadArray(LOAD_BLOCKLIST, g_Blocklist())
End If
Else
Command.Respond "Your filters file has been edited manually and is no longer valid. Please delete it."
End If
End If
End Sub
Public Sub OnUnFilter(Command As clsCommandObj)
Dim i As Integer
Dim Total As Integer
Dim TotalString As String
Dim FiltersPath As String
If (Command.IsValid) Then
FiltersPath = GetFilePath(FILE_FILTERS)
TotalString = ReadINI("TextFilters", "Total", FiltersPath)
If (LenB(TotalString) = 0) Then TotalString = "0"
If (StrictIsNumeric(TotalString)) Then
Total = Int(TotalString)
For i = 0 To Total
If (StrComp(Command.Argument("Filter"), ReadINI("TextFilters", "Filter" & (i + 1), FiltersPath), vbTextCompare) = 0) Then
Exit For
ElseIf (i = Total) Then
Command.Respond StringFormat("{0}{1}{0} is not filtered.", Chr(34), Command.Argument("Filter"))
Exit Sub
End If
Next i
If (i < Total) Then
For i = i To (Total - 1)
WriteINI "TextFilters", "Filter" & (i + 1), ReadINI("TextFilters", "Filter" & (i + 2), FiltersPath), FiltersPath
Next i
WriteINI "TextFilters", "Total", (Total - 1), FiltersPath
Command.Respond StringFormat("Removed {0}{1}{0} from the message filter list.", Chr$(34), Command.Argument("Filter"))
Call frmChat.LoadArray(LOAD_FILTERS, gFilters())
End If
Else
Command.Respond "Your filters file has been edited manually and is no longer valid. Please delete it."
End If
End If
End Sub
Public Sub OnUnIgnore(Command As clsCommandObj)
If (Command.IsValid) Then
Command.Respond StringFormat("Receiving messages from {0}{1}{0}.", Chr$(34), Command.Argument("Username"))
frmChat.AddQ "/unignore " & Command.Argument("Username"), PRIORITY.COMMAND_RESPONSE_MESSAGE
End If
End Sub
Public Sub OnUnIgPriv(Command As clsCommandObj)
Call frmChat.AddQ("/o unigpriv", PRIORITY.COMMAND_RESPONSE_MESSAGE, Command.Username)
Command.Respond "Allowing messages from non-friends in private channels."
End Sub
Public Sub OnQuickRejoin(Command As clsCommandObj)
Call RejoinChannel(g_Channel.Name)
End Sub
Public Sub OnReconnect(Command As clsCommandObj)
If (g_Online) Then
Dim LastChannel As String
If LenB(g_Channel.Name) = 0 And LenB(BotVars.LastChannel) > 0 Then
' already outside chat environment
LastChannel = BotVars.LastChannel
Else
' in chat room
LastChannel = g_Channel.Name
End If
Call frmChat.DoDisconnect
'frmChat.AddChat RTBColors.ErrorMessageText, "[BNCS] Reconnecting by command, please wait..."
Pause 1
'frmChat.AddChat RTBColors.SuccessText, "Connection initialized."
Call frmChat.DoConnect
' reinstate last channel
BotVars.LastChannel = LastChannel
PrepareHomeChannelMenu
PrepareQuickChannelMenu
Else
frmChat.AddChat RTBColors.SuccessText, "Connection initialized."
Call frmChat.DoConnect
End If
End Sub
Public Sub OnReJoin(Command As clsCommandObj)
Call frmChat.AddQ(StringFormat("/join {0} Rejoin", GetCurrentUsername), PRIORITY.COMMAND_RESPONSE_MESSAGE, Command.Username)
Call frmChat.AddQ("/join " & g_Channel.Name, PRIORITY.COMMAND_RESPONSE_MESSAGE, Command.Username)
End Sub
Public Sub OnSay(Command As clsCommandObj)
Dim tmpSend As String
If (Command.IsValid) Then
If (Not Command.Restriction("RAW_USAGE")) Then
tmpSend = StringFormat("{0} Says: {1}", Command.Username, Command.Argument("Message"))
Else
tmpSend = Command.Argument("Message")
End If
If (Len(tmpSend) > 223) Then tmpSend = Left$(tmpSend, 223)
Command.PublicOutput = True
Command.Respond tmpSend
End If
End Sub
Public Sub OnSCQ(Command As clsCommandObj)
g_Queue.Clear
End Sub
Public Sub OnShout(Command As clsCommandObj)
Dim tmpSend As String
If (Command.IsValid) Then
If (Not Command.Restriction("RAW_USAGE")) Then
tmpSend = StringFormat("{0} Shouts: {1}", Command.Username, UCase$(Command.Argument("Message")))
Else
tmpSend = UCase$(Command.Argument("Message"))
End If
If (Len(tmpSend) > 223) Then tmpSend = Left$(tmpSend, 223)
Command.PublicOutput = True
Command.Respond tmpSend
End If
End Sub
Public Sub OnWatch(Command As clsCommandObj)
If (Command.IsValid) Then
WatchUser = Command.Argument("Username")
Command.Respond StringFormat("Now watching {0}{1}{0}.", Chr$(34), Command.Argument("Username"))
Else
If (LenB(WatchUser) > 0) Then
Command.Respond StringFormat("Stopped watching {0}{1}{0}.", Chr$(34), WatchUser)
WatchUser = vbNullString
End If
End If
End Sub
Public Sub OnWatchOff(Command As clsCommandObj)
If (LenB(WatchUser) > 0) Then
Command.Respond StringFormat("Stopped watching {0}{1}{0}.", Chr$(34), WatchUser)
WatchUser = vbNullString
Else
Command.Respond "Watch is disabled."
End If
End Sub