diff options
author | EUcancER <root@euer.krebsco.de> | 2012-05-02 14:41:50 +0200 |
---|---|---|
committer | EUcancER <root@euer.krebsco.de> | 2012-05-02 14:41:50 +0200 |
commit | 090872619bd0811921a0c6c88b2b0a0620de3459 (patch) | |
tree | a7a238817d911f1725cfe812e71a5cbaae721530 /IRC | |
parent | d91d10d3426d877bd901549b93ac0dd0e6cf7264 (diff) |
add line wrapping
as it seems to lose characters between 400 and 500 characters...
Diffstat (limited to 'IRC')
-rwxr-xr-x | IRC/asybot.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/IRC/asybot.py b/IRC/asybot.py index 6edc13b..bf0c396 100755 --- a/IRC/asybot.py +++ b/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 + '') |