From 4ea18af3e838f31afb2e5bb794652dde0a4ef127 Mon Sep 17 00:00:00 2001 From: EUcancER Date: Wed, 2 May 2012 14:41:50 +0200 Subject: add line wrapping as it seems to lose characters between 400 and 500 characters... --- Reaktor/IRC/asybot.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'Reaktor/IRC') diff --git a/Reaktor/IRC/asybot.py b/Reaktor/IRC/asybot.py index 6edc13ba..bf0c396f 100755 --- a/Reaktor/IRC/asybot.py +++ b/Reaktor/IRC/asybot.py @@ -16,7 +16,7 @@ import shlex from time import sleep from sys import exit from re import split, search - +from textwrap import TextWrapper import logging,logging.handlers log = logging.getLogger('asybot') hdlr = logging.handlers.SysLogHandler(facility=logging.handlers.SysLogHandler.LOG_DAEMON) @@ -39,6 +39,7 @@ class asybot(asychat): self.set_terminator('\r\n') self.create_socket(AF_INET, SOCK_STREAM) self.connect((self.server, self.port)) + self.wrapper = TextWrapper(subsequent_indent=" ",width=400) # When we don't receive data for alarm_timeout seconds then issue a # PING every hammer_interval seconds until kill_timeout seconds have @@ -107,9 +108,10 @@ class asybot(asychat): def on_privmsg(self, prefix, command, params, rest): def PRIVMSG(text): - msg = 'PRIVMSG %s :%s' % (','.join(params), text) - self.push(msg) - sleep(1) + for line in self.wrapper.wrap(text): + msg = 'PRIVMSG %s :%s' % (','.join(params), line) + self.push(msg) + sleep(1) def ME(text): PRIVMSG('ACTION ' + text + '') -- cgit v1.2.3