Skip to content

Commit

Permalink
SpamPrediction: Fix case when ban button is invoked by non chat member
Browse files Browse the repository at this point in the history
  • Loading branch information
MrMissx committed May 31, 2022
1 parent d899db1 commit aed8ccf
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion anjani/plugins/spam_prediction.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
MessageNotModified,
QueryIdInvalid,
UserAdminInvalid,
UserNotParticipant
)
from pyrogram.types import (
CallbackQuery,
Expand Down Expand Up @@ -178,7 +179,14 @@ async def on_callback_query(self, query: CallbackQuery) -> None:

async def _spam_ban_handler(self, query: CallbackQuery, user: str) -> None:
chat = query.message.chat
invoker = await chat.get_member(query.from_user.id)
try:
invoker = await chat.get_member(query.from_user.id)
except UserNotParticipant:
return await query.answer(
await self.get_text(chat.id, "error-no-rights"),
show_alert=True
)

if not invoker.privileges or not invoker.privileges.can_restrict_members:
return await query.answer(await self.get_text(chat.id, "spampredict-ban-no-perm"))

Expand Down

0 comments on commit aed8ccf

Please sign in to comment.