forked from hjpotter92/ptokax-scripts
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathreport.lua
67 lines (57 loc) · 1.96 KB
/
report.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
--[[
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()
tConfig = {
sBotName = SetMan.GetString( 21 ),
sReportBot = "#[VIPChat]",
sChatFilePath = Core.GetPtokaXPath().."scripts/dependency/chatcore.lua"
}
tConfig.sAsBot = "<"..tConfig.sBotName.."> "
dofile( tConfig.sChatFilePath )
local fCommand = io.open( Core.GetPtokaXPath().."scripts/texts/reportMenu.txt", "r+" )
sFileCommand = fCommand:read "*a"
sFileCommand = sFileCommand:gsub( "%%%[bot%]", tConfig.sBotName )
Core.SendToAll( sFileCommand )
fCommand:close()
end
function ToArrival( tUser, sMessage )
local sTo, sCommand, sData = sMessage:match "^%$To: (%S+) From:.-%b<> [-+/*?!#](%w+)%s?(.*)|"
if sTo ~= tConfig.sBotName then return false end
if sCommand and sCommand:lower() == "report" then
return ExecuteCommand( tUser, sData, true )
end
return false
end
function ChatArrival( tUser, sMessage )
local sCommand, sData = sMessage:match "%b<> [-+/*?!#](%w+)%s?(.*)|"
if not sCommand then return false end
if sCommand:lower() == "report" then
return ExecuteCommand( tUser, sData, false )
end
return false
end
function UserConnected( tUser )
Core.SendToUser( tUser, sFileCommand )
end
RegConnected, OpConnected = UserConnected, UserConnected
function Notify( tUser, sMessage, bIsPM )
if bIsPM then
Core.SendPmToUser( tUser, tConfig.sBotName, sMessage )
else
Core.SendToUser( tUser, tConfig.sAsBot..sMessage )
end
end
function ExecuteCommand( tUser, sData, bIsPM )
if sData:len() < 20 then
local sReply = "The report text should be more than 20 characters in length."
Notify( tUser, sReply, bIsPM )
return true
end
local sReport, sReply = "(Report): "..sData, "Your message [ %s ] has been reported to %s."
SendToRoom( tUser.sNick, sReport, tConfig.sReportBot )
Notify( tUser, sReply:format(sData, tConfig.sReportBot), bIsPM )
return true
end