Skip to content
This repository has been archived by the owner on Sep 30, 2022. It is now read-only.

warns: Notify non-admin users instead of doing nothing when removing … #33

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion tg_bot/modules/warns.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ def warn(user: User, chat: Chat, reason: str, message: Message, warner: User = N


@run_async
@user_admin_no_reply
@bot_admin
@loggable
def button(bot: Bot, update: Update) -> str:
Expand All @@ -103,6 +102,9 @@ def button(bot: Bot, update: Update) -> str:
if match:
user_id = match.group(1)
chat = update.effective_chat # type: Optional[Chat]
if not is_user_admin(chat, int(user.id)):
query.answer(text="You are not authorized to remove this warn! Only administrators may remove warns.", show_alert=True)
return ""
res = sql.remove_warn(user_id, chat.id)
if res:
update.effective_message.edit_text(
Expand Down