Skip to content

Commit

Permalink
Added the field user_chat_id to the class ChatJoinRequest.
Browse files Browse the repository at this point in the history
  • Loading branch information
SpEcHiDe committed Feb 22, 2024
1 parent e45f3f2 commit 3713048
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions docs/source/releases/changes-in-this-fork.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ it can take advantage of new goodies!
| Leaked Scheme layer |
+------------------------+

- Added the field ``user_chat_id`` to the class :obj:`~pyrogram.types.ChatJoinRequest`.
- Added the field ``switch_inline_query_chosen_chat`` of the type :obj:`~pyrogram.types.SwitchInlineQueryChosenChat` to the class :obj:`~pyrogram.types.InlineKeyboardButton`, which allows bots to switch to inline mode in a chosen chat of the given type.
- Add support for ``pay`` in :obj:`~pyrogram.types.InlineKeyboardButton`
- `#1345 <https://github.com/pyrogram/pyrogram/issues/1345>`_
Expand Down
15 changes: 10 additions & 5 deletions pyrogram/types/user_and_chats/chat_join_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ class ChatJoinRequest(Object, Update):
from_user (:obj:`~pyrogram.types.User`):
User that sent the join request.
user_chat_id (``int``):
Identifier of a private chat with the user who sent the join request. This number may have more than 32 significant bits and some programming languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a 64-bit integer or double-precision float type are safe for storing this identifier. The bot can use this identifier for 5 minutes to send messages until the join request is processed, assuming no other administrator contacted the user.
date (:py:obj:`~datetime.datetime`):
Date the request was sent.
Expand All @@ -52,6 +55,7 @@ def __init__(
client: "pyrogram.Client" = None,
chat: "types.Chat",
from_user: "types.User",
user_chat_id: int,
date: datetime,
bio: str = None,
invite_link: "types.ChatInviteLink" = None
Expand All @@ -60,6 +64,7 @@ def __init__(

self.chat = chat
self.from_user = from_user
self.user_chat_id = user_chat_id
self.date = date
self.bio = bio
self.invite_link = invite_link
Expand All @@ -72,10 +77,10 @@ def _parse(
chats: Dict[int, "raw.types.Chat"]
) -> "ChatJoinRequest":
chat_id = utils.get_raw_peer_id(update.peer)

return ChatJoinRequest(
chat=types.Chat._parse_chat(client, chats[chat_id]),
from_user=types.User._parse(client, users[update.user_id]),
user_chat_id=update.user_id, # TODO
date=utils.timestamp_to_datetime(update.date),
bio=update.about,
invite_link=types.ChatInviteLink._parse(client, update.invite, users),
Expand All @@ -91,7 +96,7 @@ async def approve(self) -> bool:
await client.approve_chat_join_request(
chat_id=request.chat.id,
user_id=request.from_user.id
user_id=request.user_chat_id
)
Example:
Expand All @@ -107,7 +112,7 @@ async def approve(self) -> bool:
"""
return await self._client.approve_chat_join_request(
chat_id=self.chat.id,
user_id=self.from_user.id
user_id=self.user_chat_id
)

async def decline(self) -> bool:
Expand All @@ -119,7 +124,7 @@ async def decline(self) -> bool:
await client.decline_chat_join_request(
chat_id=request.chat.id,
user_id=request.from_user.id
user_id=request.user_chat_id
)
Example:
Expand All @@ -135,5 +140,5 @@ async def decline(self) -> bool:
"""
return await self._client.decline_chat_join_request(
chat_id=self.chat.id,
user_id=self.from_user.id
user_id=self.user_chat_id
)

0 comments on commit 3713048

Please sign in to comment.