Pyrofork: Add chat_joined_by_request

Signed-off-by: wulan17 <wulan17@nusantararom.org>
This commit is contained in:
wulan17 2023-08-18 01:49:22 +07:00
parent 97d714f640
commit 367be6f6eb
No known key found for this signature in database
GPG key ID: 318CD6CD3A6AC0A5
5 changed files with 63 additions and 15 deletions

View file

@ -385,6 +385,7 @@ def pyrogram_api():
ChatEventFilter ChatEventFilter
ChatMemberUpdated ChatMemberUpdated
ChatJoinRequest ChatJoinRequest
ChatJoinedByRequest
ChatJoiner ChatJoiner
Dialog Dialog
Restriction Restriction

View file

@ -1,20 +1,21 @@
# Pyrogram - Telegram MTProto API Client Library for Python # Pyrofork - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-present Dan <https://github.com/delivrance> # Copyright (C) 2017-present Dan <https://github.com/delivrance>
# Copyright (C) 2022-present Mayuri-Chan <https://github.com/Mayuri-Chan>
# #
# This file is part of Pyrogram. # This file is part of Pyrofork.
# #
# Pyrogram is free software: you can redistribute it and/or modify # Pyrofork is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published # 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 # by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version. # (at your option) any later version.
# #
# Pyrogram is distributed in the hope that it will be useful, # Pyrofork is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details. # GNU Lesser General Public License for more details.
# #
# You should have received a copy of the GNU Lesser General Public License # You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. # along with Pyrofork. If not, see <http://www.gnu.org/licenses/>.
from enum import auto from enum import auto
@ -27,6 +28,9 @@ class MessageServiceType(AutoName):
NEW_CHAT_MEMBERS = auto() NEW_CHAT_MEMBERS = auto()
"New members join" "New members join"
CHAT_JOINED_BY_REQUEST = auto()
"a member chat join request approved by admin."
LEFT_CHAT_MEMBERS = auto() LEFT_CHAT_MEMBERS = auto()
"Left chat members" "Left chat members"

View file

@ -1,20 +1,21 @@
# Pyrogram - Telegram MTProto API Client Library for Python # Pyrofork - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-present Dan <https://github.com/delivrance> # Copyright (C) 2017-present Dan <https://github.com/delivrance>
# Copyright (C) 2022-present Mayuri-Chan <https://github.com/Mayuri-Chan>
# #
# This file is part of Pyrogram. # This file is part of Pyrofork.
# #
# Pyrogram is free software: you can redistribute it and/or modify # Pyrofork is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published # 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 # by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version. # (at your option) any later version.
# #
# Pyrogram is distributed in the hope that it will be useful, # Pyrofork is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details. # GNU Lesser General Public License for more details.
# #
# You should have received a copy of the GNU Lesser General Public License # You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. # along with Pyrofork. If not, see <http://www.gnu.org/licenses/>.
import logging import logging
from datetime import datetime from datetime import datetime
@ -207,6 +208,9 @@ class Message(Object, Update):
New members that were added to the group or supergroup and information about them New members that were added to the group or supergroup and information about them
(the bot itself may be one of these members). (the bot itself may be one of these members).
chat_joined_by_request (:obj:`~pyrogram.types.ChatJoinedByRequest`, *optional*):
New members chat join request has been approved in group or supergroup.
left_chat_member (:obj:`~pyrogram.types.User`, *optional*): left_chat_member (:obj:`~pyrogram.types.User`, *optional*):
A member was removed from the group, information about them (this member may be the bot itself). A member was removed from the group, information about them (this member may be the bot itself).
@ -356,6 +360,7 @@ class Message(Object, Update):
poll: "types.Poll" = None, poll: "types.Poll" = None,
dice: "types.Dice" = None, dice: "types.Dice" = None,
new_chat_members: List["types.User"] = None, new_chat_members: List["types.User"] = None,
chat_joined_by_request: "types.ChatJoinedByRequest" = None,
left_chat_member: "types.User" = None, left_chat_member: "types.User" = None,
new_chat_title: str = None, new_chat_title: str = None,
new_chat_photo: "types.Photo" = None, new_chat_photo: "types.Photo" = None,
@ -433,6 +438,7 @@ class Message(Object, Update):
self.poll = poll self.poll = poll
self.dice = dice self.dice = dice
self.new_chat_members = new_chat_members self.new_chat_members = new_chat_members
self.chat_joined_by_request = chat_joined_by_request
self.left_chat_member = left_chat_member self.left_chat_member = left_chat_member
self.new_chat_title = new_chat_title self.new_chat_title = new_chat_title
self.new_chat_photo = new_chat_photo self.new_chat_photo = new_chat_photo
@ -494,6 +500,7 @@ class Message(Object, Update):
action = message.action action = message.action
new_chat_members = None new_chat_members = None
chat_joined_by_request = None
left_chat_member = None left_chat_member = None
new_chat_title = None new_chat_title = None
delete_chat_photo = None delete_chat_photo = None
@ -516,6 +523,9 @@ class Message(Object, Update):
elif isinstance(action, raw.types.MessageActionChatJoinedByLink): elif isinstance(action, raw.types.MessageActionChatJoinedByLink):
new_chat_members = [types.User._parse(client, users[utils.get_raw_peer_id(message.from_id)])] new_chat_members = [types.User._parse(client, users[utils.get_raw_peer_id(message.from_id)])]
service_type = enums.MessageServiceType.NEW_CHAT_MEMBERS service_type = enums.MessageServiceType.NEW_CHAT_MEMBERS
elif isinstance(action, raw.types.MessageActionChatJoinedByRequest):
chat_joined_by_request = types.ChatJoinedByRequest()
service_type = enums.MessageServiceType.CHAT_JOINED_BY_REQUEST
elif isinstance(action, raw.types.MessageActionChatDeleteUser): elif isinstance(action, raw.types.MessageActionChatDeleteUser):
left_chat_member = types.User._parse(client, users[action.user_id]) left_chat_member = types.User._parse(client, users[action.user_id])
service_type = enums.MessageServiceType.LEFT_CHAT_MEMBERS service_type = enums.MessageServiceType.LEFT_CHAT_MEMBERS
@ -568,6 +578,7 @@ class Message(Object, Update):
sender_chat=sender_chat, sender_chat=sender_chat,
service=service_type, service=service_type,
new_chat_members=new_chat_members, new_chat_members=new_chat_members,
chat_joined_by_request=chat_joined_by_request,
left_chat_member=left_chat_member, left_chat_member=left_chat_member,
new_chat_title=new_chat_title, new_chat_title=new_chat_title,
new_chat_photo=new_chat_photo, new_chat_photo=new_chat_photo,

