Skip to content

Commit

Permalink
remove users that stopped the bot from lists
Browse files Browse the repository at this point in the history
  • Loading branch information
fkarg committed Jun 18, 2022
1 parent 897ca89 commit aa5b72c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/tickets.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ def wip(update: Update, context: CallbackContext) -> None:
uid = int(context.args[0])
except (ValueError, IndexError):
update.message.reply_text("Die Benutzung des Kommandos ist /wip <ticket-id>")
return
if tup := context.bot_data["tickets"].get(uid):
(group, text, is_wip) = tup
if is_wip:
Expand Down
12 changes: 9 additions & 3 deletions lib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,23 @@ def group_msg(
update: Update, context: CallbackContext, group: str, message: str
) -> None:
log.info(f"to {group}: {message}")
remove = []
for chat_id in context.bot_data["group_association"].get(group, []):
try:
context.bot.send_message(
chat_id=chat_id,
text=message,
)
except telegram.error.Unauthorized as e:
text = f"Unauthorized for sending message to {chat_id} from {context.user_data['group_association']}"
log.error(text)
text = f"Unauthorized for sending message to {chat_id} from {context.user_data['group_association']} in list of {group}. Removing from list."
log.warn(text)
dev_msg(text)
# dev_msg(e)
context.dispatcher.user_data[chat_id].clear()
context.dispatcher.update_persistence()
remove.append(chat_id)
if remove:
for rid in remove:
context.bot_data["group_association"].get(group, []).remove(rid)


def orga_msg(update: Update, context: CallbackContext, message: str) -> None:
Expand Down

0 comments on commit aa5b72c

Please sign in to comment.