Added new modules

This commit is contained in:
Alex Root Junior 2021-11-08 01:34:30 +02:00
parent e5c2dffdf1
commit 7caeeb667f
6 changed files with 199 additions and 0 deletions

View 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)

View 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)

View 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"""

View 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(...)

View 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(...)

View file

@ -0,0 +1,9 @@
###############
ChatJoinRequest
###############
.. automodule:: aiogram.types.chat_join_request
:members:
:member-order: bysource
:undoc-members: True