diff -r 60ead38a61af -r da291d9426ea irc.py --- a/irc.py Mon Nov 17 22:25:18 2014 +0200 +++ b/irc.py Sat Nov 29 05:04:07 2014 +0200 @@ -120,7 +120,7 @@ self.write ("JOIN %s %s" % (channel.get_value ('name'), channel.get_value ('password', default=''))) umode = self.cfg.get_value ('umode', '') - + if umode != '': self.write ('MODE %s %s' % (self.mynick, self.cfg.get_value ('umode', ''))) elif words[1] == "PRIVMSG": @@ -151,17 +151,17 @@ def handle_privmsg (self, line): rex = re.compile (r'^:([^!]+)!([^@]+)@([^ ]+) PRIVMSG ([^ ]+) :(.+)$') match = rex.match (line) - + if not match: broadcast ("Recieved bad PRIVMSG: %s" % line) - + sender = match.group (1) user = match.group (2) host = match.group (3) channel = match.group (4) message = match.group (5) replyto = channel if channel != self.mynick else sender - + # Check for command. if len(message) >= 2 and message[0] == self.commandprefix and message[1] != self.commandprefix: stuff = message[1:].split(' ') @@ -169,20 +169,20 @@ args = stuff[1:] self.handle_command (sender, user, host, replyto, command, args, message) return - + Bt.process_message (self, line, replyto) def add_irc_channel (self, channame): for channel in self.channels: if channel.get_value ('name').upper() == channame.upper(): return - + channel = self.cfg.append_nodelist ('channels') channel.set_value ('name', channame) self.channels = self.cfg.get_nodelist ('channels') self.write ('JOIN ' + channame) self.cfg.save() - + def remove_irc_channel (self, channame): for channel in self.channels: if channel.get_value ('name') == channame: @@ -190,29 +190,29 @@ break else: return - + self.write ('PART ' + channame) self.cfg.save() - + def handle_command (self, sender, ident, host, replyto, command, args, message): kvargs = {'sender': sender, 'ident': ident, 'host': host, 'replyto': replyto, 'cmdname': command, 'message': message} - + try: result = ModuleCore.call_command (self, **kvargs) - + if result: return except ModuleCore.CommandError as e: lines = str (e).split ('\n') self.privmsg (replyto, 'error: %s' % lines[0]) - + for line in lines[1:]: self.privmsg (replyto, ' ' + line) return - + def handle_error(self): raise RestartError (traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback)) - + def restart(self): raise RestartError('') @@ -232,4 +232,4 @@ self.close_connection ('Caught exception') def keyboardinterrupt (self): - self.close_connection ('KeyboardInterrupt') \ No newline at end of file + self.close_connection ('KeyboardInterrupt')