From c941d2b5e15821f97f9ffde8c5b7c0e02cf9d9db Mon Sep 17 00:00:00 2001 From: Shiz Date: Thu, 30 Jan 2014 10:11:20 +0100 Subject: [PATCH] Add multiline support to client.message()/client.notice(). --- pydle/client.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pydle/client.py b/pydle/client.py index c7dbdbd..0bb263b 100644 --- a/pydle/client.py +++ b/pydle/client.py @@ -374,8 +374,9 @@ def message(self, target, message): # Leeway. chunklen = protocol.MESSAGE_LENGTH_LIMIT - len('{hostmask} PRIVMSG {target} :'.format(hostmask=hostmask, target=target)) - 25 - for msg in _chunkify(message, chunklen): - self.rawmsg('PRIVMSG', target, msg) + for line in message.replace('\r', '').split('\n'): + for chunk in _chunkify(line, chunklen): + self.rawmsg('PRIVMSG', target, chunk) def notice(self, target, message): """ Notice channel or user. """ @@ -386,8 +387,9 @@ def notice(self, target, message): # Leeway. chunklen = protocol.MESSAGE_LENGTH_LIMIT - len('{hostmask} NOTICE {target} :'.format(hostmask=hostmask, target=target)) - 25 - for msg in _chunkify(message, chunklen): - self.rawmsg('NOTICE', target, msg) + for line in message.replace('\r', '').split('\n'): + for chunk in _chunkify(line, chunklen): + self.rawmsg('NOTICE', target, chunk) def mode(self, target, *modes): """ Set mode on target. """