mirror of
https://github.com/TeamPGM/pyrogram.git
synced 2024-11-16 12:51:18 +00:00
Merge pull request #155 from Furoin/chat
Allow using "me" or "self" in Filters.chat
This commit is contained in:
commit
160420bda4
@ -284,15 +284,16 @@ class Filters:
|
|||||||
Args:
|
Args:
|
||||||
chats (``int`` | ``str`` | ``list``):
|
chats (``int`` | ``str`` | ``list``):
|
||||||
Pass one or more chat ids/usernames to filter chats.
|
Pass one or more chat ids/usernames to filter chats.
|
||||||
|
For your personal cloud (Saved Messages) you can simply use “me” or “self”.
|
||||||
Defaults to None (no chats).
|
Defaults to None (no chats).
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, chats: int or str or list = None):
|
def __init__(self, chats: int or str or list = None):
|
||||||
chats = [] if chats is None else chats if type(chats) is list else [chats]
|
chats = [] if chats is None else chats if type(chats) is list else [chats]
|
||||||
super().__init__(
|
super().__init__(
|
||||||
{i.lower().strip("@") if type(i) is str else i for i in chats}
|
{"me" if i in ["me", "self"] else i.lower().strip("@") if type(i) is str else i for i in chats}
|
||||||
if type(chats) is list else
|
if type(chats) is list else
|
||||||
{chats.lower().strip("@") if type(chats) is str else chats}
|
{"me" if chats in ["me", "self"] else chats.lower().strip("@") if type(chats) is str else chats}
|
||||||
)
|
)
|
||||||
|
|
||||||
def __call__(self, message):
|
def __call__(self, message):
|
||||||
@ -300,7 +301,10 @@ class Filters:
|
|||||||
message.chat
|
message.chat
|
||||||
and (message.chat.id in self
|
and (message.chat.id in self
|
||||||
or (message.chat.username
|
or (message.chat.username
|
||||||
and message.chat.username.lower() in self))
|
and message.chat.username.lower() in self)
|
||||||
|
or ("me" in self and message.from_user
|
||||||
|
and message.from_user.is_self
|
||||||
|
and not message.outgoing))
|
||||||
)
|
)
|
||||||
|
|
||||||
service = create(
|
service = create(
|
||||||
|
Loading…
Reference in New Issue
Block a user