comparison bot.py @ 110:ec4fbec1f160

new stop-bridge command Signed-off-by: Charly COSTE <changaco@changaco.net>
author Charly COSTE <changaco@changaco.net>
date Wed, 25 Nov 2009 12:47:38 +0100
parents dff9746aa508
children 59401ac0f47a
comparison
equal deleted inserted replaced
109:970a6b4ac6ce 110:ec4fbec1f160
38 38
39 39
40 class bot(Thread): 40 class bot(Thread):
41 41
42 commands = ['xmpp_participants', 'irc_participants', 'bridges'] 42 commands = ['xmpp_participants', 'irc_participants', 'bridges']
43 admin_commands = ['add-bridge', 'add-xmpp-admin', 'halt', 'remove-bridge', 'restart-bot', 'restart-bridge'] 43 admin_commands = ['add-bridge', 'add-xmpp-admin', 'halt', 'remove-bridge', 'restart-bot', 'restart-bridge', 'stop-bridge']
44 44
45 def __init__(self, jid, password, nickname, admins_jid=[], error_fd=sys.stderr, debug=False): 45 def __init__(self, jid, password, nickname, admins_jid=[], error_fd=sys.stderr, debug=False):
46 Thread.__init__(self) 46 Thread.__init__(self)
47 self.bare_jid = xmpp.protocol.JID(jid=jid) 47 self.bare_jid = xmpp.protocol.JID(jid=jid)
48 self.bare_jid.setResource('') 48 self.bare_jid.setResource('')
896 elif command == 'halt': 896 elif command == 'halt':
897 self.__del__() 897 self.__del__()
898 return 898 return
899 899
900 900
901 elif command in ['remove-bridge', 'restart-bridge']: 901 elif command in ['remove-bridge', 'restart-bridge', 'stop-bridge']:
902 # we need to know which bridge the command is for 902 # we need to know which bridge the command is for
903 if len(args_array) == 0: 903 if len(args_array) == 0:
904 if isinstance(participant_, participant): 904 if isinstance(participant_, participant):
905 b = participant_.bridge 905 b = participant_.bridge
906 else: 906 else:
926 self.removeBridge(b) 926 self.removeBridge(b)
927 return 'Bridge removed.' 927 return 'Bridge removed.'
928 elif command == 'restart-bridge': 928 elif command == 'restart-bridge':
929 b.restart() 929 b.restart()
930 return 'Bridge restarted.' 930 return 'Bridge restarted.'
931 elif command == 'stop-bridge':
932 b.stop()
933 return 'Bridge stopped.'
931 934
932 else: 935 else:
933 ret = 'Error: "'+command+'" is not a valid command.\ncommands: '+' '.join(bot.commands) 936 ret = 'Error: "'+command+'" is not a valid command.\ncommands: '+' '.join(bot.commands)
934 if bot_admin == True: 937 if bot_admin == True:
935 return ret+'\n'+'admin commands: '+' '.join(bot.admin_commands) 938 return ret+'\n'+'admin commands: '+' '.join(bot.admin_commands)