forked from nortti/tea_cah
Do line wrapping for long messages
This commit is contained in:
parent
6541323fa6
commit
55e27fd94e
1 changed files with 32 additions and 2 deletions
34
botcmd.py
34
botcmd.py
|
@ -19,10 +19,40 @@ class GameLoop(threading.Thread):
|
||||||
threading.Thread.__init__(self)
|
threading.Thread.__init__(self)
|
||||||
|
|
||||||
def send(self, message):
|
def send(self, message):
|
||||||
self.irc.bot_response(self.irc_chan, message)
|
message_parts = message.encode().split(b' ')
|
||||||
|
|
||||||
|
line = []
|
||||||
|
line_len = 0
|
||||||
|
for part in message_parts:
|
||||||
|
if len(part) + line_len > 440:
|
||||||
|
self.irc.bot_response(self.irc_chan, b' '.join(line))
|
||||||
|
line = []
|
||||||
|
line_len = 0
|
||||||
|
|
||||||
|
line.append(part)
|
||||||
|
line_len += len(part) + 1
|
||||||
|
|
||||||
|
if len(line) > 0:
|
||||||
|
self.irc.bot_response(self.irc_chan, b' '.join(line))
|
||||||
|
|
||||||
def notice(self, recipient, message):
|
def notice(self, recipient, message):
|
||||||
self.irc.send_raw(b'NOTICE %s :%s' % (recipient.encode(), message.encode()))
|
recipient = recipient.encode()
|
||||||
|
|
||||||
|
message_parts = message.encode().split(b' ')
|
||||||
|
|
||||||
|
line = []
|
||||||
|
line_len = 0
|
||||||
|
for part in message_parts:
|
||||||
|
if len(part) + line_len > 440:
|
||||||
|
self.irc.send_raw(b'NOTICE %s :%s' % (recipient, b' '.join(line)))
|
||||||
|
line = []
|
||||||
|
line_len = 0
|
||||||
|
|
||||||
|
line.append(part)
|
||||||
|
line_len += len(part) + 1
|
||||||
|
|
||||||
|
if len(line) > 0:
|
||||||
|
self.irc.send_raw(b'NOTICE %s :%s' % (recipient, b' '.join(line)))
|
||||||
|
|
||||||
def get_event(self):
|
def get_event(self):
|
||||||
event = self.chan.recv()
|
event = self.chan.recv()
|
||||||
|
|
Loading…
Reference in a new issue