From 0ed652eae38cecd36c584115129f5e3fe0e127f8 Mon Sep 17 00:00:00 2001 From: deathbybandaid Date: Tue, 2 Apr 2019 08:02:48 -0400 Subject: [PATCH] it was brought to my attention that NOTICE and PRIVMSG have different MAXTARGET --- sopel/bot.py | 23 +++++++++++++++++++++-- sopel/tools/__init__.py | 16 ---------------- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/sopel/bot.py b/sopel/bot.py index 03d3f72a68..2799b44584 100644 --- a/sopel/bot.py +++ b/sopel/bot.py @@ -297,7 +297,16 @@ def say(self, text, recipients, max_messages=1): # Manage multi-line only when needed text, excess = tools.get_sendable_message(text) - recipientgroups = tools.get_destination_groups(recipients) + if not isinstance(recipients, list): + recipients = recipients.split(",") + + maxtargets = 4 + # if server.capabilities.maxtargets # TODO + recipientgroups = [] + while len(recipients): + dests_part = ','.join(str(x) for x in recipients[-maxtargets:]) + recipientgroups.append(dests_part) + del recipients[-maxtargets:] for recipientgroup in recipientgroups: @@ -347,7 +356,17 @@ def notice(self, text, dests): the channel (or nickname, if a private message), in which the trigger happened. """ - destgroups = tools.get_destination_groups(dests) + if not isinstance(dests, list): + dests = dests.split(",") + + maxtargets = 4 + # if server.capabilities.maxtargets # TODO + destgroups = [] + while len(dests): + dests_part = ','.join(str(x) for x in dests[-maxtargets:]) + destgroups.append(dests_part) + del dests[-maxtargets:] + for destgroup in destgroups: self.write(('NOTICE', destgroup), text) diff --git a/sopel/tools/__init__.py b/sopel/tools/__init__.py index 575b2dbc6d..738a46af84 100644 --- a/sopel/tools/__init__.py +++ b/sopel/tools/__init__.py @@ -186,22 +186,6 @@ def get_sendable_message(text, max_length=400): return text, excess.lstrip() -def get_destination_groups(dests): - - if not isinstance(dests, list): - dests = dests.split(",") - - maxtargets = 4 - # if server.capabilities.maxtargets # TODO - destgroups = [] - while len(dests): - dests_part = ','.join(str(x) for x in dests[-maxtargets:]) - destgroups.append(dests_part) - del dests[-maxtargets:] - - return destgroups - - def deprecated(old): def new(*args, **kwargs): print('Function %s is deprecated.' % old.__name__, file=sys.stderr)