Mercurial > xib
comparison muc.py @ 17:32a35f7eff70
Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Signed-off-by: Charly COSTE <changaco@changaco.net>
author | Charly COSTE <changaco@changaco.net> |
---|---|
date | Thu, 20 Aug 2009 01:00:54 +0200 |
parents | 9631f8d9895d |
children | faa468731d8a |
comparison
equal
deleted
inserted
replaced
16:0c4a7452d66c | 17:32a35f7eff70 |
---|---|
41 self.jid = self.room_jid+'/'+nickname | 41 self.jid = self.room_jid+'/'+nickname |
42 self.nickname = nickname | 42 self.nickname = nickname |
43 self.xmpp_c = xmpp_c | 43 self.xmpp_c = xmpp_c |
44 self.callback = callback | 44 self.callback = callback |
45 self.xmpp_c.RegisterHandler('presence', self._xmpp_presence_handler) | 45 self.xmpp_c.RegisterHandler('presence', self._xmpp_presence_handler) |
46 self.xmpp_c.send(xmpp.protocol.Presence(to=self.jid, status=status)) | 46 self.xmpp_c.send(xmpp.protocol.Presence(to=self.jid, status=status, payload=[xmpp.simplexml.Node(tag='x', attrs={'xmlns': 'http://jabber.org/protocol/muc'}, payload=[xmpp.simplexml.Node(tag='history', attrs={'maxchars': '0'})])])) |
47 | 47 |
48 | 48 |
49 def _xmpp_presence_handler(self, xmpp_c, presence): | 49 def _xmpp_presence_handler(self, xmpp_c, presence): |
50 if presence.getFrom() == self.jid: | 50 if presence.getFrom() == self.jid: |
51 errors = [] | 51 errors = [] |
96 def sayTo(self, to, message): | 96 def sayTo(self, to, message): |
97 """Send a private message""" | 97 """Send a private message""" |
98 self.xmpp_c.send(xmpp.protocol.Message(to=self.room_jid+'/'+to, typ='chat', body=message)) | 98 self.xmpp_c.send(xmpp.protocol.Message(to=self.room_jid+'/'+to, typ='chat', body=message)) |
99 | 99 |
100 | 100 |
101 def change_nick(self, nickname, callback=None): | 101 def change_nick(self, nickname, status=None, callback=None): |
102 """Change nickname""" | 102 """Change nickname""" |
103 self.jid = self.room_jid+'/'+nickname | 103 self.jid = self.room_jid+'/'+nickname |
104 self.callback = callback | 104 self.callback = callback |
105 self.xmpp_c.RegisterHandler('presence', self._xmpp_presence_handler) | 105 self.xmpp_c.RegisterHandler('presence', self._xmpp_presence_handler) |
106 self.xmpp_c.send(xmpp.protocol.Presence(to=self.jid)) | 106 self.xmpp_c.send(xmpp.protocol.Presence(to=self.jid, status=status)) |
107 | 107 |
108 | 108 |
109 def leave(self, message=''): | 109 def leave(self, message=''): |
110 """Leave the room""" | 110 """Leave the room""" |
111 self.xmpp_c.send(xmpp.protocol.Presence(to=self.jid, typ='unavailable', status=message)) | 111 self.xmpp_c.send(xmpp.protocol.Presence(to=self.jid, typ='unavailable', status=message)) |