-
Notifications
You must be signed in to change notification settings - Fork 13
/
eat.lua
120 lines (110 loc) · 3.52 KB
/
eat.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
--[[
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
--]]
path = Core.GetPtokaXPath().."scripts/"
bot = SetMan.GetString(21)
mpath, dpath = path.."external/metabolism/", path.."dependency/"
dofile(mpath.."digest.lua")
nickc = {}
falone = {}
muted = {}
blocked = {}
lunarised = {}
dofile( path.."texts/blocks.txt" )
desu, san, chan, inPM = false, false, false, false
local temp = { -- built in commands ,bypass these commands if typed in mainchat
"ban", "banip", "fullban", "fullbanip", "nickban", "tempban", "tempbanip", "fulltempban", "fulltempbanip", "nicktempban", "unban",
"permunban", "tempunban", "getbans", "getpermbans", "gettempbans", "clrpermbans", "clrtempbans", "rangeban", "fullrangeban",
"rangetempban", "fullrangetempban", "rangeunban", "rangepermunban", "rangetempunban", "getrangebans", "getrangepermbans",
"getrangetempbans", "clrrangepermbans", "clrrangetempbans", "checknickban", "checkipban", "checkrangeban", "getinfo", "op",
"gag", "ungag", "restart", "startscript", "stopscript", "restartscript", "restartscripts", "getscripts", "reloadtxt", "addreguser", "delreguser",
"topic", "massmsg", "opmassmsg", "myip", "help"
}
PtokaxCommands = {}
for k,v in ipairs(temp) do
PtokaxCommands[v] = true
end
tmr = TmrMan.AddTimer(400, "fileread")
fileread = function()
local file = io.open(path.."texts/IRCout.txt","r")
if not file then return end
local msg = file:read("*a")
file:close();
if msg ~= "" then
local user = {
sNick = "IRC",
sIP = "127.0.0.1",
iProfile = 6
}
local file = io.open( path.."texts/IRCout.txt","w+")
file:close()
digest(user,msg,true)
end
end
ChatArrival = function(user,data)
local tempdata = data:gsub( "|", " " ) --remove terminating |
local cmd = tempdata:match( "%b<> [-+*/!#?](%S+)%s")
local isCmd, irc = false, false
if not cmd then
isCmd = false
digest(user,tempdata,isCmd,irc)
return true
end
if isthere(cmd, PtokaxCommands) then -- let ptokax handle inbuilt commands
if cmd == "help" then -- hack to have custhelp executed each time help is executed
tempdata = tempdata:gsub("help","custhelp")
inPM = false
isCmd = true
digest(user,tempdata,isCmd,irc)
end
return
end
if isthere(cmd, CustomCommands) then
isCmd = true
inPM = false
digest(user,tempdata,isCmd,irc)
return true
end
--message begins with a command character but the command is not found . Treat it as a normal message
isCmd = false
digest(user,tempdata,isCmd,irc)
return true
end
ToArrival = function( user, data )
local tempdata = data:gsub( "|", " " ) -- remove terminating |
local to, from = tempdata:match "$To: (%S+) From: (%S+)"
if to ~= bot then
return
end
--Remove the To and From parts
tempdata=tempdata:match("$.*$(.*)")
local cmd= tempdata:match( "%b<> [-+*/!#?](%S+)%s")
if not cmd then
return
end
if isthere(cmd,CustomCommands) then
local isCmd, irc = true, false
inPM = true
digest(user,tempdata,isCmd,irc)
return true
end
if cmd == "help" then
local irc = false
tempdata = tempdata:gsub("help", "custhelp")
isCmd = true
inPM = true
digest(user,tempdata,isCmd,irc)
end
return
end
ConnectToMeArrival = function(user,data)
local uploader = data:match("$ConnectToMe%s(%S+)")
local nickpair = uploader.."$"..user.sNick
if blocked[nickpair] then
local msg = uploader.." has blocked you from downloading from them for the reason: "..blocked[nickpair]
Core.SendPmToNick(user.sNick, bot, msg)
return true
end
end