Skip to content

Commit

Permalink
it was brought to my attention that NOTICE and PRIVMSG have different…
Browse files Browse the repository at this point in the history
… MAXTARGET
  • Loading branch information
deathbybandaid committed Apr 2, 2019
1 parent 4ad5bc7 commit 0ed652e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
23 changes: 21 additions & 2 deletions sopel/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down Expand Up @@ -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)

Expand Down
16 changes: 0 additions & 16 deletions sopel/tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 0ed652e

Please sign in to comment.