summaryrefslogtreecommitdiffstats
path: root/Reaktor/IRC
diff options
context:
space:
mode:
authormakefu <root@pigstarter.de>2014-06-18 10:28:55 +0200
committermakefu <root@pigstarter.de>2014-06-18 10:28:55 +0200
commit7a308fa339fba0059dc48d525498504de0a4bd00 (patch)
tree81787d706460a077c1417370ca4ac96dea459927 /Reaktor/IRC
parent438a8a9f99e72dc9c8ccda3f657f9338220f4c41 (diff)
make ircasy more robust
Diffstat (limited to 'Reaktor/IRC')
-rw-r--r--Reaktor/IRC/ircasy.py24
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')