comparison irclib.py @ 266:c726e8b28318

(irclib) new exception UnknownChannel raised in ServerConnection.part Signed-off-by: Charly COSTE <changaco@changaco.net>
author Charly COSTE <changaco@changaco.net>
date Tue, 23 Mar 2010 00:40:05 +0100
parents 53f4d9aa2b52
children 18c9e8b823bc
comparison
equal deleted inserted replaced
265:48cf498b9620 266:c726e8b28318
409 self.connections.remove(connection) 409 self.connections.remove(connection)
410 if self.fn_to_remove_socket: 410 if self.fn_to_remove_socket:
411 self.fn_to_remove_socket(connection._get_socket()) 411 self.fn_to_remove_socket(connection._get_socket())
412 412
413 413
414 class UnknownChannel(IRCError): pass
415
414 LEFT, LEAVING, NOT_IN, JOINING, JOINED = range(5) 416 LEFT, LEAVING, NOT_IN, JOINING, JOINED = range(5)
415 417
416 class Channel: 418 class Channel:
417 419
418 def __init__(self, connection, channel_name): 420 def __init__(self, connection, channel_name):
1006 1008
1007 def part(self, channels, message=""): 1009 def part(self, channels, message=""):
1008 """Send a PART command.""" 1010 """Send a PART command."""
1009 try: 1011 try:
1010 if isinstance(channels, basestring): 1012 if isinstance(channels, basestring):
1011 self.channels[channels].part(message=message) 1013 try:
1014 self.channels[channels].part(message=message)
1015 except KeyError:
1016 raise UnknownChannel, (channels, message, self)
1012 else: 1017 else:
1013 for channel in channels: 1018 for channel in channels:
1014 self.channels[channel].part(message=message) 1019 try:
1020 self.channels[channel].part(message=message)
1021 except KeyError:
1022 raise UnknownChannel, (channel, message, self)
1015 except ServerNotConnectedError: 1023 except ServerNotConnectedError:
1016 self.disconnect(volontary=True) 1024 self.disconnect(volontary=True)
1017 self.connect() 1025 self.connect()
1018 1026
1019 def pass_(self, password): 1027 def pass_(self, password):