From 2dc26fdb5d5b0fa55a4b6ad656f373a4453a47dc Mon Sep 17 00:00:00 2001 From: lassulus Date: Sun, 16 Mar 2014 20:14:17 +0100 Subject: newsbot.py: better space finding --- news/newsbot.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'news') 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: -- cgit v1.2.3