annotate bot.py @ 48:cb08ea878db9

lower() for "join" and "namreply" IRC events Signed-off-by: Charly COSTE <changaco@changaco.net>
author Charly COSTE <changaco@changaco.net>
date Mon, 24 Aug 2009 23:32:34 +0200
parents dd9d93ae405a
children 714e78fb912e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
1 #!/usr/bin/env python
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
3
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
4 # This program is free software: you can redistribute it and/or modify
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
5 # it under the terms of the GNU General Public License as published by
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
6 # the Free Software Foundation, either version 3 of the License, or
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
7 # (at your option) any later version.
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
8 #
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
9 # This program is distributed in the hope that it will be useful,
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
12 # GNU General Public License for more details.
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
13 #
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
14 # You should have received a copy of the GNU General Public License
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
16
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
17
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
18 # *** Versioning ***
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
19 # Major will pass to 1 when xib will be considered fault-tolerant
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
20 # After that major will only be changed if the new version is not retro-compatible (e.g. requires changes in config file)
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
21
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
22 version = 0, 1
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
23
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
24
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
25 import irclib
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
26 import xmppony as xmpp
24
4e1f27ea527b First hack at locks for thread safety. Some other minor changes.
Charly COSTE <changaco@changaco.net>
parents: 23
diff changeset
27 import threading
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
28 from bridge import *
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
29 from time import sleep
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
30 import re
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
31 import sys
20
08cde283621a Fixed a little bug in exception handling.
Charly COSTE <changaco@changaco.net>
parents: 19
diff changeset
32 import xml.parsers.expat
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
33
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
34
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
35 class bot(Thread):
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
36
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
37 def __init__(self, jid, password, nickname, error_fd=sys.stderr, debug=False):
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
38 Thread.__init__(self)
18
3cdf7bb580da Fixed bot.respond(), boosted XMPP thread to lower latency, fixed mode notice.
Charly COSTE <changaco@changaco.net>
parents: 17
diff changeset
39 self.commands = ['!xmpp_participants', '!irc_participants']
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
40 self.bare_jid = xmpp.protocol.JID(jid=jid)
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
41 self.bare_jid.setResource('')
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
42 self.nickname = nickname
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
43 self.password = password
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
44 self.error_fd = error_fd
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
45 self.debug = debug
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
46 self.bridges = []
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
47 self.xmpp_connections = {}
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
48 self.irc = irclib.IRC()
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
49 self.irc.bot = self
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
50 self.irc.add_global_handler('all_events', self._irc_event_handler)
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
51 self.irc_thread = Thread(target=self.irc.process_forever)
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
52 self.irc_thread.start()
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
53 # Open connection with XMPP server
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
54 try:
22
e2bd4de698e5 Solved an XMPP resource conflict that would have happened when someone on IRC changed its nickname and later its old nickname would be used again. In other words, the bot no longer uses nicknames as XMPP resources.
Charly COSTE <changaco@changaco.net>
parents: 21
diff changeset
55 self.xmpp_c = self.get_xmpp_connection(self.nickname)
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
56 except:
19
c1b84196c100 Changed format of non-debug error messages, fixed IRC namreply handling, prevented crash when receiving bad XMPP stanza.
Charly COSTE <changaco@changaco.net>
parents: 18
diff changeset
57 self.error('[Error] XMPP Connection failed')
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
58 raise
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
59 self.xmpp_thread = Thread(target=self._xmpp_loop)
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
60 self.xmpp_thread.start()
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
61
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
62
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
63 def error(self, s, debug=False):
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
64 """Output an error message."""
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
65 if not debug or debug and self.debug:
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
66 try:
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
67 self.error_fd.write(auto_encode(s)+"\n")
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
68 except EncodingException:
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
69 self.error_fd.write('Error message cannot be transcoded.\n')
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
70
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
71
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
72 def _xmpp_loop(self):
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
73 """[Internal] XMPP infinite loop."""
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
74 while True:
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
75 try:
19
c1b84196c100 Changed format of non-debug error messages, fixed IRC namreply handling, prevented crash when receiving bad XMPP stanza.
Charly COSTE <changaco@changaco.net>
parents: 18
diff changeset
76 try:
41
4c4f4ee72e17 Fixed IRC "nick" event handling. Fixed bot's XMPP infinite loop.
Charly COSTE <changaco@changaco.net>
parents: 39
diff changeset
77 if len(self.xmpp_connections) == 1:
4c4f4ee72e17 Fixed IRC "nick" event handling. Fixed bot's XMPP infinite loop.
Charly COSTE <changaco@changaco.net>
parents: 39
diff changeset
78 sleep(0.5) # avoid bot connection being locked all the time
19
c1b84196c100 Changed format of non-debug error messages, fixed IRC namreply handling, prevented crash when receiving bad XMPP stanza.
Charly COSTE <changaco@changaco.net>
parents: 18
diff changeset
79 for c in self.xmpp_connections.itervalues():
46
d29171ab2df1 Removed unnecessary and buggy test
Charly COSTE <changaco@changaco.net>
parents: 45
diff changeset
80 if hasattr(c, 'Process'):
24
4e1f27ea527b First hack at locks for thread safety. Some other minor changes.
Charly COSTE <changaco@changaco.net>
parents: 23
diff changeset
81 c.lock.acquire()
47
dd9d93ae405a Reduce latency.
Charly COSTE <changaco@changaco.net>
parents: 46
diff changeset
82 c.Process(0.01)
24
4e1f27ea527b First hack at locks for thread safety. Some other minor changes.
Charly COSTE <changaco@changaco.net>
parents: 23
diff changeset
83 c.lock.release()
19
c1b84196c100 Changed format of non-debug error messages, fixed IRC namreply handling, prevented crash when receiving bad XMPP stanza.
Charly COSTE <changaco@changaco.net>
parents: 18
diff changeset
84 except RuntimeError:
c1b84196c100 Changed format of non-debug error messages, fixed IRC namreply handling, prevented crash when receiving bad XMPP stanza.
Charly COSTE <changaco@changaco.net>
parents: 18
diff changeset
85 pass
24
4e1f27ea527b First hack at locks for thread safety. Some other minor changes.
Charly COSTE <changaco@changaco.net>
parents: 23
diff changeset
86 except (xml.parsers.expat.ExpatError, xmpp.protocol.XMLNotWellFormed):
19
c1b84196c100 Changed format of non-debug error messages, fixed IRC namreply handling, prevented crash when receiving bad XMPP stanza.
Charly COSTE <changaco@changaco.net>
parents: 18
diff changeset
87 self.error('=> Debug: received invalid stanza', debug=True)
c1b84196c100 Changed format of non-debug error messages, fixed IRC namreply handling, prevented crash when receiving bad XMPP stanza.
Charly COSTE <changaco@changaco.net>
parents: 18
diff changeset
88 continue
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
89
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
90
22
e2bd4de698e5 Solved an XMPP resource conflict that would have happened when someone on IRC changed its nickname and later its old nickname would be used again. In other words, the bot no longer uses nicknames as XMPP resources.
Charly COSTE <changaco@changaco.net>
parents: 21
diff changeset
91 def _xmpp_presence_handler(self, dispatcher, presence):
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
92 """[Internal] Manage XMPP presence."""
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
93
22
e2bd4de698e5 Solved an XMPP resource conflict that would have happened when someone on IRC changed its nickname and later its old nickname would be used again. In other words, the bot no longer uses nicknames as XMPP resources.
Charly COSTE <changaco@changaco.net>
parents: 21
diff changeset
94 xmpp_c = dispatcher._owner
e2bd4de698e5 Solved an XMPP resource conflict that would have happened when someone on IRC changed its nickname and later its old nickname would be used again. In other words, the bot no longer uses nicknames as XMPP resources.
Charly COSTE <changaco@changaco.net>
parents: 21
diff changeset
95
e2bd4de698e5 Solved an XMPP resource conflict that would have happened when someone on IRC changed its nickname and later its old nickname would be used again. In other words, the bot no longer uses nicknames as XMPP resources.
Charly COSTE <changaco@changaco.net>
parents: 21
diff changeset
96 if xmpp_c.nickname != self.nickname:
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
97 self.error('=> Debug: Skipping XMPP presence not received on bot connection.', debug=True)
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
98 return
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
99
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
100 self.error('==> Debug: Received XMPP presence.', debug=True)
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
101 self.error(presence.__str__(fancy=1), debug=True)
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
102
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
103 from_ = xmpp.protocol.JID(presence.getFrom())
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
104 bare_jid = unicode(from_.getNode()+'@'+from_.getDomain())
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
105 for bridge in self.bridges:
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
106 if bare_jid == bridge.xmpp_room.room_jid:
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
107 # presence comes from a muc
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
108 resource = unicode(from_.getResource())
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
109
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
110 if resource == '':
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
111 # presence comes from the muc itself
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
112 # TODO: handle room deletion and muc server reboot
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
113 pass
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
114
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
115 else:
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
116 # presence comes from a participant of the muc
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
117 try:
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
118 p = bridge.getParticipant(resource)
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
119
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
120 except NoSuchParticipantException:
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
121 if presence.getType() != 'unavailable' and resource != bridge.bot.nickname:
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
122 bridge.addParticipant('xmpp', resource)
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
123 return
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
124
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
125
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
126 if p.protocol == 'xmpp' and presence.getType() == 'unavailable':
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
127 x = presence.getTag('x', namespace='http://jabber.org/protocol/muc#user')
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
128 if x and x.getTag('status', attrs={'code': '303'}):
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
129 # participant changed its nickname
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
130 item = x.getTag('item')
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
131 if not item:
19
c1b84196c100 Changed format of non-debug error messages, fixed IRC namreply handling, prevented crash when receiving bad XMPP stanza.
Charly COSTE <changaco@changaco.net>
parents: 18
diff changeset
132 self.error('=> Debug: bad stanza, no item element', debug=True)
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
133 return
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
134 new_nick = item.getAttr('nick')
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
135 if not new_nick:
19
c1b84196c100 Changed format of non-debug error messages, fixed IRC namreply handling, prevented crash when receiving bad XMPP stanza.
Charly COSTE <changaco@changaco.net>
parents: 18
diff changeset
136 self.error('=> Debug: bad stanza, new nick is not given', debug=True)
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
137 return
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
138 p.changeNickname(new_nick, 'irc')
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
139
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
140 else:
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
141 # participant left
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
142 bridge.removeParticipant('xmpp', resource, presence.getStatus())
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
143
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
144 return
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
145
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
146
22
e2bd4de698e5 Solved an XMPP resource conflict that would have happened when someone on IRC changed its nickname and later its old nickname would be used again. In other words, the bot no longer uses nicknames as XMPP resources.
Charly COSTE <changaco@changaco.net>
parents: 21
diff changeset
147 def _xmpp_iq_handler(self, dispatcher, iq):
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
148 """[Internal] Manage XMPP IQs."""
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
149 self.error('=> Debug: Received XMPP iq.', debug=True)
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
150 self.error(iq.__str__(fancy=1), debug=True)
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
151
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
152
22
e2bd4de698e5 Solved an XMPP resource conflict that would have happened when someone on IRC changed its nickname and later its old nickname would be used again. In other words, the bot no longer uses nicknames as XMPP resources.
Charly COSTE <changaco@changaco.net>
parents: 21
diff changeset
153 def _xmpp_message_handler(self, dispatcher, message):
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
154 """[Internal] Manage XMPP messages."""
22
e2bd4de698e5 Solved an XMPP resource conflict that would have happened when someone on IRC changed its nickname and later its old nickname would be used again. In other words, the bot no longer uses nicknames as XMPP resources.
Charly COSTE <changaco@changaco.net>
parents: 21
diff changeset
155
e2bd4de698e5 Solved an XMPP resource conflict that would have happened when someone on IRC changed its nickname and later its old nickname would be used again. In other words, the bot no longer uses nicknames as XMPP resources.
Charly COSTE <changaco@changaco.net>
parents: 21
diff changeset
156 xmpp_c = dispatcher._owner
e2bd4de698e5 Solved an XMPP resource conflict that would have happened when someone on IRC changed its nickname and later its old nickname would be used again. In other words, the bot no longer uses nicknames as XMPP resources.
Charly COSTE <changaco@changaco.net>
parents: 21
diff changeset
157
34
57d0e66378b0 Fixed XMPP message handling and removed disconnect handler.
Charly COSTE <changaco@changaco.net>
parents: 33
diff changeset
158 if message.getBody() == None:
57d0e66378b0 Fixed XMPP message handling and removed disconnect handler.
Charly COSTE <changaco@changaco.net>
parents: 33
diff changeset
159 return
57d0e66378b0 Fixed XMPP message handling and removed disconnect handler.
Charly COSTE <changaco@changaco.net>
parents: 33
diff changeset
160
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
161 if message.getType() == 'chat':
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
162 self.error('==> Debug: Received XMPP chat message.', debug=True)
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
163 self.error(message.__str__(fancy=1), debug=True)
11
79b0a7f48a3e Introduced the command mechanism and fixed a bug
Charly COSTE <changaco@changaco.net>
parents: 10
diff changeset
164 from_bare_jid = unicode(message.getFrom().getNode()+'@'+message.getFrom().getDomain())
79b0a7f48a3e Introduced the command mechanism and fixed a bug
Charly COSTE <changaco@changaco.net>
parents: 10
diff changeset
165 for bridge in self.bridges:
79b0a7f48a3e Introduced the command mechanism and fixed a bug
Charly COSTE <changaco@changaco.net>
parents: 10
diff changeset
166 if from_bare_jid == bridge.xmpp_room.room_jid:
79b0a7f48a3e Introduced the command mechanism and fixed a bug
Charly COSTE <changaco@changaco.net>
parents: 10
diff changeset
167 # message comes from a room participant
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
168
11
79b0a7f48a3e Introduced the command mechanism and fixed a bug
Charly COSTE <changaco@changaco.net>
parents: 10
diff changeset
169 try:
79b0a7f48a3e Introduced the command mechanism and fixed a bug
Charly COSTE <changaco@changaco.net>
parents: 10
diff changeset
170 from_ = bridge.getParticipant(message.getFrom().getResource())
27
9b7a628ca612 Fixed XMPP message handling, again.
Charly COSTE <changaco@changaco.net>
parents: 25
diff changeset
171 to_ = bridge.getParticipant(xmpp_c.nickname)
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
172
34
57d0e66378b0 Fixed XMPP message handling and removed disconnect handler.
Charly COSTE <changaco@changaco.net>
parents: 33
diff changeset
173 from_.sayOnIRCTo(to_.nickname, message.getBody())
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
174
11
79b0a7f48a3e Introduced the command mechanism and fixed a bug
Charly COSTE <changaco@changaco.net>
parents: 10
diff changeset
175 except NoSuchParticipantException:
22
e2bd4de698e5 Solved an XMPP resource conflict that would have happened when someone on IRC changed its nickname and later its old nickname would be used again. In other words, the bot no longer uses nicknames as XMPP resources.
Charly COSTE <changaco@changaco.net>
parents: 21
diff changeset
176 if xmpp_c.nickname == self.nickname:
18
3cdf7bb580da Fixed bot.respond(), boosted XMPP thread to lower latency, fixed mode notice.
Charly COSTE <changaco@changaco.net>
parents: 17
diff changeset
177 xmpp_c.send(xmpp.protocol.Message(to=message.getFrom(), body=self.respond(message.getBody(), participant=from_), typ='chat'))
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
178 return
22
e2bd4de698e5 Solved an XMPP resource conflict that would have happened when someone on IRC changed its nickname and later its old nickname would be used again. In other words, the bot no longer uses nicknames as XMPP resources.
Charly COSTE <changaco@changaco.net>
parents: 21
diff changeset
179 self.error('=> Debug: XMPP chat message not relayed', debug=True)
11
79b0a7f48a3e Introduced the command mechanism and fixed a bug
Charly COSTE <changaco@changaco.net>
parents: 10
diff changeset
180 return
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
181
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
182 elif message.getType() == 'groupchat':
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
183 # message comes from a room
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
184
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
185 for child in message.getChildren():
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
186 if child.getName() == 'delay':
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
187 # MUC delayed message
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
188 return
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
189
22
e2bd4de698e5 Solved an XMPP resource conflict that would have happened when someone on IRC changed its nickname and later its old nickname would be used again. In other words, the bot no longer uses nicknames as XMPP resources.
Charly COSTE <changaco@changaco.net>
parents: 21
diff changeset
190 if xmpp_c.nickname != self.nickname:
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
191 self.error('=> Debug: Ignoring XMPP MUC message not received on bot connection.', debug=True)
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
192 return
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
193
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
194
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
195 from_ = xmpp.protocol.JID(message.getFrom())
23
abdb7a2b6c6d Minor fixes.
Charly COSTE <changaco@changaco.net>
parents: 22
diff changeset
196
abdb7a2b6c6d Minor fixes.
Charly COSTE <changaco@changaco.net>
parents: 22
diff changeset
197 if unicode(from_.getResource()) == self.nickname:
abdb7a2b6c6d Minor fixes.
Charly COSTE <changaco@changaco.net>
parents: 22
diff changeset
198 self.error('=> Debug: Ignoring XMPP MUC message sent by self.', debug=True)
abdb7a2b6c6d Minor fixes.
Charly COSTE <changaco@changaco.net>
parents: 22
diff changeset
199 return
abdb7a2b6c6d Minor fixes.
Charly COSTE <changaco@changaco.net>
parents: 22
diff changeset
200
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
201 room_jid = unicode(from_.getNode()+'@'+from_.getDomain())
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
202 for bridge in self.bridges:
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
203 if room_jid == bridge.xmpp_room.room_jid:
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
204 resource = unicode(from_.getResource())
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
205 if resource == '':
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
206 # message comes from the room itself
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
207 self.error('=> Debug: Ignoring XMPP groupchat message sent by the room.', debug=True)
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
208 return
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
209 else:
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
210 # message comes from a participant of the room
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
211 self.error('==> Debug: Received XMPP groupchat message.', debug=True)
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
212 self.error(message.__str__(fancy=1), debug=True)
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
213
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
214 try:
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
215 participant_ = bridge.getParticipant(resource)
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
216 except NoSuchParticipantException:
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
217 if resource != self.nickname:
37
7e500d4064fb Cosmetics.
Charly COSTE <changaco@changaco.net>
parents: 35
diff changeset
218 self.error('=> Debug: NoSuchParticipantException "'+resource+'" on "'+str(bridge)+'", WTF ?', debug=True)
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
219 return
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
220
25
a9066c416533 Added an XMPP disconnect handler, fixed XMPP message handling.
Charly COSTE <changaco@changaco.net>
parents: 24
diff changeset
221 participant_.sayOnIRC(message.getBody())
37
7e500d4064fb Cosmetics.
Charly COSTE <changaco@changaco.net>
parents: 35
diff changeset
222 return
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
223
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
224 else:
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
225 self.error('==> Debug: Received XMPP message of unknown type "'+message.getType()+'".', debug=True)
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
226 self.error(message.__str__(fancy=1), debug=True)
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
227
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
228
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
229 def _irc_event_handler(self, connection, event):
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
230 """[Internal] Manage IRC events"""
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
231
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
232 # Answer ping
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
233 if event.eventtype() == 'ping':
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
234 connection.pong(connection.get_server_name())
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
235 return
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
236
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
237
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
238 # Events we always want to ignore
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
239 if 'all' in event.eventtype() or 'motd' in event.eventtype():
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
240 return
23
abdb7a2b6c6d Minor fixes.
Charly COSTE <changaco@changaco.net>
parents: 22
diff changeset
241 if event.eventtype() in ['pong', 'privnotice', 'ctcp', 'nochanmodes', 'notexttosend', 'currenttopic', 'topicinfo']:
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
242 self.error('=> Debug: ignoring '+event.eventtype(), debug=True)
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
243 return
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
244
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
245
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
246 nickname = None
24
4e1f27ea527b First hack at locks for thread safety. Some other minor changes.
Charly COSTE <changaco@changaco.net>
parents: 23
diff changeset
247 if event.source() != None:
4e1f27ea527b First hack at locks for thread safety. Some other minor changes.
Charly COSTE <changaco@changaco.net>
parents: 23
diff changeset
248 if '!' in event.source():
4e1f27ea527b First hack at locks for thread safety. Some other minor changes.
Charly COSTE <changaco@changaco.net>
parents: 23
diff changeset
249 nickname = event.source().split('!')[0]
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
250
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
251
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
252 # Events that we want to ignore only in some cases
14
1a1f2a0d35c7 Fixed bug that prevented the bot from connecting to freenode and all other servers that don't send "umode"
Charly COSTE <changaco@changaco.net>
parents: 11
diff changeset
253 if event.eventtype() in ['umode', 'welcome', 'yourhost', 'created', 'myinfo', 'featurelist', 'luserclient', 'luserop', 'luserchannels', 'luserme', 'n_local', 'n_global', 'endofnames', 'luserunknown', 'luserconns']:
1a1f2a0d35c7 Fixed bug that prevented the bot from connecting to freenode and all other servers that don't send "umode"
Charly COSTE <changaco@changaco.net>
parents: 11
diff changeset
254 if connection.really_connected == False:
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
255 if event.target() == connection.nickname:
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
256 connection.really_connected = True
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
257 connection._call_nick_callbacks(None)
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
258 elif len(connection.nick_callbacks) > 0:
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
259 self.error('===> Debug: event target ('+event.target()+') and connection nickname ('+connection.nickname+') don\'t match')
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
260 connection._call_nick_callbacks('nicknametoolong', arguments=[len(event.target())])
14
1a1f2a0d35c7 Fixed bug that prevented the bot from connecting to freenode and all other servers that don't send "umode"
Charly COSTE <changaco@changaco.net>
parents: 11
diff changeset
261 self.error('=> Debug: ignoring '+event.eventtype(), debug=True)
1a1f2a0d35c7 Fixed bug that prevented the bot from connecting to freenode and all other servers that don't send "umode"
Charly COSTE <changaco@changaco.net>
parents: 11
diff changeset
262 return
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
263
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
264
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
265 # A string representation of the event
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
266 event_str = '==> Debug: Received IRC event.\nconnection='+str(connection)+'\neventtype='+event.eventtype()+'\nsource='+str(event.source())+'\ntarget='+str(event.target())+'\narguments='+str(event.arguments())
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
267
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
268
32
8aa261545662 Implemented "/me" in the IRC->XMPP way (ie "action" event is now handled). Re-written bot.getBridges because the old one didn't always work and was slow.
Charly COSTE <changaco@changaco.net>
parents: 30
diff changeset
269 if event.eventtype() in ['pubmsg', 'action', 'privmsg', 'quit', 'part', 'nick']:
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
270 if nickname == None:
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
271 return
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
272
39
3b06450d60cd Improved debug output.
Charly COSTE <changaco@changaco.net>
parents: 37
diff changeset
273 handled = False
3b06450d60cd Improved debug output.
Charly COSTE <changaco@changaco.net>
parents: 37
diff changeset
274
3b06450d60cd Improved debug output.
Charly COSTE <changaco@changaco.net>
parents: 37
diff changeset
275 if event.eventtype() in ['quit', 'part', 'nick']:
3b06450d60cd Improved debug output.
Charly COSTE <changaco@changaco.net>
parents: 37
diff changeset
276 self.error(event_str, debug=True)
3b06450d60cd Improved debug output.
Charly COSTE <changaco@changaco.net>
parents: 37
diff changeset
277
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
278 # TODO: lock self.bridges for thread safety
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
279 for bridge in self.bridges:
32
8aa261545662 Implemented "/me" in the IRC->XMPP way (ie "action" event is now handled). Re-written bot.getBridges because the old one didn't always work and was slow.
Charly COSTE <changaco@changaco.net>
parents: 30
diff changeset
280 if connection.server != bridge.irc_server:
8aa261545662 Implemented "/me" in the IRC->XMPP way (ie "action" event is now handled). Re-written bot.getBridges because the old one didn't always work and was slow.
Charly COSTE <changaco@changaco.net>
parents: 30
diff changeset
281 continue
8aa261545662 Implemented "/me" in the IRC->XMPP way (ie "action" event is now handled). Re-written bot.getBridges because the old one didn't always work and was slow.
Charly COSTE <changaco@changaco.net>
parents: 30
diff changeset
282
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
283 try:
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
284 from_ = bridge.getParticipant(nickname)
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
285
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
286 except NoSuchParticipantException:
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
287 continue
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
288
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
289
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
290 # Private message
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
291 if event.eventtype() == 'privmsg':
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
292 if event.target() == None:
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
293 return
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
294
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
295 try:
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
296 to_ = bridge.getParticipant(event.target().split('!')[0])
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
297 self.error(event_str, debug=True)
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
298 from_.sayOnXMPPTo(to_.nickname, event.arguments()[0])
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
299 return
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
300
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
301 except NoSuchParticipantException:
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
302 if event.target().split('!')[0] == self.nickname:
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
303 # Message is for the bot
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
304 self.error(event_str, debug=True)
18
3cdf7bb580da Fixed bot.respond(), boosted XMPP thread to lower latency, fixed mode notice.
Charly COSTE <changaco@changaco.net>
parents: 17
diff changeset
305 connection.privmsg(from_.nickname, self.respond(event.arguments()[0]))
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
306 return
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
307 else:
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
308 continue
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
309
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
310
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
311 # From here we skip if the event was not received on bot connection
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
312 if connection.get_nickname() != self.nickname:
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
313 self.error('=> Debug: ignoring IRC '+event.eventtype()+' not received on bridge connection', debug=True)
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
314 continue
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
315
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
316 # Leaving events
45
41394ddb3aff Lower before comparing strings.
Charly COSTE <changaco@changaco.net>
parents: 44
diff changeset
317 if event.eventtype() == 'quit' or event.eventtype() == 'part' and event.target().lower() == bridge.irc_room:
30
c0fb916cb0a0 Fixed IRC leaving events handling.
Charly COSTE <changaco@changaco.net>
parents: 29
diff changeset
318 if len(event.arguments()) > 0:
c0fb916cb0a0 Fixed IRC leaving events handling.
Charly COSTE <changaco@changaco.net>
parents: 29
diff changeset
319 leave_message = event.arguments()[0]
c0fb916cb0a0 Fixed IRC leaving events handling.
Charly COSTE <changaco@changaco.net>
parents: 29
diff changeset
320 elif event.eventtype() == 'quit':
c0fb916cb0a0 Fixed IRC leaving events handling.
Charly COSTE <changaco@changaco.net>
parents: 29
diff changeset
321 leave_message = 'Left server.'
c0fb916cb0a0 Fixed IRC leaving events handling.
Charly COSTE <changaco@changaco.net>
parents: 29
diff changeset
322 elif event.eventtype() == 'part':
c0fb916cb0a0 Fixed IRC leaving events handling.
Charly COSTE <changaco@changaco.net>
parents: 29
diff changeset
323 leave_message = 'Left channel.'
c0fb916cb0a0 Fixed IRC leaving events handling.
Charly COSTE <changaco@changaco.net>
parents: 29
diff changeset
324 else:
c0fb916cb0a0 Fixed IRC leaving events handling.
Charly COSTE <changaco@changaco.net>
parents: 29
diff changeset
325 leave_message = ''
c0fb916cb0a0 Fixed IRC leaving events handling.
Charly COSTE <changaco@changaco.net>
parents: 29
diff changeset
326 bridge.removeParticipant('irc', from_.nickname, leave_message)
39
3b06450d60cd Improved debug output.
Charly COSTE <changaco@changaco.net>
parents: 37
diff changeset
327 handled = True
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
328 continue
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
329
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
330
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
331 # Nickname change
41
4c4f4ee72e17 Fixed IRC "nick" event handling. Fixed bot's XMPP infinite loop.
Charly COSTE <changaco@changaco.net>
parents: 39
diff changeset
332 if event.eventtype() == 'nick':
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
333 from_.changeNickname(event.target(), 'xmpp')
39
3b06450d60cd Improved debug output.
Charly COSTE <changaco@changaco.net>
parents: 37
diff changeset
334 handled = True
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
335 continue
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
336
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
337
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
338 # Chan message
32
8aa261545662 Implemented "/me" in the IRC->XMPP way (ie "action" event is now handled). Re-written bot.getBridges because the old one didn't always work and was slow.
Charly COSTE <changaco@changaco.net>
parents: 30
diff changeset
339 if event.eventtype() in ['pubmsg', 'action']:
45
41394ddb3aff Lower before comparing strings.
Charly COSTE <changaco@changaco.net>
parents: 44
diff changeset
340 if bridge.irc_room == event.target().lower() and bridge.irc_server == connection.server:
39
3b06450d60cd Improved debug output.
Charly COSTE <changaco@changaco.net>
parents: 37
diff changeset
341 self.error(event_str, debug=True)
32
8aa261545662 Implemented "/me" in the IRC->XMPP way (ie "action" event is now handled). Re-written bot.getBridges because the old one didn't always work and was slow.
Charly COSTE <changaco@changaco.net>
parents: 30
diff changeset
342 message = event.arguments()[0]
8aa261545662 Implemented "/me" in the IRC->XMPP way (ie "action" event is now handled). Re-written bot.getBridges because the old one didn't always work and was slow.
Charly COSTE <changaco@changaco.net>
parents: 30
diff changeset
343 if event.eventtype() == 'action':
8aa261545662 Implemented "/me" in the IRC->XMPP way (ie "action" event is now handled). Re-written bot.getBridges because the old one didn't always work and was slow.
Charly COSTE <changaco@changaco.net>
parents: 30
diff changeset
344 message = '/me '+message
8aa261545662 Implemented "/me" in the IRC->XMPP way (ie "action" event is now handled). Re-written bot.getBridges because the old one didn't always work and was slow.
Charly COSTE <changaco@changaco.net>
parents: 30
diff changeset
345 from_.sayOnXMPP(message)
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
346 return
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
347 else:
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
348 continue
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
349
39
3b06450d60cd Improved debug output.
Charly COSTE <changaco@changaco.net>
parents: 37
diff changeset
350 if handled == False:
3b06450d60cd Improved debug output.
Charly COSTE <changaco@changaco.net>
parents: 37
diff changeset
351 if not event.eventtype() in ['quit', 'part', 'nick']:
3b06450d60cd Improved debug output.
Charly COSTE <changaco@changaco.net>
parents: 37
diff changeset
352 self.error(event_str, debug=True)
44
3d964ca1cf89 Fixed XMPP infinite loop and a debug message that wasn't flagged as a debug one.
Charly COSTE <changaco@changaco.net>
parents: 42
diff changeset
353 self.error('=> Debug: event was not handled', debug=True)
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
354 return
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
355
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
356
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
357 if event.eventtype() in ['namreply', 'join']:
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
358 if connection.get_nickname() != self.nickname:
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
359 self.error('=> Debug: ignoring IRC '+event.eventtype()+' not received on bridge connection', debug=True)
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
360 return
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
361
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
362 if event.eventtype() == 'namreply':
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
363 # TODO: lock self.bridges for thread safety
48
cb08ea878db9 lower() for "join" and "namreply" IRC events
Charly COSTE <changaco@changaco.net>
parents: 47
diff changeset
364 for bridge in self.getBridges(irc_room=event.arguments()[1].lower(), irc_server=connection.server):
19
c1b84196c100 Changed format of non-debug error messages, fixed IRC namreply handling, prevented crash when receiving bad XMPP stanza.
Charly COSTE <changaco@changaco.net>
parents: 18
diff changeset
365 for nickname in re.split('(?:^[&@\+]?|(?: [&@\+]?)*)', event.arguments()[2].strip()):
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
366 if nickname == '' or nickname == self.nickname:
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
367 continue
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
368 bridge.addParticipant('irc', nickname)
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
369 return
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
370 elif event.eventtype() == 'join':
48
cb08ea878db9 lower() for "join" and "namreply" IRC events
Charly COSTE <changaco@changaco.net>
parents: 47
diff changeset
371 bridges = self.getBridges(irc_room=event.target().lower(), irc_server=connection.server)
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
372 if len(bridges) == 0:
48
cb08ea878db9 lower() for "join" and "namreply" IRC events
Charly COSTE <changaco@changaco.net>
parents: 47
diff changeset
373 self.error('===> Debug: no bridge found for "'+event.target().lower()+' at '+connection.server+'"', debug=True)
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
374 return
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
375 for bridge in bridges:
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
376 bridge.addParticipant('irc', nickname)
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
377 return
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
378
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
379
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
380 # From here the event is shown
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
381 self.error(event_str, debug=True)
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
382
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
383 if event.eventtype() == 'disconnect':
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
384 # TODO: lock self.bridges for thread safety
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
385 for bridge in self.bridges:
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
386 try:
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
387 bridge.getParticipant(connection.get_nickname())
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
388 if bridge.mode == 'normal':
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
389 bridge.switchFromNormalToLimitedMode()
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
390 except NoSuchParticipantException:
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
391 pass
5
cb0daec4b778 Added support for IRC "nick" event, fixed participant.changeNickname(), fixed handling of IRC "namreply" event, removed muc._check() because waiting does not solve the problem if it is blocking incoming messages handling
Charly COSTE <changaco@changaco.net>
parents: 3
diff changeset
392 return
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
393 elif event.eventtype() == 'nicknameinuse':
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
394 connection._call_nick_callbacks('nicknameinuse')
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
395 return
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
396 elif event.eventtype() == 'erroneusnickname':
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
397 connection._call_nick_callbacks('erroneusnickname')
5
cb0daec4b778 Added support for IRC "nick" event, fixed participant.changeNickname(), fixed handling of IRC "namreply" event, removed muc._check() because waiting does not solve the problem if it is blocking incoming messages handling
Charly COSTE <changaco@changaco.net>
parents: 3
diff changeset
398 return
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
399
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
400
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
401 # Unhandled events
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
402 self.error('=> Debug: event not handled', debug=True)
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
403
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
404
21
801160b4136f Introduced a bridge's "say" attribute to offer more flexibility in what the bot says.
Charly COSTE <changaco@changaco.net>
parents: 20
diff changeset
405 def new_bridge(self, xmpp_room, irc_room, irc_server, mode, say_level, irc_port=6667):
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
406 """Create a bridge between xmpp_room and irc_room at irc_server."""
21
801160b4136f Introduced a bridge's "say" attribute to offer more flexibility in what the bot says.
Charly COSTE <changaco@changaco.net>
parents: 20
diff changeset
407 b = bridge(self, xmpp_room, irc_room, irc_server, mode, say_level, irc_port=irc_port)
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
408 self.bridges.append(b)
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
409 return b
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
410
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
411
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
412 def getBridges(self, irc_room=None, irc_server=None, xmpp_room_jid=None):
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
413 bridges = [b for b in self.bridges]
32
8aa261545662 Implemented "/me" in the IRC->XMPP way (ie "action" event is now handled). Re-written bot.getBridges because the old one didn't always work and was slow.
Charly COSTE <changaco@changaco.net>
parents: 30
diff changeset
414 for bridge in [b for b in bridges]:
8aa261545662 Implemented "/me" in the IRC->XMPP way (ie "action" event is now handled). Re-written bot.getBridges because the old one didn't always work and was slow.
Charly COSTE <changaco@changaco.net>
parents: 30
diff changeset
415 if irc_room != None and bridge.irc_room != irc_room:
8aa261545662 Implemented "/me" in the IRC->XMPP way (ie "action" event is now handled). Re-written bot.getBridges because the old one didn't always work and was slow.
Charly COSTE <changaco@changaco.net>
parents: 30
diff changeset
416 bridges.remove(bridge)
8aa261545662 Implemented "/me" in the IRC->XMPP way (ie "action" event is now handled). Re-written bot.getBridges because the old one didn't always work and was slow.
Charly COSTE <changaco@changaco.net>
parents: 30
diff changeset
417 continue
8aa261545662 Implemented "/me" in the IRC->XMPP way (ie "action" event is now handled). Re-written bot.getBridges because the old one didn't always work and was slow.
Charly COSTE <changaco@changaco.net>
parents: 30
diff changeset
418 if irc_server != None and bridge.irc_server != irc_server:
8aa261545662 Implemented "/me" in the IRC->XMPP way (ie "action" event is now handled). Re-written bot.getBridges because the old one didn't always work and was slow.
Charly COSTE <changaco@changaco.net>
parents: 30
diff changeset
419 bridges.remove(bridge)
8aa261545662 Implemented "/me" in the IRC->XMPP way (ie "action" event is now handled). Re-written bot.getBridges because the old one didn't always work and was slow.
Charly COSTE <changaco@changaco.net>
parents: 30
diff changeset
420 continue
8aa261545662 Implemented "/me" in the IRC->XMPP way (ie "action" event is now handled). Re-written bot.getBridges because the old one didn't always work and was slow.
Charly COSTE <changaco@changaco.net>
parents: 30
diff changeset
421 if xmpp_room_jid != None and bridge.xmpp_room.room_jid != xmpp_room_jid:
8aa261545662 Implemented "/me" in the IRC->XMPP way (ie "action" event is now handled). Re-written bot.getBridges because the old one didn't always work and was slow.
Charly COSTE <changaco@changaco.net>
parents: 30
diff changeset
422 bridges.remove(bridge)
8aa261545662 Implemented "/me" in the IRC->XMPP way (ie "action" event is now handled). Re-written bot.getBridges because the old one didn't always work and was slow.
Charly COSTE <changaco@changaco.net>
parents: 30
diff changeset
423 continue
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
424 return bridges
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
425
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
426
22
e2bd4de698e5 Solved an XMPP resource conflict that would have happened when someone on IRC changed its nickname and later its old nickname would be used again. In other words, the bot no longer uses nicknames as XMPP resources.
Charly COSTE <changaco@changaco.net>
parents: 21
diff changeset
427 def get_xmpp_connection(self, nickname):
e2bd4de698e5 Solved an XMPP resource conflict that would have happened when someone on IRC changed its nickname and later its old nickname would be used again. In other words, the bot no longer uses nicknames as XMPP resources.
Charly COSTE <changaco@changaco.net>
parents: 21
diff changeset
428 if self.xmpp_connections.has_key(nickname):
e2bd4de698e5 Solved an XMPP resource conflict that would have happened when someone on IRC changed its nickname and later its old nickname would be used again. In other words, the bot no longer uses nicknames as XMPP resources.
Charly COSTE <changaco@changaco.net>
parents: 21
diff changeset
429 c = self.xmpp_connections[nickname]
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
430 c.used_by += 1
22
e2bd4de698e5 Solved an XMPP resource conflict that would have happened when someone on IRC changed its nickname and later its old nickname would be used again. In other words, the bot no longer uses nicknames as XMPP resources.
Charly COSTE <changaco@changaco.net>
parents: 21
diff changeset
431 self.error('===> Debug: using existing XMPP connection for "'+nickname+'", now used by '+str(c.used_by)+' bridges', debug=True)
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
432 return c
22
e2bd4de698e5 Solved an XMPP resource conflict that would have happened when someone on IRC changed its nickname and later its old nickname would be used again. In other words, the bot no longer uses nicknames as XMPP resources.
Charly COSTE <changaco@changaco.net>
parents: 21
diff changeset
433 self.error('===> Debug: opening new XMPP connection for "'+nickname+'"', debug=True)
e2bd4de698e5 Solved an XMPP resource conflict that would have happened when someone on IRC changed its nickname and later its old nickname would be used again. In other words, the bot no longer uses nicknames as XMPP resources.
Charly COSTE <changaco@changaco.net>
parents: 21
diff changeset
434 c = xmpp.client.Client(self.bare_jid.getDomain(), debug=[])
35
ebf516b2e5c9 Switched from Lock() to RLock().
Charly COSTE <changaco@changaco.net>
parents: 34
diff changeset
435 c.lock = threading.RLock()
24
4e1f27ea527b First hack at locks for thread safety. Some other minor changes.
Charly COSTE <changaco@changaco.net>
parents: 23
diff changeset
436 c.lock.acquire()
22
e2bd4de698e5 Solved an XMPP resource conflict that would have happened when someone on IRC changed its nickname and later its old nickname would be used again. In other words, the bot no longer uses nicknames as XMPP resources.
Charly COSTE <changaco@changaco.net>
parents: 21
diff changeset
437 self.xmpp_connections[nickname] = c
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
438 c.used_by = 1
22
e2bd4de698e5 Solved an XMPP resource conflict that would have happened when someone on IRC changed its nickname and later its old nickname would be used again. In other words, the bot no longer uses nicknames as XMPP resources.
Charly COSTE <changaco@changaco.net>
parents: 21
diff changeset
439 c.nickname = nickname
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
440 c.connect()
22
e2bd4de698e5 Solved an XMPP resource conflict that would have happened when someone on IRC changed its nickname and later its old nickname would be used again. In other words, the bot no longer uses nicknames as XMPP resources.
Charly COSTE <changaco@changaco.net>
parents: 21
diff changeset
441 c.auth(self.bare_jid.getNode(), self.password)
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
442 c.RegisterHandler('presence', self._xmpp_presence_handler)
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
443 c.RegisterHandler('iq', self._xmpp_iq_handler)
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
444 c.RegisterHandler('message', self._xmpp_message_handler)
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
445 c.sendInitPresence()
24
4e1f27ea527b First hack at locks for thread safety. Some other minor changes.
Charly COSTE <changaco@changaco.net>
parents: 23
diff changeset
446 c.lock.release()
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
447 return c
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
448
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
449
22
e2bd4de698e5 Solved an XMPP resource conflict that would have happened when someone on IRC changed its nickname and later its old nickname would be used again. In other words, the bot no longer uses nicknames as XMPP resources.
Charly COSTE <changaco@changaco.net>
parents: 21
diff changeset
450 def close_xmpp_connection(self, nickname):
29
a694ffe6a973 Fixed nickname change.
Charly COSTE <changaco@changaco.net>
parents: 27
diff changeset
451 if not self.xmpp_connections.has_key(nickname):
a694ffe6a973 Fixed nickname change.
Charly COSTE <changaco@changaco.net>
parents: 27
diff changeset
452 return
37
7e500d4064fb Cosmetics.
Charly COSTE <changaco@changaco.net>
parents: 35
diff changeset
453 c = self.xmpp_connections[nickname]
42
b8c9ddf320f8 Thread safety for bot.close_xmpp_connection().
Charly COSTE <changaco@changaco.net>
parents: 41
diff changeset
454 c.lock.acquire()
37
7e500d4064fb Cosmetics.
Charly COSTE <changaco@changaco.net>
parents: 35
diff changeset
455 c.used_by -= 1
7e500d4064fb Cosmetics.
Charly COSTE <changaco@changaco.net>
parents: 35
diff changeset
456 if c.used_by < 1:
22
e2bd4de698e5 Solved an XMPP resource conflict that would have happened when someone on IRC changed its nickname and later its old nickname would be used again. In other words, the bot no longer uses nicknames as XMPP resources.
Charly COSTE <changaco@changaco.net>
parents: 21
diff changeset
457 self.error('===> Debug: closing XMPP connection for "'+nickname+'"', debug=True)
37
7e500d4064fb Cosmetics.
Charly COSTE <changaco@changaco.net>
parents: 35
diff changeset
458 self.xmpp_connections.pop(nickname)
7e500d4064fb Cosmetics.
Charly COSTE <changaco@changaco.net>
parents: 35
diff changeset
459 del c
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
460 else:
42
b8c9ddf320f8 Thread safety for bot.close_xmpp_connection().
Charly COSTE <changaco@changaco.net>
parents: 41
diff changeset
461 c.lock.release()
37
7e500d4064fb Cosmetics.
Charly COSTE <changaco@changaco.net>
parents: 35
diff changeset
462 self.error('===> Debug: XMPP connection for "'+nickname+'" is now used by '+str(c.used_by)+' bridges', debug=True)
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
463
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
464
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
465 def removeBridge(self, bridge):
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
466 self.bridges.remove(bridge)
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
467 del bridge
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
468
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
469
18
3cdf7bb580da Fixed bot.respond(), boosted XMPP thread to lower latency, fixed mode notice.
Charly COSTE <changaco@changaco.net>
parents: 17
diff changeset
470 def respond(self, message, participant=None):
3cdf7bb580da Fixed bot.respond(), boosted XMPP thread to lower latency, fixed mode notice.
Charly COSTE <changaco@changaco.net>
parents: 17
diff changeset
471 ret = ''
11
79b0a7f48a3e Introduced the command mechanism and fixed a bug
Charly COSTE <changaco@changaco.net>
parents: 10
diff changeset
472 if message.strip() == '!xmpp_participants':
18
3cdf7bb580da Fixed bot.respond(), boosted XMPP thread to lower latency, fixed mode notice.
Charly COSTE <changaco@changaco.net>
parents: 17
diff changeset
473 if participant == None:
3cdf7bb580da Fixed bot.respond(), boosted XMPP thread to lower latency, fixed mode notice.
Charly COSTE <changaco@changaco.net>
parents: 17
diff changeset
474 for bridge in self.bridges:
3cdf7bb580da Fixed bot.respond(), boosted XMPP thread to lower latency, fixed mode notice.
Charly COSTE <changaco@changaco.net>
parents: 17
diff changeset
475 xmpp_participants_nicknames = bridge.get_participants_nicknames_list(protocols=['xmpp'])
3cdf7bb580da Fixed bot.respond(), boosted XMPP thread to lower latency, fixed mode notice.
Charly COSTE <changaco@changaco.net>
parents: 17
diff changeset
476 ret += '\nparticipants on '+bridge.xmpp_room.room_jid+': '+' '.join(xmpp_participants_nicknames)
3cdf7bb580da Fixed bot.respond(), boosted XMPP thread to lower latency, fixed mode notice.
Charly COSTE <changaco@changaco.net>
parents: 17
diff changeset
477 return ret
3cdf7bb580da Fixed bot.respond(), boosted XMPP thread to lower latency, fixed mode notice.
Charly COSTE <changaco@changaco.net>
parents: 17
diff changeset
478 else:
3cdf7bb580da Fixed bot.respond(), boosted XMPP thread to lower latency, fixed mode notice.
Charly COSTE <changaco@changaco.net>
parents: 17
diff changeset
479 xmpp_participants_nicknames = participant.bridge.get_participants_nicknames_list(protocols=['xmpp'])
3cdf7bb580da Fixed bot.respond(), boosted XMPP thread to lower latency, fixed mode notice.
Charly COSTE <changaco@changaco.net>
parents: 17
diff changeset
480 return 'participants on '+participant.bridge.xmpp_room.room_jid+': '+' '.join(xmpp_participants_nicknames)
3cdf7bb580da Fixed bot.respond(), boosted XMPP thread to lower latency, fixed mode notice.
Charly COSTE <changaco@changaco.net>
parents: 17
diff changeset
481 elif message.strip() == '!irc_participants':
3cdf7bb580da Fixed bot.respond(), boosted XMPP thread to lower latency, fixed mode notice.
Charly COSTE <changaco@changaco.net>
parents: 17
diff changeset
482 if participant == None:
3cdf7bb580da Fixed bot.respond(), boosted XMPP thread to lower latency, fixed mode notice.
Charly COSTE <changaco@changaco.net>
parents: 17
diff changeset
483 for bridge in self.bridges:
3cdf7bb580da Fixed bot.respond(), boosted XMPP thread to lower latency, fixed mode notice.
Charly COSTE <changaco@changaco.net>
parents: 17
diff changeset
484 irc_participants_nicknames = bridge.get_participants_nicknames_list(protocols=['irc'])
3cdf7bb580da Fixed bot.respond(), boosted XMPP thread to lower latency, fixed mode notice.
Charly COSTE <changaco@changaco.net>
parents: 17
diff changeset
485 ret += '\nparticipants on '+bridge.irc_room+' at '+bridge.irc_server+': '+' '.join(irc_participants_nicknames)
3cdf7bb580da Fixed bot.respond(), boosted XMPP thread to lower latency, fixed mode notice.
Charly COSTE <changaco@changaco.net>
parents: 17
diff changeset
486 return ret
3cdf7bb580da Fixed bot.respond(), boosted XMPP thread to lower latency, fixed mode notice.
Charly COSTE <changaco@changaco.net>
parents: 17
diff changeset
487 else:
3cdf7bb580da Fixed bot.respond(), boosted XMPP thread to lower latency, fixed mode notice.
Charly COSTE <changaco@changaco.net>
parents: 17
diff changeset
488 irc_participants_nicknames = participant.bridge.get_participants_nicknames_list(protocols=['irc'])
3cdf7bb580da Fixed bot.respond(), boosted XMPP thread to lower latency, fixed mode notice.
Charly COSTE <changaco@changaco.net>
parents: 17
diff changeset
489 return 'participants on '+participant.bridge.irc_room+' at '+participant.bridge.irc_server+': '+' '.join(irc_participants_nicknames)
11
79b0a7f48a3e Introduced the command mechanism and fixed a bug
Charly COSTE <changaco@changaco.net>
parents: 10
diff changeset
490 else:
79b0a7f48a3e Introduced the command mechanism and fixed a bug
Charly COSTE <changaco@changaco.net>
parents: 10
diff changeset
491 return 'commands: '+' '.join(self.commands)
79b0a7f48a3e Introduced the command mechanism and fixed a bug
Charly COSTE <changaco@changaco.net>
parents: 10
diff changeset
492
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
493
0
4c842d23d4ce Initial commit, version 0.1
Charly COSTE <changaco@changaco.net>
parents:
diff changeset
494 def __del__(self):
17
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
495 for bridge in self.bridges:
32a35f7eff70 Rewrote/modified many things, multiple bridges should now work and are preferred over multiple bots.
Charly COSTE <changaco@changaco.net>
parents: 14
diff changeset
496 self.removeBridge(bridge)