comparison bot.py @ 118:b29fd5696a78

new mode bypass and new method bridge.changeMode Signed-off-by: Charly COSTE <changaco@changaco.net>
author Charly COSTE <changaco@changaco.net>
date Sat, 28 Nov 2009 23:47:11 +0100
parents 0ae0f8836a7a
children ae55fc0d783d
comparison
equal deleted inserted replaced
117:d062efcfbe9d 118:b29fd5696a78
292 real_jid = item.getAttr('jid') 292 real_jid = item.getAttr('jid')
293 293
294 p = bridge.addParticipant('xmpp', resource, real_jid) 294 p = bridge.addParticipant('xmpp', resource, real_jid)
295 295
296 # if we have the real jid check if the participant is a bot admin 296 # if we have the real jid check if the participant is a bot admin
297 if real_jid: 297 if real_jid and isinstance(p, participant):
298 for jid in self.admins_jid: 298 for jid in self.admins_jid:
299 if xmpp.protocol.JID(jid).bareMatch(real_jid): 299 if xmpp.protocol.JID(jid).bareMatch(real_jid):
300 p.bot_admin = True 300 p.bot_admin = True
301 break 301 break
302 302
681 for bridge in self.bridges: 681 for bridge in self.bridges:
682 if connection.server != bridge.irc_server: 682 if connection.server != bridge.irc_server:
683 continue 683 continue
684 try: 684 try:
685 p = bridge.getParticipant(connection.get_nickname()) 685 p = bridge.getParticipant(connection.get_nickname())
686 if bridge.mode == 'normal': 686 if bridge.mode in ['normal', 'bypass']:
687 bridge.switchFromNormalToLimitedMode() 687 bridge.changeMode('limited')
688 else: 688 else:
689 if p.irc_connection.really_connected == True: 689 if p.irc_connection.really_connected == True:
690 p.irc_connection.part(bridge.irc_room, message=message) 690 p.irc_connection.part(bridge.irc_room, message=message)
691 p.irc_connection.used_by -= 1 691 p.irc_connection.used_by -= 1
692 if p.irc_connection.used_by < 1: 692 if p.irc_connection.used_by < 1:
698 698
699 699
700 # Nickname callbacks 700 # Nickname callbacks
701 # TODO: move this into irclib.py 701 # TODO: move this into irclib.py
702 if event.eventtype() == 'nicknameinuse': 702 if event.eventtype() == 'nicknameinuse':
703 connection._call_nick_callbacks('nicknameinuse') 703 connection._call_nick_callbacks('nicknameinuse', arguments=[event])
704 return 704 return
705 if event.eventtype() == 'nickcollision': 705 if event.eventtype() == 'nickcollision':
706 connection._call_nick_callbacks('nickcollision') 706 connection._call_nick_callbacks('nickcollision', arguments=[event])
707 return 707 return
708 if event.eventtype() == 'erroneusnickname': 708 if event.eventtype() == 'erroneusnickname':
709 connection._call_nick_callbacks('erroneusnickname') 709 connection._call_nick_callbacks('erroneusnickname', arguments=[event])
710 return 710 return
711 711
712 712
713 # Unhandled events 713 # Unhandled events
714 self.error('=> Debug: event not handled', debug=True) 714 self.error('=> Debug: event not handled', debug=True)