mcabbot.lua
changeset 24 77a72b227d59
parent 1 cca972635e5e
child 27 a166e9ab8065
equal deleted inserted replaced
23:491f7d046353 24:77a72b227d59
     8 require "mcbot.mcbot_engine"
     8 require "mcbot.mcbot_engine"
     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 
       
    14 local function hk_subscription (h)
       
    15     if h.type == "subscribe" then
       
    16         -- Let's authorize them...
       
    17         main.run("authorization allow "..h.jid)
       
    18         -- ... and subscribe to their own presence
       
    19         main.run("authorization request "..h.jid)
       
    20         return 1
       
    21     elseif h.type == "unsubscribe" or h.type == "unsubscribed" then
       
    22         main.run("authorization cancel "..h.jid)
       
    23     end
       
    24     return 0
       
    25 end
    13 
    26 
    14 local function hk_message_in (h)
    27 local function hk_message_in (h)
    15     local perso = false
    28     local perso = false
    16     local muc = false
    29     local muc = false
    17     local message = h.message
    30     local message = h.message
    47         if (msg) then main.run(cmd..msg) end
    60         if (msg) then main.run(cmd..msg) end
    48     end
    61     end
    49 end
    62 end
    50 
    63 
    51 main.hook("hook-post-message-in", hk_message_in)
    64 main.hook("hook-post-message-in", hk_message_in)
       
    65 main.hook("hook-subscription", hk_subscription)