--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mcabbot.lua Sun Apr 11 18:13:18 2010 +0200
@@ -0,0 +1,49 @@
+
+local home = os.getenv("HOME")
+package.path = package.path..
+ ";"..home.."/.mcabber/lua/?.lua"..
+ ";"..home.."/.mcabber/lua/mcbot/?.lua"
+home = nil
+
+require "mcbot.mcbot_engine"
+
+local mcabbot = {}
+mcabbot.nickname = "McBot"
+mcabbot.jid = "mcabbot@lilotux.net"
+
+function mcabbot.message_in (h)
+ local perso = false
+ local muc = false
+ local message = h.message
+ if h.groupchat and h.groupchat == "true" then
+ muc = true
+ end
+ if muc == true then
+ if h.delayed == "" and h.attention and h.attention == "true" then
+ if h.resource and h.resource ~= mcabbot.nickname then
+ perso = true
+ end
+ end
+ else
+ if h.jid ~= mcabbot.jid then
+ perso = true
+ end
+ end
+ if perso == true then
+ local cmd, msg
+ if muc == true then
+ cmd = "say_to -q "..h.jid.." "..h.resource..": "
+ else
+ cmd = "say_to -q "..h.jid.."/"..h.resource.." "
+ end
+ local res, errmsg = process(message, mcabbot.nickname, muc)
+ if res then
+ msg = res
+ elseif errmsg then
+ msg = "! " .. errmsg
+ end
+ if (msg) then main.run(cmd..msg) end
+ end
+end
+
+main.hook("hook-post-message-in", mcabbot.message_in)