diff options
author | lassulus <lassulus@googlemail.com> | 2014-03-16 20:14:17 +0100 |
---|---|---|
committer | lassulus <lassulus@googlemail.com> | 2014-03-16 20:14:17 +0100 |
commit | 2dc26fdb5d5b0fa55a4b6ad656f373a4453a47dc (patch) | |
tree | f3bb6588e730bf8cd6fa0af14c281201618be2b7 | |
parent | e90b6909dd62e95d58f434a4352ef2163e3f62c6 (diff) |
newsbot.py: better space finding
-rw-r--r-- | news/newsbot.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/news/newsbot.py b/news/newsbot.py index 8834851d..0161f818 100644 --- a/news/newsbot.py +++ b/news/newsbot.py @@ -203,14 +203,14 @@ class RssBot(asybot): def send_msg(self, target, string): if self.connected: for line in string.split('\n'): - if len(line) < 450: - self.PRIVMSG(target, line) - else: - space = 0 - for x in range(math.ceil(len(line)/400)): - oldspace = space - space = line.find(" ", (x+1)*400, (x+1)*400+50) - self.PRIVMSG(target, line[oldspace:space]) + while len(line)>0: + if len(line) < 450: + self.PRIVMSG(target, line) + line = '' + else: + space = line.rfind(" ", 1, 450) + self.PRIVMSG(target, line[:space]) + line=line[space:] else: self.reconnect() while not self.connected: |