async def is_joined(app, from_user_id, ids) -> bool:
"""
Parameters:
- app (`pyrogram.Client`) - client
- from_user_id (`int | str`) - user id
- ids (`list[int | str] | int | str`) - chat ids
"""
# convert to list if it is not
ids = ids if isinstance(ids, list) else [ids]
for ch in ids:
try:
status = await app.get_chat_member(ch, from_user_id)
except errors.UserNotParticipant:
return False
if status.status == ChatMemberStatus.LEFT:
return False
return True
# Example:
@app.on_message()
async def func(_, msg):
if is_joined(app, msg.from_user.id, [50463729, "pyrogram", 11837386]):
...
...
Last active
March 7, 2023 15:02
-
-
Save awolverp/5de08ef2ca3d8645ee490592c974c726 to your computer and use it in GitHub Desktop.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment