Skip to content

Commit

Permalink
Merge pull request #1576 from paper1111/patch-1
Browse files Browse the repository at this point in the history
 Add unnotify-all command
  • Loading branch information
quartata committed Jan 29, 2018
2 parents 4524343 + 1cf34fa commit b3f050b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
13 changes: 12 additions & 1 deletion chatcommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,18 @@ def notify(msg, room_id, se_site):
raise CmdException("Unrecognized code returned when adding notification.")


# TODO: !!/unnotify-all
# noinspection PyIncorrectDocstring,PyMissingTypeHints
@command(whole_msg=True, aliases=["unnotify-all"])
def unnotify_all(msg):
"""
Unsubscribes a user to all events
:param msg:
:param room_id:
:param se_site:
:return: A string
"""
remove_all_from_notification_list(msg.owner.id)
return "I will no longer ping you if I report a post anywhere."


# noinspection PyIncorrectDocstring,PyMissingTypeHints
Expand Down
9 changes: 9 additions & 0 deletions datahandling.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,15 @@ def will_i_be_notified(user_id, chat_site, room_id, se_site):
return notification_tuple in GlobalVars.notifications


# noinspection PyMissingTypeHints
def remove_all_from_notification_list(user_id):
user_id = int(user_id)

for notification in GlobalVars.notifications:
if notification[0] == user_id:
remove_from_notification_list(*notification)


def get_all_notification_sites(user_id, chat_site, room_id):
sites = []
for notification in GlobalVars.notifications:
Expand Down

0 comments on commit b3f050b

Please sign in to comment.