Skip to content

Commit

Permalink
Fixed telegram issue with chat member lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
ManiMozaffar committed Apr 28, 2023
1 parent 4e8f366 commit 6cd246e
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions tel/plugins/filters.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from functools import wraps


from pyrogram.errors.exceptions.bad_request_400 import UserNotParticipant
from pyrogram import enums
from pyrogram.types import Message
import loguru
Expand All @@ -11,14 +9,17 @@


async def is_user_a_member_of_channel(bot: app, message: Message) -> bool:
user = await bot.get_chat_member(
int(env.channel_id), message.from_user.id
)
return user.status in [
enums.ChatMemberStatus.ADMINISTRATOR,
enums.ChatMemberStatus.MEMBER,
enums.ChatMemberStatus.OWNER,
]
try:
user = await bot.get_chat_member(
int(env.channel_id), message.from_user.id
)
return user.status in [
enums.ChatMemberStatus.ADMINISTRATOR,
enums.ChatMemberStatus.MEMBER,
enums.ChatMemberStatus.OWNER,
]
except UserNotParticipant:
return False


async def is_not_user_a_member_of_channel(bot: app, message: Message) -> bool:
Expand Down

0 comments on commit 6cd246e

Please sign in to comment.