mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Added new modules
This commit is contained in:
parent
e5c2dffdf1
commit
7caeeb667f
6 changed files with 199 additions and 0 deletions
28
aiogram/methods/approve_chat_join_request.py
Normal file
28
aiogram/methods/approve_chat_join_request.py
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Union
|
||||
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
|
||||
|
||||
class ApproveChatJoinRequest(TelegramMethod[bool]):
|
||||
"""
|
||||
Use this method to approve a chat join request. The bot must be an administrator in the chat for this to work and must have the *can_invite_users* administrator right. Returns :code:`True` on success.
|
||||
|
||||
Source: https://core.telegram.org/bots/api#approvechatjoinrequest
|
||||
"""
|
||||
|
||||
__returning__ = bool
|
||||
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
|
||||
user_id: int
|
||||
"""Unique identifier of the target user"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="approveChatJoinRequest", data=data)
|
||||
28
aiogram/methods/decline_chat_join_request.py
Normal file
28
aiogram/methods/decline_chat_join_request.py
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING, Any, Dict, Union
|
||||
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from ..client.bot import Bot
|
||||
|
||||
|
||||
class DeclineChatJoinRequest(TelegramMethod[bool]):
|
||||
"""
|
||||
Use this method to decline a chat join request. The bot must be an administrator in the chat for this to work and must have the *can_invite_users* administrator right. Returns :code:`True` on success.
|
||||
|
||||
Source: https://core.telegram.org/bots/api#declinechatjoinrequest
|
||||
"""
|
||||
|
||||
__returning__ = bool
|
||||
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target channel (in the format :code:`@channelusername`)"""
|
||||
user_id: int
|
||||
"""Unique identifier of the target user"""
|
||||
|
||||
def build_request(self, bot: Bot) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="declineChatJoinRequest", data=data)
|
||||
32
aiogram/types/chat_join_request.py
Normal file
32
aiogram/types/chat_join_request.py
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import datetime
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
|
||||
from pydantic import Field
|
||||
|
||||
from .base import TelegramObject
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .chat import Chat
|
||||
from .chat_invite_link import ChatInviteLink
|
||||
from .user import User
|
||||
|
||||
|
||||
class ChatJoinRequest(TelegramObject):
|
||||
"""
|
||||
Represents a join request sent to a chat.
|
||||
|
||||
Source: https://core.telegram.org/bots/api#chatjoinrequest
|
||||
"""
|
||||
|
||||
chat: Chat
|
||||
"""Chat to which the request was sent"""
|
||||
from_user: User = Field(..., alias="from")
|
||||
"""User that sent the join request"""
|
||||
date: datetime.datetime
|
||||
"""Date the request was sent in Unix time"""
|
||||
bio: Optional[str] = None
|
||||
"""*Optional*. Bio of the user."""
|
||||
invite_link: Optional[ChatInviteLink] = None
|
||||
"""*Optional*. Chat invite link that was used by the user to send the join request"""
|
||||
51
docs/api/methods/approve_chat_join_request.rst
Normal file
51
docs/api/methods/approve_chat_join_request.rst
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
######################
|
||||
approveChatJoinRequest
|
||||
######################
|
||||
|
||||
Returns: :obj:`bool`
|
||||
|
||||
.. automodule:: aiogram.methods.approve_chat_join_request
|
||||
:members:
|
||||
:member-order: bysource
|
||||
:undoc-members: True
|
||||
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
As bot method
|
||||
-------------
|
||||
|
||||
.. code-block::
|
||||
|
||||
result: bool = await bot.approve_chat_join_request(...)
|
||||
|
||||
|
||||
Method as object
|
||||
----------------
|
||||
|
||||
Imports:
|
||||
|
||||
- :code:`from aiogram.methods.approve_chat_join_request import ApproveChatJoinRequest`
|
||||
- alias: :code:`from aiogram.methods import ApproveChatJoinRequest`
|
||||
|
||||
In handlers with current bot
|
||||
----------------------------
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
result: bool = await ApproveChatJoinRequest(...)
|
||||
|
||||
With specific bot
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
result: bool = await bot(ApproveChatJoinRequest(...))
|
||||
|
||||
As reply into Webhook in handler
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
return ApproveChatJoinRequest(...)
|
||||
51
docs/api/methods/decline_chat_join_request.rst
Normal file
51
docs/api/methods/decline_chat_join_request.rst
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
######################
|
||||
declineChatJoinRequest
|
||||
######################
|
||||
|
||||
Returns: :obj:`bool`
|
||||
|
||||
.. automodule:: aiogram.methods.decline_chat_join_request
|
||||
:members:
|
||||
:member-order: bysource
|
||||
:undoc-members: True
|
||||
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
As bot method
|
||||
-------------
|
||||
|
||||
.. code-block::
|
||||
|
||||
result: bool = await bot.decline_chat_join_request(...)
|
||||
|
||||
|
||||
Method as object
|
||||
----------------
|
||||
|
||||
Imports:
|
||||
|
||||
- :code:`from aiogram.methods.decline_chat_join_request import DeclineChatJoinRequest`
|
||||
- alias: :code:`from aiogram.methods import DeclineChatJoinRequest`
|
||||
|
||||
In handlers with current bot
|
||||
----------------------------
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
result: bool = await DeclineChatJoinRequest(...)
|
||||
|
||||
With specific bot
|
||||
~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
result: bool = await bot(DeclineChatJoinRequest(...))
|
||||
|
||||
As reply into Webhook in handler
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
return DeclineChatJoinRequest(...)
|
||||
9
docs/api/types/chat_join_request.rst
Normal file
9
docs/api/types/chat_join_request.rst
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
###############
|
||||
ChatJoinRequest
|
||||
###############
|
||||
|
||||
|
||||
.. automodule:: aiogram.types.chat_join_request
|
||||
:members:
|
||||
:member-order: bysource
|
||||
:undoc-members: True
|
||||
Loading…
Add table
Add a link
Reference in a new issue