-
Notifications
You must be signed in to change notification settings - Fork 0
/
commands.lua
67 lines (45 loc) · 1.67 KB
/
commands.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
local t = bot.plugins or {}
if not bot.plugins then
local f = io.popen("ls plugins", "r")
for v in f:lines() do
t[#t+1] = v
end
end
for i, v in ipairs(t) do
dofile("plugins/"..v)
print("Plugin " .. v .. " loaded.")
end
bot.PRIVMSG:register("Command parser", function(nick, target, message)
--nick = nick or ''
message = message or ''
message = message:match("^%s*(.-)%s*$")
if target == bot.nick then --private message!
local success, r = pcall(bot.commands.cookie, message, nick, target, true)
if not success and r then
sendNotice(r, nick)
end
end
if ((not settings.Master) or (settings.Master and masters[nick:lower()])) and not ignored[nick:lower()] then
if message:lower() == bot.nick:lower()..'!' then
sendMessage(nick..'!', (target == bot.nick) and nick or target)
end
if message:match("^".. bot.nick .."%, *") then message = message:gsub("^" .. bot.nick .. "%, *", ",") end
local i = message:sub(1,1)
if i == '!' then
local m = message:sub(2, -1)
local command, args = m:match(scp)
command = command or m
if not bot.commands[command] then return end
local success, result = pcall(bot.commands[command], args, nick, target)
if not success then
sendNotice(result, nick)
end
end
table.insert(messages[target == bot.nick and nick or target], {nick, message})
end
end)
bot["396"]:register("bot.onLoad", function(nick, host)
if nick:lower() == bot.nick:lower() then
bot.onLoad:fire()
end
end)