mirror of
https://github.com/aiogram/aiogram.git
synced 2026-04-08 16:37:47 +00:00
Telegram Bot API 4.5
This commit is contained in:
parent
d2606b389a
commit
ffb0cdf88f
39 changed files with 146 additions and 37 deletions
|
|
@ -26,5 +26,5 @@ __all__ = (
|
|||
"handler",
|
||||
)
|
||||
|
||||
__version__ = "3.0.0a0"
|
||||
__api_version__ = "4.4"
|
||||
__version__ = "3.0.0a1"
|
||||
__api_version__ = "4.5"
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ from ..methods import (
|
|||
SendVideo,
|
||||
SendVideoNote,
|
||||
SendVoice,
|
||||
SetChatAdministratorCustomTitle,
|
||||
SetChatDescription,
|
||||
SetChatPermissions,
|
||||
SetChatPhoto,
|
||||
|
|
@ -1204,6 +1205,27 @@ class Bot(BaseBot):
|
|||
)
|
||||
return await self.emit(call)
|
||||
|
||||
async def set_chat_administrator_custom_title(
|
||||
self, chat_id: Union[int, str], user_id: int, custom_title: str,
|
||||
) -> bool:
|
||||
"""
|
||||
Use this method to set a custom title for an administrator in a supergroup promoted by the
|
||||
bot. Returns True on success.
|
||||
|
||||
Source: https://core.telegram.org/bots/api#setchatadministratorcustomtitle
|
||||
|
||||
:param chat_id: Unique identifier for the target chat or username of the target supergroup
|
||||
(in the format @supergroupusername)
|
||||
:param user_id: Unique identifier of the target user
|
||||
:param custom_title: New custom title for the administrator; 0-16 characters, emoji are
|
||||
not allowed
|
||||
:return: Returns True on success.
|
||||
"""
|
||||
call = SetChatAdministratorCustomTitle(
|
||||
chat_id=chat_id, user_id=user_id, custom_title=custom_title,
|
||||
)
|
||||
return await self.emit(call)
|
||||
|
||||
async def set_chat_permissions(
|
||||
self, chat_id: Union[int, str], permissions: ChatPermissions
|
||||
) -> bool:
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ from .send_venue import SendVenue
|
|||
from .send_video import SendVideo
|
||||
from .send_video_note import SendVideoNote
|
||||
from .send_voice import SendVoice
|
||||
from .set_chat_administrator_custom_title import SetChatAdministratorCustomTitle
|
||||
from .set_chat_description import SetChatDescription
|
||||
from .set_chat_permissions import SetChatPermissions
|
||||
from .set_chat_photo import SetChatPhoto
|
||||
|
|
@ -97,6 +98,7 @@ __all__ = (
|
|||
"UnbanChatMember",
|
||||
"RestrictChatMember",
|
||||
"PromoteChatMember",
|
||||
"SetChatAdministratorCustomTitle",
|
||||
"SetChatPermissions",
|
||||
"ExportChatInviteLink",
|
||||
"SetChatPhoto",
|
||||
|
|
|
|||
27
aiogram/api/methods/set_chat_administrator_custom_title.py
Normal file
27
aiogram/api/methods/set_chat_administrator_custom_title.py
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
from typing import Any, Dict, Union
|
||||
|
||||
from .base import Request, TelegramMethod
|
||||
|
||||
|
||||
class SetChatAdministratorCustomTitle(TelegramMethod[bool]):
|
||||
"""
|
||||
Use this method to set a custom title for an administrator in a supergroup promoted by the
|
||||
bot. Returns True on success.
|
||||
|
||||
Source: https://core.telegram.org/bots/api#setchatadministratorcustomtitle
|
||||
"""
|
||||
|
||||
__returning__ = bool
|
||||
|
||||
chat_id: Union[int, str]
|
||||
"""Unique identifier for the target chat or username of the target supergroup (in the format
|
||||
@supergroupusername)"""
|
||||
user_id: int
|
||||
"""Unique identifier of the target user"""
|
||||
custom_title: str
|
||||
"""New custom title for the administrator; 0-16 characters, emoji are not allowed"""
|
||||
|
||||
def build_request(self) -> Request:
|
||||
data: Dict[str, Any] = self.dict()
|
||||
|
||||
return Request(method="setChatAdministratorCustomTitle", data=data)
|
||||
|
|
@ -16,7 +16,10 @@ class Animation(TelegramObject):
|
|||
"""
|
||||
|
||||
file_id: str
|
||||
"""Identifier for this file"""
|
||||
"""Identifier for this file, which can be used to download or reuse the file"""
|
||||
file_unique_id: str
|
||||
"""Unique identifier for this file, which is supposed to be the same over time and for
|
||||
different bots. Can't be used to download or reuse the file."""
|
||||
width: int
|
||||
"""Video width as defined by sender"""
|
||||
height: int
|
||||
|
|
|
|||
|
|
@ -16,7 +16,10 @@ class Audio(TelegramObject):
|
|||
"""
|
||||
|
||||
file_id: str
|
||||
"""Identifier for this file"""
|
||||
"""Identifier for this file, which can be used to download or reuse the file"""
|
||||
file_unique_id: str
|
||||
"""Unique identifier for this file, which is supposed to be the same over time and for
|
||||
different bots. Can't be used to download or reuse the file."""
|
||||
duration: int
|
||||
"""Duration of the audio in seconds as defined by sender"""
|
||||
performer: Optional[str] = None
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ from typing import TYPE_CHECKING, Optional
|
|||
from .base import TelegramObject
|
||||
|
||||
if TYPE_CHECKING: # pragma: no cover
|
||||
from .chat_photo import ChatPhoto
|
||||
from .message import Message
|
||||
from .chat_photo import ChatPhoto
|
||||
from .chat_permissions import ChatPermissions
|
||||
|
||||
|
||||
|
|
@ -44,6 +44,9 @@ class Chat(TelegramObject):
|
|||
"""Pinned message, for groups, supergroups and channels. Returned only in getChat."""
|
||||
permissions: Optional[ChatPermissions] = None
|
||||
"""Default chat member permissions, for groups and supergroups. Returned only in getChat."""
|
||||
slow_mode_delay: Optional[int] = None
|
||||
"""For supergroups, the minimum allowed delay between consecutive messages sent by each
|
||||
unpriviledged user. Returned only in getChat."""
|
||||
sticker_set_name: Optional[str] = None
|
||||
"""For supergroups, name of group sticker set. Returned only in getChat."""
|
||||
can_set_sticker_set: Optional[bool] = None
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ class ChatMember(TelegramObject):
|
|||
status: str
|
||||
"""The member's status in the chat. Can be 'creator', 'administrator', 'member', 'restricted',
|
||||
'left' or 'kicked'"""
|
||||
custom_title: Optional[str] = None
|
||||
"""Owner and administrators only. Custom title for this user"""
|
||||
until_date: Optional[Union[int, datetime.datetime, datetime.timedelta]] = None
|
||||
"""Restricted and kicked only. Date when restrictions will be lifted for this user; unix time"""
|
||||
can_be_edited: Optional[bool] = None
|
||||
|
|
|
|||
|
|
@ -13,6 +13,12 @@ class ChatPhoto(TelegramObject):
|
|||
small_file_id: str
|
||||
"""File identifier of small (160x160) chat photo. This file_id can be used only for photo
|
||||
download and only for as long as the photo is not changed."""
|
||||
small_file_unique_id: str
|
||||
"""Unique file identifier of small (160x160) chat photo, which is supposed to be the same over
|
||||
time and for different bots. Can't be used to download or reuse the file."""
|
||||
big_file_id: str
|
||||
"""File identifier of big (640x640) chat photo. This file_id can be used only for photo
|
||||
download and only for as long as the photo is not changed."""
|
||||
big_file_unique_id: str
|
||||
"""Unique file identifier of big (640x640) chat photo, which is supposed to be the same over
|
||||
time and for different bots. Can't be used to download or reuse the file."""
|
||||
|
|
|
|||
|
|
@ -16,7 +16,10 @@ class Document(TelegramObject):
|
|||
"""
|
||||
|
||||
file_id: str
|
||||
"""Identifier for this file"""
|
||||
"""Identifier for this file, which can be used to download or reuse the file"""
|
||||
file_unique_id: str
|
||||
"""Unique identifier for this file, which is supposed to be the same over time and for
|
||||
different bots. Can't be used to download or reuse the file."""
|
||||
thumb: Optional[PhotoSize] = None
|
||||
"""Document thumbnail as defined by sender"""
|
||||
file_name: Optional[str] = None
|
||||
|
|
|
|||
|
|
@ -17,7 +17,10 @@ class File(TelegramObject):
|
|||
"""
|
||||
|
||||
file_id: str
|
||||
"""Identifier for this file"""
|
||||
"""Identifier for this file, which can be used to download or reuse the file"""
|
||||
file_unique_id: str
|
||||
"""Unique identifier for this file, which is supposed to be the same over time and for
|
||||
different bots. Can't be used to download or reuse the file."""
|
||||
file_size: Optional[int] = None
|
||||
"""File size, if known"""
|
||||
file_path: Optional[str] = None
|
||||
|
|
|
|||
|
|
@ -17,10 +17,12 @@ class MessageEntity(TelegramObject):
|
|||
"""
|
||||
|
||||
type: str
|
||||
"""Type of the entity. Can be mention (@username), hashtag, cashtag, bot_command, url, email,
|
||||
phone_number, bold (bold text), italic (italic text), code (monowidth string), pre
|
||||
(monowidth block), text_link (for clickable text URLs), text_mention (for users without
|
||||
usernames)"""
|
||||
"""Type of the entity. Can be 'mention' (@username), 'hashtag' (#hashtag), 'cashtag' ($USD),
|
||||
'bot_command' (/start@jobs_bot), 'url' (https://telegram.org), 'email'
|
||||
(do-not-reply@telegram.org), 'phone_number' (+1-212-555-0123), 'bold' (bold text), 'italic'
|
||||
(italic text), 'underline' (underlined text), 'strikethrough' (strikethrough text), 'code'
|
||||
(monowidth string), 'pre' (monowidth block), 'text_link' (for clickable text URLs),
|
||||
'text_mention' (for users without usernames)"""
|
||||
offset: int
|
||||
"""Offset in UTF-16 code units to the start of the entity"""
|
||||
length: int
|
||||
|
|
|
|||
|
|
@ -12,7 +12,10 @@ class PassportFile(TelegramObject):
|
|||
"""
|
||||
|
||||
file_id: str
|
||||
"""Identifier for this file"""
|
||||
"""Identifier for this file, which can be used to download or reuse the file"""
|
||||
file_unique_id: str
|
||||
"""Unique identifier for this file, which is supposed to be the same over time and for
|
||||
different bots. Can't be used to download or reuse the file."""
|
||||
file_size: int
|
||||
"""File size"""
|
||||
file_date: int
|
||||
|
|
|
|||
|
|
@ -13,7 +13,10 @@ class PhotoSize(TelegramObject):
|
|||
"""
|
||||
|
||||
file_id: str
|
||||
"""Identifier for this file"""
|
||||
"""Identifier for this file, which can be used to download or reuse the file"""
|
||||
file_unique_id: str
|
||||
"""Unique identifier for this file, which is supposed to be the same over time and for
|
||||
different bots. Can't be used to download or reuse the file."""
|
||||
width: int
|
||||
"""Photo width"""
|
||||
height: int
|
||||
|
|
|
|||
|
|
@ -7,8 +7,8 @@ from pydantic import Field
|
|||
from .base import TelegramObject
|
||||
|
||||
if TYPE_CHECKING: # pragma: no cover
|
||||
from .user import User
|
||||
from .shipping_address import ShippingAddress
|
||||
from .user import User
|
||||
|
||||
|
||||
class ShippingQuery(TelegramObject):
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ from typing import TYPE_CHECKING, Optional
|
|||
from .base import TelegramObject
|
||||
|
||||
if TYPE_CHECKING: # pragma: no cover
|
||||
from .photo_size import PhotoSize
|
||||
from .mask_position import MaskPosition
|
||||
from .photo_size import PhotoSize
|
||||
|
||||
|
||||
class Sticker(TelegramObject):
|
||||
|
|
@ -17,7 +17,10 @@ class Sticker(TelegramObject):
|
|||
"""
|
||||
|
||||
file_id: str
|
||||
"""Identifier for this file"""
|
||||
"""Identifier for this file, which can be used to download or reuse the file"""
|
||||
file_unique_id: str
|
||||
"""Unique identifier for this file, which is supposed to be the same over time and for
|
||||
different bots. Can't be used to download or reuse the file."""
|
||||
width: int
|
||||
"""Sticker width"""
|
||||
height: int
|
||||
|
|
|
|||
|
|
@ -16,7 +16,10 @@ class Video(TelegramObject):
|
|||
"""
|
||||
|
||||
file_id: str
|
||||
"""Identifier for this file"""
|
||||
"""Identifier for this file, which can be used to download or reuse the file"""
|
||||
file_unique_id: str
|
||||
"""Unique identifier for this file, which is supposed to be the same over time and for
|
||||
different bots. Can't be used to download or reuse the file."""
|
||||
width: int
|
||||
"""Video width as defined by sender"""
|
||||
height: int
|
||||
|
|
|
|||
|
|
@ -16,7 +16,10 @@ class VideoNote(TelegramObject):
|
|||
"""
|
||||
|
||||
file_id: str
|
||||
"""Identifier for this file"""
|
||||
"""Identifier for this file, which can be used to download or reuse the file"""
|
||||
file_unique_id: str
|
||||
"""Unique identifier for this file, which is supposed to be the same over time and for
|
||||
different bots. Can't be used to download or reuse the file."""
|
||||
length: int
|
||||
"""Video width and height (diameter of the video message) as defined by sender"""
|
||||
duration: int
|
||||
|
|
|
|||
|
|
@ -13,7 +13,10 @@ class Voice(TelegramObject):
|
|||
"""
|
||||
|
||||
file_id: str
|
||||
"""Identifier for this file"""
|
||||
"""Identifier for this file, which can be used to download or reuse the file"""
|
||||
file_unique_id: str
|
||||
"""Unique identifier for this file, which is supposed to be the same over time and for
|
||||
different bots. Can't be used to download or reuse the file."""
|
||||
duration: int
|
||||
"""Duration of the audio in seconds as defined by sender"""
|
||||
mime_type: Optional[str] = None
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue