Пример #1
0
    def presence_control(self, stanza):
        msg = unicode(stanza.get_from())
        t = stanza.get_type()
        frm = stanza.get_from()
        frm_email = "%s@%s" % (frm.node, frm.domain)
        if frm_email == DAEMONACCOUNT[0]:
            p = Presence(to_jid=frm, stanza_type="subscibe")
            return stanza.make_accept_response(), p
        if t == "subscribe":
            msg += u" has requested presence subscription."
            body = "%s 加入群" % frm.node
            p = Presence(to_jid=frm, stanza_type="subscibe")
            send_all_msg(stanza, body)
            add_member(frm)
        elif t == "subscribed":
            msg += u" has accepted our presence subscription request."
            p = Presence(to_jid=frm, stanza_type="subscibe")
            add_member(frm)
        elif t == "unsubscribe":
            msg += u" has canceled his subscription of our."
            body = "%s 离开群" % frm.node
            send_all_msg(stanza, body)
            del_member(frm)
        elif t == "unsubscribed":
            msg += u" has canceled our subscription of his presence."
            del_member(frm)

        logger.info(msg)

        return stanza.make_accept_response(), p
Пример #2
0
 def rm(self, stanza, *args):
     """剔除用户($rm nick1 nick2 nick3...)"""
     emails = [get_member(nick = n) for n in args]
     if emails >= 1:
         p = []
         for e in emails:
             jid = JID(e)
             p.append(
                 Presence(
                     to_jid = jid,
                     stanza_type='unsubscribe'
                     ))
             del_member(jid)
     else:
         p = self.help(stanza, 'rm')
     return p