Re-generate bot class, remove deprecated methods

This commit is contained in:
Alex Root Junior 2022-11-21 00:45:44 +02:00
parent a86298ea7d
commit 9557db424a
No known key found for this signature in database
GPG key ID: 074C1D455EBEA4AC
12 changed files with 2691 additions and 3027 deletions

View file

@ -5,9 +5,6 @@ Types
Here is list of all available enums:
{% for title, group in groups.items() %}
{{ title }}
{{ title|header('=') }}
.. toctree::
:maxdepth: 1
{% for name in group %}

File diff suppressed because it is too large Load diff

View file

@ -36,7 +36,6 @@ from .get_chat import GetChat
from .get_chat_administrators import GetChatAdministrators
from .get_chat_member import GetChatMember
from .get_chat_member_count import GetChatMemberCount
from .get_chat_members_count import GetChatMembersCount
from .get_chat_menu_button import GetChatMenuButton
from .get_custom_emoji_stickers import GetCustomEmojiStickers
from .get_file import GetFile
@ -49,7 +48,6 @@ from .get_sticker_set import GetStickerSet
from .get_updates import GetUpdates
from .get_user_profile_photos import GetUserProfilePhotos
from .get_webhook_info import GetWebhookInfo
from .kick_chat_member import KickChatMember
from .leave_chat import LeaveChat
from .log_out import LogOut
from .pin_chat_message import PinChatMessage
@ -131,7 +129,6 @@ __all__ = (
"GetUserProfilePhotos",
"GetFile",
"BanChatMember",
"KickChatMember",
"UnbanChatMember",
"RestrictChatMember",
"PromoteChatMember",
@ -156,7 +153,6 @@ __all__ = (
"GetChat",
"GetChatAdministrators",
"GetChatMemberCount",
"GetChatMembersCount",
"GetChatMember",
"SetChatStickerSet",
"DeleteChatStickerSet",

View file

@ -1,30 +0,0 @@
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 GetChatMembersCount(TelegramMethod[int]):
"""
.. warning:
Renamed from :code:`getChatMembersCount` in 5.3 bot API version and can be removed in near future
Use this method to get the number of members in a chat. Returns *Int* on success.
Source: https://core.telegram.org/bots/api#getchatmembercount
"""
__returning__ = int
chat_id: Union[int, str]
"""Unique identifier for the target chat or username of the target supergroup or channel (in the format :code:`@channelusername`)"""
def build_request(self, bot: Bot) -> Request:
data: Dict[str, Any] = self.dict()
return Request(method="getChatMembersCount", data=data)

View file

@ -1,37 +0,0 @@
from __future__ import annotations
import datetime
from typing import TYPE_CHECKING, Any, Dict, Optional, Union
from .base import Request, TelegramMethod
if TYPE_CHECKING:
from ..client.bot import Bot
class KickChatMember(TelegramMethod[bool]):
"""
.. warning:
Renamed from :code:`kickChatMember` in 5.3 bot API version and can be removed in near future
Use this method to ban a user in a group, a supergroup or a channel. In the case of supergroups and channels, the user will not be able to return to the chat on their own using invite links, etc., unless `unbanned <https://core.telegram.org/bots/api#unbanchatmember>`_ first. The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. Returns :code:`True` on success.
Source: https://core.telegram.org/bots/api#banchatmember
"""
__returning__ = bool
chat_id: Union[int, str]
"""Unique identifier for the target group or username of the target supergroup or channel (in the format :code:`@channelusername`)"""
user_id: int
"""Unique identifier of the target user"""
until_date: Optional[Union[datetime.datetime, datetime.timedelta, int]] = None
"""Date when the user will be unbanned, unix time. If user is banned for more than 366 days or less than 30 seconds from the current time they are considered to be banned forever. Applied for supergroups and channels only."""
revoke_messages: Optional[bool] = None
"""Pass :code:`True` to delete all messages from the chat for the user that is being removed. If :code:`False`, the user will be able to see messages in the group that were sent before the user was removed. Always :code:`True` for supergroups and channels."""
def build_request(self, bot: Bot) -> Request:
data: Dict[str, Any] = self.dict()
return Request(method="kickChatMember", data=data)

View file

@ -1,9 +1,10 @@
#####
Enums
Types
#####
Here is list of all available enums:
.. toctree::
:maxdepth: 1

View file

@ -11,73 +11,73 @@ Available methods
.. toctree::
:maxdepth: 1
get_me
set_chat_photo
unpin_all_chat_messages
answer_callback_query
approve_chat_join_request
ban_chat_member
ban_chat_sender_chat
close
close_forum_topic
set_chat_title
copy_message
create_chat_invite_link
create_forum_topic
decline_chat_join_request
delete_chat_photo
set_chat_sticker_set
delete_chat_sticker_set
delete_forum_topic
delete_my_commands
edit_chat_invite_link
edit_forum_topic
edit_message_live_location
export_chat_invite_link
forward_message
get_chat
approve_chat_join_request
get_user_profile_photos
create_forum_topic
create_chat_invite_link
delete_my_commands
stop_message_live_location
get_chat_member
promote_chat_member
set_chat_administrator_custom_title
leave_chat
send_dice
send_contact
set_my_commands
send_voice
send_animation
send_venue
send_document
send_media_group
get_chat_menu_button
send_audio
send_photo
export_chat_invite_link
send_chat_action
ban_chat_sender_chat
unban_chat_member
delete_chat_sticker_set
decline_chat_join_request
delete_forum_topic
get_my_default_administrator_rights
unpin_chat_message
get_forum_topic_icon_stickers
reopen_forum_topic
copy_message
restrict_chat_member
send_location
set_chat_description
edit_chat_invite_link
send_video_note
get_file
get_my_commands
close
set_chat_permissions
pin_chat_message
set_my_default_administrator_rights
edit_forum_topic
send_message
set_chat_menu_button
revoke_chat_invite_link
edit_message_live_location
unpin_all_forum_topic_messages
send_poll
ban_chat_member
get_chat_member_count
log_out
unban_chat_sender_chat
answer_callback_query
get_chat_administrators
get_chat_member
get_chat_member_count
get_chat_menu_button
get_file
get_forum_topic_icon_stickers
get_me
get_my_commands
get_my_default_administrator_rights
get_user_profile_photos
leave_chat
log_out
pin_chat_message
promote_chat_member
reopen_forum_topic
restrict_chat_member
revoke_chat_invite_link
send_animation
send_audio
send_chat_action
send_contact
send_dice
send_document
send_location
send_media_group
send_message
send_photo
send_poll
send_venue
send_video
send_video_note
send_voice
set_chat_administrator_custom_title
set_chat_description
set_chat_menu_button
set_chat_permissions
set_chat_photo
set_chat_sticker_set
set_chat_title
set_my_commands
set_my_default_administrator_rights
stop_message_live_location
unban_chat_member
unban_chat_sender_chat
unpin_all_chat_messages
unpin_all_forum_topic_messages
unpin_chat_message
Payments
========
@ -86,8 +86,8 @@ Payments
:maxdepth: 1
answer_pre_checkout_query
create_invoice_link
answer_shipping_query
create_invoice_link
send_invoice
Stickers
@ -96,15 +96,15 @@ Stickers
.. toctree::
:maxdepth: 1
add_sticker_to_set
create_new_sticker_set
delete_sticker_from_set
get_custom_emoji_stickers
get_sticker_set
create_new_sticker_set
send_sticker
upload_sticker_file
set_sticker_set_thumb
add_sticker_to_set
set_sticker_position_in_set
delete_sticker_from_set
set_sticker_set_thumb
upload_sticker_file
Games
=====
@ -113,8 +113,8 @@ Games
:maxdepth: 1
get_game_high_scores
set_game_score
send_game
set_game_score
Getting updates
===============
@ -122,10 +122,10 @@ Getting updates
.. toctree::
:maxdepth: 1
delete_webhook
get_updates
get_webhook_info
set_webhook
get_updates
delete_webhook
Telegram Passport
=================
@ -141,11 +141,11 @@ Updating messages
.. toctree::
:maxdepth: 1
delete_message
edit_message_caption
edit_message_media
delete_message
edit_message_text
edit_message_reply_markup
edit_message_text
stop_poll
Inline mode
@ -154,5 +154,5 @@ Inline mode
.. toctree::
:maxdepth: 1
answer_web_app_query
answer_inline_query
answer_web_app_query

View file

@ -11,35 +11,35 @@ Inline mode
.. toctree::
:maxdepth: 1
input_invoice_message_content
inline_query_result_document
input_message_content
inline_query_result_cached_document
inline_query_result_contact
inline_query_result_cached_gif
inline_query_result_location
input_venue_message_content
chosen_inline_result
inline_query
inline_query_result
inline_query_result_cached_mpeg4_gif
inline_query_result_game
inline_query_result_cached_sticker
inline_query_result_gif
inline_query_result_cached_voice
inline_query_result_cached_video
input_location_message_content
input_text_message_content
inline_query_result_cached_audio
inline_query_result_video
inline_query_result_article
inline_query_result_audio
inline_query_result_cached_audio
inline_query_result_cached_document
inline_query_result_cached_gif
inline_query_result_cached_mpeg4_gif
inline_query_result_cached_photo
inline_query
inline_query_result_venue
inline_query_result_photo
input_contact_message_content
inline_query_result_cached_sticker
inline_query_result_cached_video
inline_query_result_cached_voice
inline_query_result_contact
inline_query_result_document
inline_query_result_game
inline_query_result_gif
inline_query_result_location
inline_query_result_mpeg4_gif
inline_query_result_photo
inline_query_result_venue
inline_query_result_video
inline_query_result_voice
input_contact_message_content
input_invoice_message_content
input_location_message_content
input_message_content
input_text_message_content
input_venue_message_content
sent_web_app_message
Available types
@ -48,83 +48,83 @@ Available types
.. toctree::
:maxdepth: 1
chat_administrator_rights
proximity_alert_triggered
animation
audio
bot_command
bot_command_scope
bot_command_scope_all_chat_administrators
bot_command_scope_all_group_chats
bot_command_scope_all_private_chats
input_media_photo
message_entity
message
bot_command_scope_chat
forum_topic_reopened
reply_keyboard_remove
video
poll_option
login_url
location
bot_command_scope_chat_administrators
bot_command_scope_chat_member
bot_command_scope_default
callback_query
chat
chat_administrator_rights
chat_invite_link
chat_join_request
chat_location
chat_member_administrator
menu_button_default
web_app_data
chat_member
user
file
poll_answer
chat_member_administrator
chat_member_banned
chat_member_left
chat_member_member
chat_member_owner
chat_member_restricted
chat_member_updated
keyboard_button_poll_type
chat_permissions
poll
chat_member_banned
venue
video_chat_participants_invited
response_parameters
menu_button_web_app
force_reply
chat_member_left
bot_command_scope_default
input_media_audio
keyboard_button
video_chat_ended
inline_keyboard_button
callback_query
bot_command_scope_all_group_chats
user_profile_photos
chat_invite_link
input_media
chat_photo
chat_join_request
bot_command_scope_chat_administrators
forum_topic_created
bot_command_scope
bot_command
document
reply_keyboard_markup
chat_member_member
photo_size
bot_command_scope_chat_member
voice
input_file
input_media_animation
video_note
video_chat_started
message_id
audio
menu_button
input_media_document
dice
message_auto_delete_timer_changed
bot_command_scope_all_chat_administrators
web_app_info
contact
animation
input_media_video
dice
document
file
force_reply
forum_topic
forum_topic_closed
forum_topic_created
forum_topic_reopened
inline_keyboard_button
inline_keyboard_markup
video_chat_scheduled
chat_member_owner
chat
input_file
input_media
input_media_animation
input_media_audio
input_media_document
input_media_photo
input_media_video
keyboard_button
keyboard_button_poll_type
location
login_url
menu_button
menu_button_commands
menu_button_default
menu_button_web_app
message
message_auto_delete_timer_changed
message_entity
message_id
photo_size
poll
poll_answer
poll_option
proximity_alert_triggered
reply_keyboard_markup
reply_keyboard_remove
response_parameters
user
user_profile_photos
venue
video
video_chat_ended
video_chat_participants_invited
video_chat_scheduled
video_chat_started
video_note
voice
web_app_data
web_app_info
Telegram Passport
=================
@ -132,20 +132,20 @@ Telegram Passport
.. toctree::
:maxdepth: 1
passport_data
passport_element_error_reverse_side
passport_element_error_data_field
passport_element_error_selfie
passport_element_error
passport_element_error_unspecified
passport_element_error_file
passport_element_error_translation_files
encrypted_passport_element
passport_file
passport_element_error_front_side
passport_element_error_files
encrypted_credentials
encrypted_passport_element
passport_data
passport_element_error
passport_element_error_data_field
passport_element_error_file
passport_element_error_files
passport_element_error_front_side
passport_element_error_reverse_side
passport_element_error_selfie
passport_element_error_translation_file
passport_element_error_translation_files
passport_element_error_unspecified
passport_file
Getting updates
===============
@ -162,9 +162,9 @@ Stickers
.. toctree::
:maxdepth: 1
sticker_set
mask_position
sticker
sticker_set
Payments
========
@ -172,14 +172,14 @@ Payments
.. toctree::
:maxdepth: 1
pre_checkout_query
shipping_query
labeled_price
invoice
shipping_option
successful_payment
labeled_price
order_info
pre_checkout_query
shipping_address
shipping_option
shipping_query
successful_payment
Games
=====
@ -187,6 +187,6 @@ Games
.. toctree::
:maxdepth: 1
game_high_score
game
callback_game
game
game_high_score

8
poetry.lock generated
View file

@ -176,7 +176,7 @@ uvloop = ["uvloop (>=0.15.2)"]
[[package]]
name = "butcher"
version = "0.1.2"
version = "0.1.5"
description = "Code-generation utility for aiogram v3 core developers"
category = "dev"
optional = false
@ -199,8 +199,8 @@ requests = "^2.28.1"
[package.source]
type = "git"
url = "https://github.com/aiogram/butcher.git"
reference = "v0.1.2"
resolved_reference = "34314e50fca149c84a1fe8a96a89bf6fa57cb6c6"
reference = "v0.1.5"
resolved_reference = "2693f8559b9496974b48b3f6762f8acd0c666268"
[[package]]
name = "certifi"
@ -1353,7 +1353,7 @@ redis = ["redis"]
[metadata]
lock-version = "1.1"
python-versions = "^3.8"
content-hash = "b569f50be7eb1211b0301b48dd079ac4a3902bb46b585c765a447ffed284e399"
content-hash = "234adf05496b157948ddafcd9cfefeee9b0c151a207bb0404c3db8f8dcb02f94"
[metadata.files]
about-time = [

View file

@ -97,7 +97,7 @@ toml = "^0.10.2"
pre-commit = "^2.20.0"
packaging = "^21.3"
typing-extensions = "^4.3.0"
butcher = { git = "https://github.com/aiogram/butcher.git", rev = "v0.1.2", python = "3.10" }
butcher = { git = "https://github.com/aiogram/butcher.git", rev = "v0.1.5", python = "3.10" }
[tool.poetry.extras]

View file

@ -1,24 +0,0 @@
import pytest
from aiogram.methods import GetChatMembersCount, Request
from tests.mocked_bot import MockedBot
pytestmark = pytest.mark.asyncio
class TestGetChatMembersCount:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(GetChatMembersCount, ok=True, result=42)
response: int = await GetChatMembersCount(chat_id=-42)
request: Request = bot.get_request()
assert request.method == "getChatMembersCount"
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(GetChatMembersCount, ok=True, result=42)
response: int = await bot.get_chat_members_count(chat_id=-42)
request: Request = bot.get_request()
assert request.method == "getChatMembersCount"
assert response == prepare_result.result

View file

@ -1,24 +0,0 @@
import pytest
from aiogram.methods import KickChatMember, Request
from tests.mocked_bot import MockedBot
pytestmark = pytest.mark.asyncio
class TestKickChatMember:
async def test_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(KickChatMember, ok=True, result=True)
response: bool = await KickChatMember(chat_id=-42, user_id=42)
request: Request = bot.get_request()
assert request.method == "kickChatMember"
assert response == prepare_result.result
async def test_bot_method(self, bot: MockedBot):
prepare_result = bot.add_result_for(KickChatMember, ok=True, result=True)
response: bool = await bot.kick_chat_member(chat_id=-42, user_id=42)
request: Request = bot.get_request()
assert request.method == "kickChatMember"
assert response == prepare_result.result