attempt to give up if we're doing too many splits

This commit is contained in:
Brian S. Stephan 2010-09-30 19:38:21 -05:00
parent 827d1b2c86
commit 466eb6eff1
1 changed files with 6 additions and 0 deletions

View File

@ -45,12 +45,18 @@ class DrBotServerConnection(irclib.ServerConnection):
splitspace = space - (len(splitter) + 1)
if len(text) > space:
times = 1
while len(text) > splitspace:
splitpos = text.rfind(' ', 0, splitspace)
splittext = text[0:splitpos] + ' ' + splitter
text = splitter + ' ' + text[splitpos+1:]
self.send_raw("PRIVMSG %s :%s" % (target, unicode(splittext).encode('utf-8')))
times = times + 1
if times >= 4:
return
# done splitting
try:
text = unicode(text).encode('utf-8')