Skip to content
This repository has been archived by the owner on Oct 25, 2019. It is now read-only.

Commit

Permalink
Merge pull request #61 from wei2912/upstream-irc
Browse files Browse the repository at this point in the history
modify phenny.say() to split long messages
  • Loading branch information
mutantmonkey committed Feb 11, 2017
2 parents 2dc0b0b + a981cf3 commit f195b7c
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions irc.py
Expand Up @@ -182,6 +182,19 @@ def msg(self, recipient, text):
except UnicodeEncodeError as e:
return

# Split long messages
maxlength = 430
if len(text) > maxlength:
first_message = text[0:maxlength].decode('utf-8','ignore')
line_break = len(first_message)
for i in range(len(first_message)-1,-1,-1):
if first_message[i] == " ":
line_break = i
break
self.msg(recipient, text.decode('utf-8','ignore')[0:line_break])
self.msg(recipient, text.decode('utf-8','ignore')[line_break+1:])
return

# No messages within the last 3 seconds? Go ahead!
# Otherwise, wait so it's been at least 0.8 seconds + penalty
if self.stack:
Expand Down

0 comments on commit f195b7c

Please sign in to comment.