# HG changeset patch # User Mikael Berthe # Date 1271508036 -7200 # Node ID 77a72b227d59accc7aaebe442b7661e8ba753bc2 # Parent 491f7d04635340d2454ed81023587aa6b07a6c49 Handle subscription requests \o/ diff -r 491f7d046353 -r 77a72b227d59 mcabbot.lua --- 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)