def handle_presence_subscribe(self, stanza): self.logger.info(u"{0} join us".format(stanza.from_jid)) frm = stanza.from_jid presence = Presence(to_jid=frm, stanza_type="subscribe") Logics.add(frm, None, stanza.show) r = [stanza.make_accept_response(), presence] if frm not in self.sended: self.message_bus.send_sys_msg(stanza, new_member(frm)) self.message_bus.send_back_msg(stanza, welcome(frm)) self.sended.append(frm) return r
def handle_presence_subscribe(self, stanza): self.logger.info(u"{0} join us".format(stanza.from_jid)) frm = stanza.from_jid presence = Presence(to_jid = frm, stanza_type = "subscribe") Logics.add(frm, None, stanza.show) r =[stanza.make_accept_response(), presence] if frm not in self.sended: self.message_bus.send_sys_msg(stanza, new_member(frm)) self.message_bus.send_back_msg(stanza, welcome(frm)) self.sended.append(frm) return r
def handle_roster_received(self, event): dbstatus = Logics.get_global_info('status').value if not dbstatus: status = STATUS else: status = dbstatus p = Presence(status=status) self.client.stream.send(p) ret = [x.jid.bare() for x in self.roster if x.subscription == 'both'] self.logger.info(' -- roster:{0}'.format(ret)) members = Logics.get_members() members = [m.email for m in members] [Logics.add(frm) for frm in ret if not Logics.get_one(frm)] if IMPORT: [self.invite_member(JID(m)) for m in members if JID(m) not in ret]