Mercurial > xib
comparison bridge.py @ 269:abef394fded5
fix in Bridge, don't change mode to None otherwise restart cannot work
Signed-off-by: Charly COSTE <changaco@changaco.net>
author | Charly COSTE <changaco@changaco.net> |
---|---|
date | Tue, 23 Mar 2010 00:53:01 +0100 |
parents | 7602a0898d19 |
children | 7640a3feddf5 |
comparison
equal
deleted
inserted
replaced
268:7602a0898d19 | 269:abef394fded5 |
---|---|
48 self.say_level = say_level | 48 self.say_level = say_level |
49 self.participants = [] | 49 self.participants = [] |
50 if mode not in self.__class__.modes: | 50 if mode not in self.__class__.modes: |
51 raise Exception('[Error] "'+mode+'" is not a correct value for a bridge\'s "mode" attribute') | 51 raise Exception('[Error] "'+mode+'" is not a correct value for a bridge\'s "mode" attribute') |
52 self.mode = mode | 52 self.mode = mode |
53 self.stopped = False | |
53 | 54 |
54 self.lock = threading.RLock() | 55 self.lock = threading.RLock() |
55 | 56 |
56 self.init2() | 57 self.init2() |
57 | 58 |
75 self.stop(message='Failed to connect to the IRC chan, stopping bridge', log=False) | 76 self.stop(message='Failed to connect to the IRC chan, stopping bridge', log=False) |
76 | 77 |
77 | 78 |
78 def _irc_nick_callback(self, error, arguments=None): | 79 def _irc_nick_callback(self, error, arguments=None): |
79 if not error: | 80 if not error: |
80 if not self.mode: | 81 if self.stopped: |
81 return | 82 return |
82 self.irc_connection.join(self.irc_room, callback=self._irc_join_callback) | 83 self.irc_connection.join(self.irc_room, callback=self._irc_join_callback) |
83 | 84 |
84 else: | 85 else: |
85 self.mode = None | 86 self.stopped = True |
86 self.say(say_levels.error, 'failed to connect to the IRC chan, leaving ...', on_irc=False) | 87 self.say(say_levels.error, 'failed to connect to the IRC chan, leaving ...', on_irc=False) |
87 if error in ['nicknameinuse', 'nickcollision']: | 88 if error in ['nicknameinuse', 'nickcollision']: |
88 reason = '"'+self.bot.nickname+'" is already used or reserved on the IRC server' | 89 reason = '"'+self.bot.nickname+'" is already used or reserved on the IRC server' |
89 elif error == 'erroneusnickname': | 90 elif error == 'erroneusnickname': |
90 reason = '"'+self.bot.nickname+'" got "erroneusnickname"' | 91 reason = '"'+self.bot.nickname+'" got "erroneusnickname"' |
115 | 116 |
116 def _xmpp_join_callback(self, errors): | 117 def _xmpp_join_callback(self, errors): |
117 """Called by muc._xmpp_presence_handler""" | 118 """Called by muc._xmpp_presence_handler""" |
118 if len(errors) == 0: | 119 if len(errors) == 0: |
119 self.reconnecting = False | 120 self.reconnecting = False |
120 if not self.mode: | 121 if self.stopped: |
121 return | 122 return |
122 self.bot.error(3, 'succesfully connected on XMPP side of bridge "'+str(self)+'"', debug=True) | 123 self.bot.error(3, 'succesfully connected on XMPP side of bridge "'+str(self)+'"', debug=True) |
123 self.say(say_levels.notice, 'bridge "'+str(self)+'" is running in '+self.mode+' mode', on_irc=False) | 124 self.say(say_levels.notice, 'bridge "'+str(self)+'" is running in '+self.mode+' mode', on_irc=False) |
124 else: | 125 else: |
125 self.mode = None | 126 self.stopped = True |
126 self.say(say_levels.error, 'failed to connect to the XMPP room, leaving ...', on_xmpp=False) | 127 self.say(say_levels.error, 'failed to connect to the XMPP room, leaving ...', on_xmpp=False) |
127 for error in errors: | 128 for error in errors: |
128 try: | 129 try: |
129 raise error | 130 raise error |
130 except xmpp.muc.RemoteServerNotFound: | 131 except xmpp.muc.RemoteServerNotFound: |