comparison bot.py @ 14:1a1f2a0d35c7

Fixed bug that prevented the bot from connecting to freenode and all other servers that don't send "umode" Signed-off-by: Charly COSTE <changaco@changaco.net>
author Charly COSTE <changaco@changaco.net>
date Mon, 17 Aug 2009 13:20:25 +0200
parents 79b0a7f48a3e
children 32a35f7eff70
comparison
equal deleted inserted replaced
13:a9077fa9cac9 14:1a1f2a0d35c7
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details. 12 # GNU General Public License for more details.
13 # 13 #
14 # You should have received a copy of the GNU General Public License 14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>. 15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17
18 # *** CONTRIBUTORS ***
19 # Contributor: Changaco <changaco@changaco.net>
20
21
22 # *** Changelog ***
23 # 0.1: First release
24 16
25 17
26 # *** Versioning *** 18 # *** Versioning ***
27 # Major will pass to 1 when xib will be considered fault-tolerant 19 # Major will pass to 1 when xib will be considered fault-tolerant
28 # After that major will only be changed if the new version is not retro-compatible (e.g. requires changes in config file) 20 # After that major will only be changed if the new version is not retro-compatible (e.g. requires changes in config file)
204 if 'all' in event.eventtype(): 196 if 'all' in event.eventtype():
205 return 197 return
206 if 'motd' in event.eventtype(): 198 if 'motd' in event.eventtype():
207 self.error('=> Debug: ignoring event containing "motd" in the eventtype ('+event.eventtype()+')', debug=True) 199 self.error('=> Debug: ignoring event containing "motd" in the eventtype ('+event.eventtype()+')', debug=True)
208 return 200 return
209 if event.eventtype() in ['pong', 'welcome', 'yourhost', 'created', 'myinfo', 'featurelist', 'luserclient', 'luserop', 'luserchannels', 'luserme', 'n_local', 'n_global', 'endofnames', 'luserunknown']: 201 if event.eventtype() in ['pong', 'privnotice']:
210 self.error('=> Debug: ignoring '+event.eventtype(), debug=True) 202 self.error('=> Debug: ignoring '+event.eventtype(), debug=True)
211 return 203 return
212 if event.eventtype() == 'pubmsg' and connection.get_nickname() != connection.bridge.irc_connection.get_nickname(): 204 if event.eventtype() == 'pubmsg' and connection.get_nickname() != connection.bridge.irc_connection.get_nickname():
213 self.error('=> Debug: ignoring IRC pubmsg not received on bridge connection', debug=True) 205 self.error('=> Debug: ignoring IRC pubmsg not received on bridge connection', debug=True)
214 return 206 return
215 if event.eventtype() == 'ping': 207 if event.eventtype() == 'ping':
216 connection.pong(connection.get_server_name()) 208 connection.pong(connection.get_server_name())
209 return
210 if event.eventtype() in ['umode', 'welcome', 'yourhost', 'created', 'myinfo', 'featurelist', 'luserclient', 'luserop', 'luserchannels', 'luserme', 'n_local', 'n_global', 'endofnames', 'luserunknown', 'luserconns']:
211 if connection.really_connected == False:
212 connection.really_connected = True
213 self.error('===> Debug: now really connected', debug=True)
214 if connection.nick_callback:
215 connection.nick_callback(None)
216 else:
217 self.error('=> Debug: no nick callback for "'+str(event.target())+'"', debug=True)
218 self.error('connection.nick_callback='+str(connection.nick_callback), debug=True)
219 self.error('=> Debug: ignoring '+event.eventtype(), debug=True)
217 return 220 return
218 self.error('==> Debug: Received IRC event.', debug=True) 221 self.error('==> Debug: Received IRC event.', debug=True)
219 self.error('server='+connection.get_server_name(), debug=True) 222 self.error('server='+connection.get_server_name(), debug=True)
220 self.error('eventtype='+event.eventtype(), debug=True) 223 self.error('eventtype='+event.eventtype(), debug=True)
221 self.error('source='+str(event.source()), debug=True) 224 self.error('source='+str(event.source()), debug=True)
241 if connection.nick_callback: 244 if connection.nick_callback:
242 connection.nick_callback('erroneusnickname') 245 connection.nick_callback('erroneusnickname')
243 else: 246 else:
244 self.error('=> Debug: no nick callback for "'+str(event.target())+'"', debug=True) 247 self.error('=> Debug: no nick callback for "'+str(event.target())+'"', debug=True)
245 return 248 return
246 elif event.eventtype() == 'umode':
247 if connection.nick_callback:
248 connection.nick_callback(None)
249 else:
250 self.error('=> Debug: no nick callback for "'+str(event.target())+'"', debug=True)
251 self.error('connection.nick_callback='+str(connection.nick_callback), debug=True)
252 return
253 elif event.eventtype() == 'namreply': 249 elif event.eventtype() == 'namreply':
254 for nickname in re.split('(?:^[@\+]?|(?: [@\+]?)*)', event.arguments()[2].strip()): 250 for nickname in re.split('(?:^[@\+]?|(?: [@\+]?)*)', event.arguments()[2].strip()):
255 if nickname == '': 251 if nickname == '':
256 continue 252 continue
257 try: 253 try: