Skip to content

Commit

Permalink
Let !!/allspam accept a custom close reason
Browse files Browse the repository at this point in the history
If one is supplied, appends "Reason: {Custom reason}" (as a new line) to the
automatic "User manually reported by..." note. Calls without a custom reason
are unaffected.

The reason must be separated from the URL by a single space and
enclosed in double quotes.

Heavily inspired by the custom-reason handling in !!/report.
  • Loading branch information
Andrew5057 committed Aug 23, 2024
1 parent a92225a commit 9361aef
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions chatcommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -2112,14 +2112,20 @@ def report(msg, args, alias_used="report"):

# noinspection PyIncorrectDocstring,PyUnusedLocal
@command(str, whole_msg=True, privileged=True, aliases=['reportuser'])
def allspam(msg, url):
def allspam(msg, args):
"""
Reports all of a user's posts as spam
Optionally allows for a custom reason, which should follow the URL and be
enclosed by double quotes.
:param msg:
:param url: A user profile URL
:return:
"""

args_raw = msg.split(' "', 1)
url = args_raw[0]

crn, wait = can_report_now(msg.owner.id, msg._client.host)
if not crn:
raise CmdException("You can execute the !!/allspam command again in {} seconds. "
Expand Down Expand Up @@ -2220,7 +2226,14 @@ def allspam(msg, url):
if len(user_posts) > 15:
raise CmdException("The specified user has an abnormally high number of spam posts. Please consider flagging "
"for moderator attention, otherwise use !!/report on the posts individually.")

why_info = u"User manually reported by *{}* in room *{}*.\n".format(msg.owner.name, msg.room.name)
try:
custom_reason = argsraw[1][:-1] if argsraw[1].endswith('"') else argsraw[1]
why_info += "Reason: {}".format(custom_reason)
except IndexError:
pass

# Handle all posts
for index, post in enumerate(user_posts, start=1):
batch = ""
Expand Down

0 comments on commit 9361aef

Please sign in to comment.