comparison bot.py @ 130:52d94261a406

minor fixes Signed-off-by: Charly COSTE <changaco@changaco.net>
author Charly COSTE <changaco@changaco.net>
date Fri, 15 Jan 2010 16:23:38 +0100
parents b13ca9cefe1c
children e662ff6ecf50
comparison
equal deleted inserted replaced
129:b13ca9cefe1c 130:52d94261a406
867 for i, b in enumerate(self.bridges): 867 for i, b in enumerate(self.bridges):
868 ret += '\n'+str(i+1)+' - '+str(b) 868 ret += '\n'+str(i+1)+' - '+str(b)
869 if args.show_mode: 869 if args.show_mode:
870 ret += ' - mode='+b.mode 870 ret += ' - mode='+b.mode
871 if args.show_say_level: 871 if args.show_say_level:
872 ret += ' - say_level='+bridge._say_levels[b.say_level] 872 ret += ' - say_level='+Bridge._say_levels[b.say_level]
873 if args.show_participants: 873 if args.show_participants:
874 xmpp_participants_nicknames = b.get_participants_nicknames_list(protocols=['xmpp']) 874 xmpp_participants_nicknames = b.get_participants_nicknames_list(protocols=['xmpp'])
875 ret += '\nparticipants on XMPP ('+str(len(xmpp_participants_nicknames))+'): '+' '.join(xmpp_participants_nicknames) 875 ret += '\nparticipants on XMPP ('+str(len(xmpp_participants_nicknames))+'): '+' '.join(xmpp_participants_nicknames)
876 irc_participants_nicknames = b.get_participants_nicknames_list(protocols=['irc']) 876 irc_participants_nicknames = b.get_participants_nicknames_list(protocols=['irc'])
877 ret += '\nparticipants on IRC ('+str(len(irc_participants_nicknames))+'): '+' '.join(irc_participants_nicknames) 877 ret += '\nparticipants on IRC ('+str(len(irc_participants_nicknames))+'): '+' '.join(irc_participants_nicknames)
886 if command == 'add-bridge': 886 if command == 'add-bridge':
887 parser = ArgumentParser(prog=command) 887 parser = ArgumentParser(prog=command)
888 parser.add_argument('xmpp_room_jid', type=str) 888 parser.add_argument('xmpp_room_jid', type=str)
889 parser.add_argument('irc_chan', type=str) 889 parser.add_argument('irc_chan', type=str)
890 parser.add_argument('irc_server', type=str) 890 parser.add_argument('irc_server', type=str)
891 parser.add_argument('--mode', choices=bridge._modes, default='normal') 891 parser.add_argument('--mode', choices=Bridge._modes, default='normal')
892 parser.add_argument('--say-level', choices=bridge._say_levels, default='all') 892 parser.add_argument('--say-level', choices=Bridge._say_levels, default='all')
893 parser.add_argument('--irc-port', type=int, default=6667) 893 parser.add_argument('--irc-port', type=int, default=6667)
894 try: 894 try:
895 args = parser.parse_args(args_array) 895 args = parser.parse_args(args_array)
896 except ArgumentParser.ParseException as e: 896 except ArgumentParser.ParseException as e:
897 return '\n'+e.args[1] 897 return '\n'+e.args[1]
937 raise IndexError 937 raise IndexError
938 b = self.bridges[bn-1] 938 b = self.bridges[bn-1]
939 except IndexError: 939 except IndexError:
940 return 'Invalid bridge number "'+str(bn)+'". '+self.respond('bridges') 940 return 'Invalid bridge number "'+str(bn)+'". '+self.respond('bridges')
941 except ValueError: 941 except ValueError:
942 bridges = self.findBridges(args_array) 942 bridges = self.findBridges(args_array[0])
943 if len(bridges) == 0: 943 if len(bridges) == 0:
944 return 'No bridge found matching "'+' '.join(args_array)+'". '+self.respond('bridges') 944 return 'No bridge found matching "'+args_array[0]+'". '+self.respond('bridges')
945 elif len(bridges) == 1: 945 elif len(bridges) == 1:
946 b = bridges[0] 946 b = bridges[0]
947 elif len(bridges) > 1: 947 elif len(bridges) > 1:
948 return 'More than one bridge matches "'+' '.join(args_array)+'", please be more specific. '+self.respond('bridges') 948 return 'More than one bridge matches "'+args_array[0]+'", please be more specific. '+self.respond('bridges')
949 949
950 if command == 'remove-bridge': 950 if command == 'remove-bridge':
951 self.removeBridge(b) 951 self.removeBridge(b)
952 return 'Bridge removed.' 952 return 'Bridge removed.'
953 elif command == 'restart-bridge': 953 elif command == 'restart-bridge':