equal
deleted
inserted
replaced
9 |
9 |
10 local mcabbot = {} |
10 local mcabbot = {} |
11 mcabbot.nickname = "McBot" |
11 mcabbot.nickname = "McBot" |
12 mcabbot.jid = "mcabbot@lilotux.net" |
12 mcabbot.jid = "mcabbot@lilotux.net" |
13 |
13 |
14 function mcabbot.message_in (h) |
14 local function hk_message_in (h) |
15 local perso = false |
15 local perso = false |
16 local muc = false |
16 local muc = false |
17 local message = h.message |
17 local message = h.message |
18 if h.groupchat and h.groupchat == "true" then |
18 if h.groupchat and h.groupchat == "true" then |
19 muc = true |
19 muc = true |
34 if muc == true then |
34 if muc == true then |
35 cmd = "say_to -q "..h.jid.." "..h.resource..": " |
35 cmd = "say_to -q "..h.jid.." "..h.resource..": " |
36 else |
36 else |
37 cmd = "say_to -q "..h.jid.."/"..h.resource.." " |
37 cmd = "say_to -q "..h.jid.."/"..h.resource.." " |
38 end |
38 end |
39 local res, errmsg = process(message, mcabbot.nickname, muc) |
39 mcabbot.message = h |
|
40 local res, errmsg = process(message, mcabbot, muc) |
|
41 mcabbot.message = nil |
40 if res then |
42 if res then |
41 msg = res |
43 msg = res |
42 elseif errmsg then |
44 elseif errmsg then |
43 msg = "! " .. errmsg |
45 msg = "! " .. errmsg |
44 end |
46 end |
45 if (msg) then main.run(cmd..msg) end |
47 if (msg) then main.run(cmd..msg) end |
46 end |
48 end |
47 end |
49 end |
48 |
50 |
49 main.hook("hook-post-message-in", mcabbot.message_in) |
51 main.hook("hook-post-message-in", hk_message_in) |