-
Notifications
You must be signed in to change notification settings - Fork 13
/
infobot.lua
517 lines (486 loc) · 20.2 KB
/
infobot.lua
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
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
--[[
This file is part of HiT Hi FiT Hai's PtokaX scripts
Copyright: © 2014 HiT Hi FiT Hai group
Licence: GNU General Public Licence v3 https://www.gnu.org/licenses/gpl-3.0.html
--]]
function OnStartup()
tCfg = {
sBotName = "[BOT]Info",
sBotDescription = "All informatory works are performed.",
sBotEmail = "[email protected]",
sPath = Core.GetPtokaXPath().."scripts/",
sFunctionsFile = "info.lua",
sChatFile = "chatcore.lua",
sHelpFile = "ihelp.txt",
sReportBot = "#[Hub-Feed]",
tTemplates = {
sNotify = "New: %s has been added to [ %s ] table. Use %s for more information.",
sCategNotify = "New %s: %s has been added to [ %s ] table. Use %s for more information.",
},
sHelp = "",
sAllCategories = "",
iMaxStringLength = 250,
iModProfile = 4,
iRegProfile = 5,
}
tPaths = {
sTexts = tCfg.sPath.."texts/",
sExternal = tCfg.sPath.."external/",
sDependency = tCfg.sPath.."dependency/",
}
tProfiles = {
AllowVIP = {
[0] = true, -- Admin
[1] = true, -- God
[2] = true, -- OP
[3] = true, -- VIP
},
AllowMods = {
[0] = true, -- Admin
[1] = true, -- God
[2] = true, -- OP
[3] = true, -- VIP
[4] = true, -- Mods
},
}
dofile( tPaths.sExternal..tCfg.sFunctionsFile )
dofile( tPaths.sDependency..tCfg.sChatFile )
local fHelp = io.open( tPaths.sTexts..tCfg.sHelpFile )
if fHelp then
tCfg.sHelp = fHelp:read( "*a" )
fHelp:close()
end
Core.RegBot( tCfg.sBotName, tCfg.sBotDescription, tCfg.sBotEmail, true )
tCfg.sAllCategories = tFunction.Connect()
end
function ToArrival( tUser, sMessage )
local sTo = sMessage:match "$To: (%S+) From:"
if sTo ~= tCfg.sBotName then return false end
local sCmd, sData = sMessage:match "%b<> [-+*/?!#](%w+)%s*(.*)|"
if not sCmd then return false end
if sData and sData:len() > tCfg.iMaxStringLength then
Core.SendPmToUser( tUser, tCfg.sBotName, "All command length must be below "..tostring(tCfg.iMaxStringLength).." characters." )
end
if sCmd:lower() == "h" or sCmd:lower() == "help" then
Core.SendPmToUser( tUser, tCfg.sBotName, tCfg.sHelp )
return false
else
return ExecuteCommand( tUser, sCmd:lower(), sData )
end
end
function ExecuteCommand( tUser, sCommand, sData )
if sCommand == "readall" or sCommand == "rall" then
if ( not sData ) or ( sData and not tonumber(sData) ) then
iLimit = 15
else
iLimit = ( tonumber(sData) > 35 and 35 ) or tonumber(sData)
end
if iLimit < 0 then iLimit = 15 end
local sList = tInfobot.readAll( iLimit )
if sList then
Core.SendPmToUser( tUser, tCfg.sBotName, sList )
end
sList = nil
return true
elseif sCommand == "readreq" or sCommand == "rreq" then
if ( not sData ) or ( sData and not tonumber(sData) ) then
iLimit = 15
else
iLimit = ( tonumber(sData) > 50 and 50 ) or tonumber(sData)
end
if iLimit < 0 then iLimit = 15 end
local sList = tInfobot.readOne( "requests", iLimit )
if sList then
Core.SendPmToUser( tUser, tCfg.sBotName, sList )
sList = nil
end
return true
elseif sCommand == "readbuysell" or sCommand == "rbsell" then
if ( not sData ) or ( sData and not tonumber(sData) ) then
iLimit = 15
else
iLimit = ( tonumber(sData) > 50 and 50 ) or tonumber(sData)
end
if iLimit < 0 then iLimit = 15 end
local sList = tInfobot.readOne( "buynsell", iLimit )
if sList then
Core.SendPmToUser( tUser, tCfg.sBotName, sList )
sList = nil
end
return true
elseif sCommand == "readsug" or sCommand == "rsg" then
if ( not sData ) or ( sData and not tonumber(sData) ) then
iLimit = 15
else
iLimit = ( tonumber(sData) > 50 and 50 ) or tonumber(sData)
end
if iLimit < 0 then iLimit = 15 end
local sList = tInfobot.readOne( "suggestions", iLimit )
if sList then
Core.SendPmToUser( tUser, tCfg.sBotName, sList )
end
sList = nil
return true
elseif sCommand == "readdels" or sCommand == "rdel" then
if ( not sData ) or ( sData and not tonumber(sData) ) then
iLimit = 15
else
iLimit = ( tonumber(sData) > 50 and 50 ) or tonumber(sData)
end
if iLimit < 0 then iLimit = 15 end
local sList = tInfobot.readOne( "deletions", iLimit )
if sList then
Core.SendPmToUser( tUser, tCfg.sBotName, sList )
end
sList = nil
return true
elseif sCommand == "readgst" or sCommand == "rgst" then
if ( not sData ) or ( sData and not tonumber(sData) ) then
iLimit = 15
else
iLimit = ( tonumber(sData) > 50 and 50 ) or tonumber(sData)
end
if iLimit < 0 then iLimit = 15 end
local sList = tInfobot.readOne( "guestbook", iLimit )
if sList then
Core.SendPmToUser( tUser, tCfg.sBotName, sList )
end
sList = nil
return true
elseif sCommand == "readnws" or sCommand == "rn" then
if ( not sData ) or ( sData and not tonumber(sData) ) then
iLimit = 15
else
iLimit = ( tonumber(sData) > 50 and 50 ) or tonumber(sData)
end
if iLimit < 0 then iLimit = 15 end
local sList = tInfobot.readOne( "news", iLimit )
if sList then
Core.SendPmToUser( tUser, tCfg.sBotName, sList )
end
sList = nil
return true
end
if sData:len() == 0 then
Core.SendPmToUser( tUser, tCfg.sBotName, "You did not pass anything as argument." )
return false
end
local tInsertData, iLastID = { sMsg = sData, sTable = "all" }, 0
if not tInsertData.sMsg then
Core.SendPmToUser( tUser, tCfg.sBotName, "No message provided." )
return false
elseif tInsertData.sMsg:len() > 200 then
Core.SendPmToUser( tUser, tCfg.sBotName, "Too long text!" )
return false
end
if sCommand == "areq" or sCommand == "ar" then
if tUser.iProfile == -1 then
Core.SendPmToUser( tUser, tCfg.sBotName, tFunction.Report('gen', 2) )
return false
end
local tBreak = Explode( sData )
if tFunction.CheckCategory( tBreak[1] ) then
tInsertData.sCtg = tBreak[1]:lower()
else
Core.SendPmToUser( tUser, tCfg.sBotName, "Wrong category! "..tCfg.sAllCategories )
return false
end
tInsertData.sMsg, tInsertData.sTable = table.concat( tBreak, " ", 2 ), "requests"
iLastID = tInfobot.add( tUser, tInsertData )
if not iLastID or iLastID == 0 then
Core.SendPmToUser( tUser, tCfg.sBotName, "Something went wrong." )
return false
end
local sChatMessage = tCfg.tTemplates.sCategNotify:format( tInsertData.sCtg:upper(), tInsertData.sMsg, tInsertData.sTable:upper(), tCfg.sBotName )
SendToRoom( tUser.sNick, sChatMessage, tCfg.sReportBot, tCfg.iModProfile )
tFunction.SendToAll( tUser.sNick, sChatMessage )
sChatMessage = nil
Core.SendPmToUser( tUser, tCfg.sBotName, "Request has been added at ID #"..tostring(iLastID).."." )
return true
elseif sCommand == "asug" or sCommand == "asg" then
local tBreak = Explode( sData )
if tFunction.CheckCategory( tBreak[1] ) then
tInsertData.sCtg = tBreak[1]:lower()
else
Core.SendPmToUser( tUser, tCfg.sBotName, "Wrong category! "..tCfg.sAllCategories )
return false
end
tInsertData.sMsg, tInsertData.sTable = table.concat( tBreak, " ", 2 ), "suggestions"
iLastID = tInfobot.add( tUser, tInsertData )
if not iLastID or iLastID == 0 then
Core.SendPmToUser( tUser, tCfg.sBotName, "Something went wrong." )
return false
end
local sChatMessage = tCfg.tTemplates.sCategNotify:format( tInsertData.sCtg:upper(), tInsertData.sMsg, tInsertData.sTable:upper(), tCfg.sBotName )
SendToRoom( tUser.sNick, sChatMessage, tCfg.sReportBot )
tFunction.SendToAll( tUser.sNick, sChatMessage )
sChatMessage = nil
Core.SendPmToUser( tUser, tCfg.sBotName, "Suggestion has been added at ID #"..tostring(iLastID).."." )
return true
elseif sCommand == "anws" or sCommand == "an" then
tInsertData.sTable = "news"
iLastID = tInfobot.add( tUser, tInsertData )
if not iLastID or iLastID == 0 then
Core.SendPmToUser( tUser, tCfg.sBotName, "Something went wrong." )
return false
end
local sChatMessage = tCfg.tTemplates.sNotify:format( tInsertData.sMsg, tInsertData.sTable:upper(), tCfg.sBotName )
SendToRoom( tUser.sNick, sChatMessage, tCfg.sReportBot )
tFunction.SendToAll( tUser.sNick, sChatMessage )
sChatMessage = nil
Core.SendPmToUser( tUser, tCfg.sBotName, "News has been added at ID #"..tostring(iLastID).."." )
return true
elseif sCommand == "agst" or sCommand == "ag" then
if tUser.iProfile == -1 then
Core.SendPmToUser( tUser, tCfg.sBotName, tFunction.Report('gen', 2) )
return false
end
tInsertData.sTable = "guestbook"
iLastID = tInfobot.add( tUser, tInsertData )
if not iLastID or iLastID == 0 then
Core.SendPmToUser( tUser, tCfg.sBotName, "Something went wrong." )
return false
end
local sChatMessage = tCfg.tTemplates.sNotify:format( tInsertData.sMsg, tInsertData.sTable:upper(), tCfg.sBotName )
SendToRoom( tUser.sNick, sChatMessage, tCfg.sReportBot )
tFunction.SendToAll( tUser.sNick, sChatMessage )
sChatMessage = nil
Core.SendPmToUser( tUser, tCfg.sBotName, "Your comment has been recorded at ID #"..tostring(iLastID).."." )
return true
elseif sCommand == "adel" or sCommand == "ad" then
tInsertData.sTable = "deletions"
iLastID = tInfobot.add( tUser, tInsertData )
if not iLastID or iLastID == 0 then
Core.SendPmToUser( tUser, tCfg.sBotName, "Something went wrong." )
return false
end
local sChatMessage = tCfg.tTemplates.sNotify:format( tInsertData.sMsg, tInsertData.sTable:upper(), tCfg.sBotName )
SendToRoom( tUser.sNick, sChatMessage, tCfg.sReportBot, tCfg.iModProfile )
tFunction.SendToAll( tUser.sNick, sChatMessage )
sChatMessage = nil
Core.SendPmToUser( tUser, tCfg.sBotName, "Deletion info has been added at ID #"..tostring(iLastID).."." )
return true
elseif sCommand == "addbns" or sCommand == "absell" then
if tUser.iProfile == -1 then
Core.SendPmToUser( tUser, tCfg.sBotName, tFunction.Report('gen', 2) )
return false
end
local tBreak = Explode( sData )
local _, sError = tFunction.CheckBnS( string.lower(tBreak[1]) )
if _ then
tInsertData.sType = _
else
Core.SendPmToUser( tUser, tCfg.sBotName, "Wrong category! Available ones are \n"..sError )
return false
end
tInsertData.sMsg, tInsertData.sTable = table.concat( tBreak, " ", 2 ), "buynsell"
iLastID = tInfobot.add( tUser, tInsertData )
if not iLastID or iLastID == 0 then
Core.SendPmToUser( tUser, tCfg.sBotName, "Something went wrong." )
return false
end
local sChatMessage = tCfg.tTemplates.sCategNotify:format( tBreak[1]:upper(), tInsertData.sMsg, tInsertData.sTable:upper(), tCfg.sBotName )
SendToRoom( tUser.sNick, sChatMessage, tCfg.sReportBot )
tFunction.SendToAll( tUser.sNick, sChatMessage )
sChatMessage = nil
Core.SendPmToUser( tUser, tCfg.sBotName, "Buy and sell entry has been added at ID #"..tostring(iLastID).."." )
return true
elseif sCommand == "addreply" or sCommand == "amsg" then
local tBreak = Explode( sData )
if not tonumber( tBreak[1], 10 ) then
Core.SendPmToUser( tUser, tCfg.sBotName, tFunction.Report("gen", 5) )
return false
end
tInsertData.sMsg, tInsertData.iID, tInsertData.sTable = table.concat( tBreak, " ", 2 ), tonumber( tBreak[1], 10 ), "replies"
local tRow = tFunction.FetchRow( "buynsell", tInsertData.iID )
if not tRow then
Core.SendPmToUser( tUser, tCfg.sBotName, tFunction.Report("info", 2) )
return false
end
iLastID = tInfobot.add( tUser, tInsertData )
if not iLastID or iLastID == 0 then
Core.SendPmToUser( tUser, tCfg.sBotName, "Something went wrong." )
return false
end
tInfobot.StoreMessage( tUser.sNick, tRow.nick, "I've replied to your buy and sell thread. ID#"..tostring(tInsertData.iID).." - "..tRow.msg.."." )
local sReply = ("Your reply to buy and sell thread#%d has been added at ID #%d. %s will be notified with your message. Keep checking the thread for further replies."):format( tInsertData.iID, iLastID, tRow.nick )
Core.SendPmToUser( tUser, tCfg.sBotName, sReply )
return true
elseif sCommand == "fill" or sCommand == "freq" then
local tBreak, sReply = Explode( sData ), "You filled the request \n\tID#%d. [%s] - %s (Added by %s)\n\n"
if not tonumber( tBreak[1], 10 ) then
Core.SendPmToUser( tUser, tCfg.sBotName, tFunction.Report("gen", 5) )
return false
end
tInsertData.sMsg, tInsertData.iID = nil, tonumber( tBreak[1], 10 )
local tRow = tFunction.FetchRow( "requests", tInsertData.iID )
if not tRow then
Core.SendPmToUser( tUser, tCfg.sBotName, tFunction.Report("info", 2) )
return false
end
local iOfflineMessageID, sError = tInfobot.StoreMessage( tUser.sNick, tRow.nick, "I've filled your request ID#"..tostring(tInsertData.iID).." - "..tRow.msg.."." )
tInfobot.fill( tUser, tonumber(tBreak[1], 10) )
if iOfflineMessageID ~= 0 then
sReply = sReply.."The requesting user will be notified with message ID#%d when they connect."
Core.SendPmToUser( tUser, tCfg.sBotName, sReply:format(tInsertData.iID, tRow.ctg, tRow.msg, tRow.nick, iOfflineMessageID) )
else
Core.SendPmToUser( tUser, tCfg.sBotName, sReply:format(tInsertData.iID, tRow.ctg, tRow.msg, tRow.nick)..sError )
end
return true
elseif tProfiles.AllowMods[tUser.iProfile] and ( sCommand == "close" or sCommand == "creq" ) then
local tBreak, sReply = Explode( sData ), "You closed the request \n\tID#%d. [%s] - %s (Added by %s)\n\nThe requesting user will be notified with message ID#%d when they connect."
if not tonumber( tBreak[1], 10 ) then
Core.SendPmToUser( tUser, tCfg.sBotName, tFunction.Report("gen", 5) )
return false
end
tInsertData.sMsg, tInsertData.iID = nil, tonumber( tBreak[1], 10 )
local tRow = tFunction.FetchRow( "requests", tInsertData.iID )
if not tRow then
Core.SendPmToUser( tUser, tCfg.sBotName, tFunction.Report("info", 2) )
return false
end
local iOfflineMessageID, sError = tInfobot.StoreMessage( tUser.sNick, tRow.nick, "I've closed your request ID#"..tostring(tInsertData.iID).." - "..tRow.msg.."." )
tInfobot.fill( tUser, tInsertData.iID, true )
if iOfflineMessageID ~= 0 then
Core.SendPmToUser( tUser, tCfg.sBotName, sReply:format(tInsertData.iID, tRow.ctg, tRow.msg, tRow.nick, tonumber(iOfflineMessageID)) )
else
Core.SendPmToUser( tUser, tCfg.sBotName, sReply:format(tInsertData.iID, tRow.ctg, tRow.msg, tRow.nick, tonumber(iOfflineMessageID))..sError )
end
return true
elseif sCommand == "switch" then
local tBreak, sReply = Explode( sData ), "You switched the status of thread \n\tID#%d. [%s] - %s (Added by %s)\n\nThe requesting user will be notified with message ID#%d when they connect."
if not tonumber( tBreak[1], 10 ) then
Core.SendPmToUser( tUser, tCfg.sBotName, tFunction.Report("gen", 5) )
return false
end
tInsertData.sMsg, tInsertData.iID = nil, tonumber( tBreak[1], 10 )
local tRow = tFunction.FetchRow( "buynsell", tInsertData.iID )
if not tRow then
Core.SendPmToUser( tUser, tCfg.sBotName, tFunction.Report("info", 2) )
return false
end
if tRow.type:lower() ~= "buy" and tRow.type:lower() ~= "sell" then
Core.SendPmToUser( tUser, tCfg.sBotName, "The thread is of [ "..tRow.type.." ] type. Can not switch its status." )
return false
end
if tUser.sNick:lower() == tRow.nick:lower() or tProfiles.AllowMods[tUser.iProfile] then
tInfobot.switch( tInsertData.iID )
if tUser.sNick:lower() ~= tRow.nick:lower() then
local iOfflineMessageID, sError = tInfobot.StoreMessage( tUser.sNick, tRow.nick, "I've switched your buy and sell thread ID #"..tostring(tInsertData.iID).." - "..tRow.msg.."." )
if iOfflineMessageID ~= 0 then
Core.SendPmToUser( tUser, tCfg.sBotName, sReply:format(tInsertData.iID, tRow.type, tRow.msg, tRow.nick, tonumber(iOfflineMessageID)) )
else
Core.SendPmToUser( tUser, tCfg.sBotName, sReply:format(tInsertData.iID, tRow.type, tRow.msg, tRow.nick, tonumber(iOfflineMessageID))..sError )
end
else
Core.SendPmToUser( tUser, tCfg.sBotName, "Status switched successfully." )
end
return true
else
Core.SendPmToUser( tUser, tCfg.sBotName, tFunction.Report("info", 1) )
return false
end
elseif sCommand == "delreq" or sCommand == "dr" then
local tBreak = Explode( sData )
if not tonumber( tBreak[1], 10 ) then
Core.SendPmToUser( tUser, tCfg.sBotName, tFunction.Report("gen", 5) )
return false
end
tInsertData.sMsg, tInsertData.iID, tInsertData.sTable = nil, tonumber( tBreak[1], 10 ), "requests"
local tRow = tFunction.FetchRow( tInsertData.sTable, tInsertData.iID )
if not tRow then
Core.SendPmToUser( tUser, tCfg.sBotName, tFunction.Report("info", 2) )
return false
end
if tProfiles.AllowVIP[tUser.iProfile] or tRow.nick:lower() == tUser.sNick:lower() then
local sTemporary = "The following entry has been deleted:\n\tID#%d. [%s] - %s (Added by %s)"
Core.SendPmToUser( tUser, tCfg.sBotName, sTemporary:format(tInsertData.iID, tRow.ctg, tRow.msg, tRow.nick) )
tInfobot.del( tUser, tInsertData )
else
Core.SendPmToUser( tUser, tCfg.sBotName, tFunction.Report("info", 1) )
end
return true
elseif sCommand == "delsug" or sCommand == "dsg" then
local tBreak = Explode( sData )
if not tonumber( tBreak[1], 10 ) then
Core.SendPmToUser( tUser, tCfg.sBotName, tFunction.Report("gen", 5) )
return false
end
tInsertData.sMsg, tInsertData.iID, tInsertData.sTable = nil, tonumber( tBreak[1], 10 ), "suggestions"
local tRow = tFunction.FetchRow( tInsertData.sTable, tInsertData.iID )
if not tRow then
Core.SendPmToUser( tUser, tCfg.sBotName, tFunction.Report("info", 2) )
return false
end
if tProfiles.AllowVIP[tUser.iProfile] or tRow.nick:lower() == tUser.sNick:lower() then
local sTemporary = "The following entry has been deleted:\n\t%d. [%s] - %s (Added by %s)"
Core.SendPmToUser( tUser, tCfg.sBotName, sTemporary:format(tInsertData.iID, tRow.ctg, tRow.msg, tRow.nick) )
tInfobot.del( tUser, tInsertData )
else
Core.SendPmToUser( tUser, tCfg.sBotName, tFunction.Report("info", 1) )
return false
end
return true
elseif sCommand == "delnws" or sCommand == "dn" then
local tBreak = Explode( sData )
if not tonumber( tBreak[1], 10 ) then
Core.SendPmToUser( tUser, tCfg.sBotName, tFunction.Report("gen", 5) )
end
tInsertData.sMsg, tInsertData.iID, tInsertData.sTable = nil, tonumber( tBreak[1], 10 ), "news"
local tRow = tFunction.FetchRow( tInsertData.sTable, tInsertData.iID )
if not tRow then
Core.SendPmToUser( tUser, tCfg.sBotName, tFunction.Report("info", 2) )
return false
end
if tProfiles.AllowVIP[tUser.iProfile] or tRow.nick:lower() == tUser.sNick:lower() then
local sTemporary = "The following entry has been deleted:\n\t%d. %s (Added by %s)"
Core.SendPmToUser( tUser, tCfg.sBotName, sTemporary:format(tInsertData.iID, tRow.msg, tRow.nick) )
tInfobot.del( tUser, tInsertData )
else
Core.SendPmToUser( tUser, tCfg.sBotName, tFunction.Report("info", 1) )
return false
end
return true
elseif sCommand == "delbns" or sCommand == "dbsell" then
local tBreak = Explode( sData )
if not tonumber( tBreak[1], 10 ) then
Core.SendPmToUser( tUser, tCfg.sBotName, tFunction.Report("gen", 5) )
return false
end
tInsertData.sMsg, tInsertData.iID, tInsertData.sTable = nil, tonumber( tBreak[1], 10 ), "buynsell"
local tRow = tFunction.FetchRow( tInsertData.sTable, tInsertData.iID )
if not tRow then
Core.SendPmToUser( tUser, tCfg.sBotName, tFunction.Report("info", 2) )
return false
end
if tProfiles.AllowVIP[tUser.iProfile] or tRow.nick:lower() == tUser.sNick:lower() then
local sTemporary = "The following entry has been deleted:\n\tID#%d. [%s] - %s (Added by %s)"
Core.SendPmToUser( tUser, tCfg.sBotName, sTemporary:format(tInsertData.iID, tRow.type, tRow.msg, tRow.nick) )
tInfobot.del( tUser, tInsertData )
else
Core.SendPmToUser( tUser, tCfg.sBotName, tFunction.Report("info", 1) )
end
return true
elseif sCommand == "delmsg" or sCommand == "dmsg" then
local tBreak = Explode( sData )
if not tonumber( tBreak[1], 10 ) then
Core.SendPmToUser( tUser, tCfg.sBotName, tFunction.Report("gen", 5) )
return false
end
tInsertData.sMsg, tInsertData.iID, tInsertData.sTable = nil, tonumber( tBreak[1], 10 ), "replies"
local tRow = tFunction.FetchRow( tInsertData.sTable, tInsertData.iID )
if not tRow then
Core.SendPmToUser( tUser, tCfg.sBotName, "No reply with that ID." )
return false
end
if tProfiles.AllowVIP[tUser.iProfile] or tRow.nick:lower() == tUser.sNick:lower() then
local sTemporary = "The following reply has been deleted:\n\tID#%d. %s (Added by %s)"
Core.SendPmToUser( tUser, tCfg.sBotName, sTemporary:format(tInsertData.iID, tRow.msg, tRow.nick) )
tInfobot.del( tUser, tInsertData )
else
Core.SendPmToUser( tUser, tCfg.sBotName, tFunction.Report("info", 1) )
end
return true
end
return false
end