View file

@ -1,20 +1,21 @@
# Pyrogram - Telegram MTProto API Client Library for Python # Pyrofork - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-present Dan <https://github.com/delivrance> # Copyright (C) 2017-present Dan <https://github.com/delivrance>
# Copyright (C) 2022-present Mayuri-Chan <https://github.com/Mayuri-Chan>
# #
# This file is part of Pyrogram. # This file is part of Pyrofork.
# #
# Pyrogram is free software: you can redistribute it and/or modify # Pyrofork is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published # 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 # by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version. # (at your option) any later version.
# #
# Pyrogram is distributed in the hope that it will be useful, # Pyrofork is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details. # GNU Lesser General Public License for more details.
# #
# You should have received a copy of the GNU Lesser General Public License # You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>. # along with Pyrofork. If not, see <http://www.gnu.org/licenses/>.
from .chat import Chat from .chat import Chat
from .chat_admin_with_invite_links import ChatAdminWithInviteLinks from .chat_admin_with_invite_links import ChatAdminWithInviteLinks
@ -22,6 +23,7 @@ from .chat_event import ChatEvent
from .chat_event_filter import ChatEventFilter from .chat_event_filter import ChatEventFilter
from .chat_invite_link import ChatInviteLink from .chat_invite_link import ChatInviteLink
from .chat_join_request import ChatJoinRequest from .chat_join_request import ChatJoinRequest
from .chat_joined_by_request import ChatJoinedByRequest
from .chat_joiner import ChatJoiner from .chat_joiner import ChatJoiner
from .chat_member import ChatMember from .chat_member import ChatMember
from .chat_member_updated import ChatMemberUpdated from .chat_member_updated import ChatMemberUpdated
@ -60,6 +62,7 @@ __all__ = [
"ChatMemberUpdated", "ChatMemberUpdated",
"VideoChatScheduled", "VideoChatScheduled",
"ChatJoinRequest", "ChatJoinRequest",
"ChatJoinedByRequest",
"ChatPrivileges", "ChatPrivileges",
"ChatJoiner", "ChatJoiner",
"EmojiStatus", "EmojiStatus",

View file

@ -0,0 +1,29 @@
# Pyrofork - Telegram MTProto API Client Library for Python
# Copyright (C) 2022-present Mayuri-Chan <https://github.com/Mayuri-Chan>
#
# This file is part of Pyrofork.
#
# Pyrofork 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.
#
# Pyrofork 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 Pyrofork. If not, see <http://www.gnu.org/licenses/>.
from ..object import Object
class ChatJoinedByRequest(Object):
"""A service message about a user join request approved in the chat.
Currently holds no information.
"""
def __init__(self):
super().__init__()