-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.lua
executable file
·70 lines (54 loc) · 1.52 KB
/
main.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
#!/usr/bin/env lua
-- Cfg:
nick = "lucyna_enlikowa"
real = "/me"
chan = "#mariom-test"
host = "irc.freenode.net"
port = 6667
cmdChar = "'"
admin = "mariom!mariom@unaffiliated/mariom"
-- Załadowanie rdzenia
require( "core" )
-- Inicjalizacja rdzenia
core = core.init( nick, real, chan, host, port )
-- Połączenie z serwerem
core:connect()
-- Plugin autoload:
core:pluginLoad( "ping" )
core:pluginLoad( "hello" )
while true do
local s = socket:receive()
if s ~= nil then
print( s )
if s:match(" PRIVMSG ") then
msg = core:parse( s )
print( msg.chan .. "| " .. msg.nick .. ": " .. msg.msg )
if msg.msg:find( "^" .. cmdChar .. "load" ) then
plug = msg.msg:match("%w+$")
core:pluginLoad( plug )
cmd:msg( msg.chan, "plugin " .. plug .. " loaded" )
elseif msg.msg:find( "^" .. cmdChar .. "unload" ) then
plug = msg.msg:match("%w+$")
core:pluginUnload( plug )
cmd:msg( msg.chan, "plugin " .. plug .. " unloaded" )
end
for i, v in ipairs( core.cmd ) do
if msg.msg:find( "^" .. v.cmd ) then
cmd:msg( msg.chan,
core[ v.plugin ]:actionCmd( msg.msg, msg.nick ) )
--cmd:msg( msg.chan, core.cmd[ v ]:callBack( msg.msg, msg.nick ) )
end
end
elseif s:match("ERROR :Closing Link: ") then
print( "Bot shutdown - see you later" )
return 0
else
for i, v in ipairs( core.raw ) do
if s:find( v.cmd ) then
cmd:send( core[ v.plugin ]:actionRaw( s ) )
--cmd:send( core.cmd[ v ]:callBack( s ) )
end
end
end
end
end