aboutsummaryrefslogtreecommitdiffstats
path: root/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
commit0f3f819d964cc3e57234efb9de7ea32cad829e98 (patch)
treeb08b050b58b8fd6e3d37f590c173aa67cd89838d /IRC
parentcadaec7a094b3df89ca3442f7b94ce0bd59cab3b (diff)
make ircasy more robust
Diffstat (limited to 'IRC')
-rw-r--r--IRC/ircasy.py24
1 files changed, 17 insertions, 7 deletions
diff --git a/IRC/ircasy.py b/IRC/ircasy.py
index 9a7f44f..99fbc32 100644
--- a/IRC/ircasy.py
+++ b/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')