diff options
author | makefu <github@syntax-fehler.de> | 2014-07-08 18:29:19 +0200 |
---|---|---|
committer | makefu <github@syntax-fehler.de> | 2014-07-08 18:29:19 +0200 |
commit | fcf4a7f64463a8190260ab2c138e428f07cadee7 (patch) | |
tree | 938f718f0fffa71493e86ca42afdd0d6596afbcd /Reaktor/IRC/ircasy.py | |
parent | 033ce69ba717841f5c9834f4680cdd6db625ce4b (diff) | |
parent | da8f9b0ea4c73aa90244f8e9eba4d1f5af9af611 (diff) |
Merge branch 'master' of ssh://github.com/krebscode/painload
Diffstat (limited to 'Reaktor/IRC/ircasy.py')
-rw-r--r-- | Reaktor/IRC/ircasy.py | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/Reaktor/IRC/ircasy.py b/Reaktor/IRC/ircasy.py index 9a7f44f3..99fbc324 100644 --- a/Reaktor/IRC/ircasy.py +++ b/Reaktor/IRC/ircasy.py @@ -89,15 +89,22 @@ class asybot(asychat): self.data += data.decode() except Exception as e: print('error decoding message: ' + str(e)); + print('current data: %s' % self.data); + print('received data: %s' % data); + print('trying to decode as latin1') + self.data += data.decode('latin1') def found_terminator(self): self.log.debug('<< %s' % self.data) message = self.data self.data = '' - - _, prefix, command, params, rest, _ = \ - split('^(?::(\S+)\s)?(\S+)((?:\s[^:]\S*)*)(?:\s:(.*))?$', message) + try: + _, prefix, command, params, rest, _ = \ + split('^(?::(\S+)\s)?(\S+)((?:\s[^:]\S*)*)(?:\s:(.*))?$', message) + except Exception as e: + print("cannot split message :(\nmsg: %s"%message) + return params = params.split(' ')[1:] if command == 'PING': @@ -126,10 +133,13 @@ class asybot(asychat): self.reset_alarm() def push(self, message): - self.log.debug('>> %s' % message) - msg = (message + self.myterminator).encode() - self.log.debug('>> %s' % msg) - asychat.push(self, msg) + try: + self.log.debug('>> %s' % message) + msg = (message + self.myterminator).encode() + self.log.debug('>> %s' % msg) + asychat.push(self, msg) + except: + pass def disconnect(self): self.push('QUIT') |