Skip to content

Commit

Permalink
Merge pull request #1138 from KazWolfe/master
Browse files Browse the repository at this point in the history
Implement delete_force command (#1071)
  • Loading branch information
angussidney committed Oct 9, 2017
2 parents ebafbc8 + 49d1c86 commit 953b85f
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions chatcommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -1435,9 +1435,9 @@ def command_report_post(ev_room, ev_user_id, wrap2, message_parts, message_url,
# Subcommands go below here
# noinspection PyIncorrectDocstring,PyUnusedLocal,PyBroadException
@check_permissions
def subcommand_delete(ev_room, ev_user_id, wrap2, msg, *args, **kwargs):
def subcommand_delete_force(ev_room, ev_user_id, wrap2, msg, *args, **kwargs):
"""
Attempts to delete a post from room
Delete a post from the room, ignoring protection for Charcoal HQ
:param msg:
:param wrap2:
:param ev_user_id:
Expand All @@ -1452,6 +1452,29 @@ def subcommand_delete(ev_room, ev_user_id, wrap2, msg, *args, **kwargs):
return Response(command_status=True, message=None)


# noinspection PyIncorrectDocstring,PyUnusedLocal,PyBroadException
@check_permissions
def subcommand_delete(ev_room, ev_user_id, wrap2, msg, *args, **kwargs):
"""
Delete a post from a chatroom, with an override for Charcoal HQ.
:param msg:
:param wrap2:
:param ev_user_id:
:param ev_room:
:param kwargs: No additional arguments expected
:return: None
"""

if int(ev_room.id) == int(GlobalVars.charcoal_hq.id):
return Response(command_status=False, message="Messages from SmokeDetector in Charcoal HQ are generally kept "
"as records. If you really need to delete a message, please use "
"`sd delete-force`. See [this note on message deletion]"
"(https://charcoal-se.org/smokey/Commands"
"#a-note-on-message-deletion) for more details.")
else:
return subcommand_delete_force(ev_room, ev_user_id, wrap2, msg, *args, **kwargs)


# noinspection PyIncorrectDocstring,PyUnusedLocal
@check_permissions
def subcommand_editlink(ev_room, ev_user_id, wrap2, msg_content, msg, *args, **kwargs):
Expand Down Expand Up @@ -1843,6 +1866,8 @@ def subcommand_autoflagged(msg_content, post_url, *args, **kwargs):
"poof": subcommand_delete,
"del": subcommand_delete,

"delete-force": subcommand_delete_force,

"postgone": subcommand_editlink,

"why": subcommand_why,
Expand Down

0 comments on commit 953b85f

Please sign in to comment.