--- a/mcabbot.lua Thu Apr 15 21:47:33 2010 +0200
+++ b/mcabbot.lua Sat Apr 17 14:40:36 2010 +0200
@@ -11,6 +11,19 @@
mcabbot.nickname = "McBot"
mcabbot.jid = "mcabbot@lilotux.net"
+local function hk_subscription (h)
+ if h.type == "subscribe" then
+ -- Let's authorize them...
+ main.run("authorization allow "..h.jid)
+ -- ... and subscribe to their own presence
+ main.run("authorization request "..h.jid)
+ return 1
+ elseif h.type == "unsubscribe" or h.type == "unsubscribed" then
+ main.run("authorization cancel "..h.jid)
+ end
+ return 0
+end
+
local function hk_message_in (h)
local perso = false
local muc = false
@@ -49,3 +62,4 @@
end
main.hook("hook-post-message-in", hk_message_in)
+main.hook("hook-subscription", hk_subscription)