mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2026-01-02 05:24:51 +00:00
Add chat_join_type to differentiate on three different types of new_chat_members
Signed-off-by: wulan17 <wulan17@nusantararom.org>
This commit is contained in:
parent
ecfa97f115
commit
9697a7f3cd
4 changed files with 48 additions and 4 deletions
|
|
@ -20,6 +20,7 @@
|
|||
from .business_schedule import BusinessSchedule
|
||||
from .chat_action import ChatAction
|
||||
from .chat_event_action import ChatEventAction
|
||||
from .chat_join_type import ChatJoinType
|
||||
from .chat_member_status import ChatMemberStatus
|
||||
from .chat_members_filter import ChatMembersFilter
|
||||
from .chat_type import ChatType
|
||||
|
|
@ -45,6 +46,7 @@ __all__ = [
|
|||
'BusinessSchedule',
|
||||
'ChatAction',
|
||||
'ChatEventAction',
|
||||
'ChatJoinType',
|
||||
'ChatMemberStatus',
|
||||
'ChatMembersFilter',
|
||||
'ChatType',
|
||||
|
|
|
|||
34
pyrogram/enums/chat_join_type.py
Normal file
34
pyrogram/enums/chat_join_type.py
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
# Pyrogram - Telegram MTProto API Client Library for Python
|
||||
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
|
||||
#
|
||||
# This file is part of Pyrogram.
|
||||
#
|
||||
# Pyrogram is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Pyrogram is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from enum import auto
|
||||
|
||||
from .auto_name import AutoName
|
||||
|
||||
|
||||
class ChatJoinType(AutoName):
|
||||
"""How the service message :obj:`~pyrogram.enums.MessageServiceType.NEW_CHAT_MEMBERS` was used for the member to join the chat."""
|
||||
|
||||
BY_ADD = auto()
|
||||
"A new member joined the chat via an invite link"
|
||||
|
||||
BY_LINK = auto()
|
||||
"A new member joined the chat via an invite link"
|
||||
|
||||
BY_REQUEST = auto()
|
||||
"A new member was accepted to the chat by an administrator"
|
||||
|
|
@ -28,9 +28,6 @@ class MessageServiceType(AutoName):
|
|||
NEW_CHAT_MEMBERS = auto()
|
||||
"New members join"
|
||||
|
||||
CHAT_JOINED_BY_REQUEST = auto()
|
||||
"a member chat join request approved by admin."
|
||||
|
||||
LEFT_CHAT_MEMBERS = auto()
|
||||
"Left chat members"
|
||||
|
||||
|
|
|
|||
|
|
@ -422,6 +422,10 @@ class Message(Object, Update):
|
|||
|
||||
from_scheduled (``bool``, *optional*):
|
||||
Message is a scheduled message and has been sent.
|
||||
|
||||
chat_join_type (:obj:`~pyrogram.enums.ChatJoinType`, *optional*):
|
||||
The message is a service message of the type :obj:`~pyrogram.enums.MessageServiceType.NEW_CHAT_MEMBERS`.
|
||||
This field will contain the enumeration type of how the user had joined the chat.
|
||||
"""
|
||||
|
||||
# TODO: Add game missing field, Also connected_website
|
||||
|
|
@ -537,6 +541,7 @@ class Message(Object, Update):
|
|||
"types.ForceReply"
|
||||
] = None,
|
||||
reactions: List["types.Reaction"] = None,
|
||||
chat_join_type: "enums.ChatJoinType" = None,
|
||||
raw: "raw.types.Message" = None
|
||||
):
|
||||
super().__init__(client)
|
||||
|
|
@ -643,6 +648,7 @@ class Message(Object, Update):
|
|||
self.successful_payment = successful_payment
|
||||
self.payment_refunded = payment_refunded
|
||||
self.reactions = reactions
|
||||
self.chat_join_type = chat_join_type
|
||||
self.raw = raw
|
||||
|
||||
async def wait_for_click(
|
||||
|
|
@ -752,6 +758,7 @@ class Message(Object, Update):
|
|||
boosts_applied = None
|
||||
|
||||
service_type = None
|
||||
chat_join_type = None
|
||||
|
||||
from_user = types.User._parse(client, users.get(user_id, None))
|
||||
sender_chat = types.Chat._parse(client, message, users, chats, is_chat=False) if not from_user else None
|
||||
|
|
@ -759,12 +766,15 @@ class Message(Object, Update):
|
|||
if isinstance(action, raw.types.MessageActionChatAddUser):
|
||||
new_chat_members = [types.User._parse(client, users[i]) for i in action.users]
|
||||
service_type = enums.MessageServiceType.NEW_CHAT_MEMBERS
|
||||
chat_join_type = enums.ChatJoinType.BY_ADD
|
||||
elif isinstance(action, raw.types.MessageActionChatJoinedByLink):
|
||||
new_chat_members = [types.User._parse(client, users[utils.get_raw_peer_id(message.from_id)])]
|
||||
service_type = enums.MessageServiceType.NEW_CHAT_MEMBERS
|
||||
chat_join_type = enums.ChatJoinType.BY_LINK
|
||||
elif isinstance(action, raw.types.MessageActionChatJoinedByRequest):
|
||||
chat_joined_by_request = types.ChatJoinedByRequest()
|
||||
service_type = enums.MessageServiceType.CHAT_JOINED_BY_REQUEST
|
||||
service_type = enums.MessageServiceType.NEW_CHAT_MEMBERS
|
||||
chat_join_type = enums.ChatJoinType.BY_REQUEST
|
||||
elif isinstance(action, raw.types.MessageActionChatDeleteUser):
|
||||
left_chat_member = types.User._parse(client, users[action.user_id])
|
||||
service_type = enums.MessageServiceType.LEFT_CHAT_MEMBERS
|
||||
|
|
@ -889,6 +899,7 @@ class Message(Object, Update):
|
|||
payment_refunded=payment_refunded,
|
||||
boosts_applied=boosts_applied,
|
||||
raw=message,
|
||||
chat_join_type=chat_join_type,
|
||||
client=client
|
||||
# TODO: supergroup_chat_created
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue