mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-09 09:22:03 +00:00
Clean bot.py
This commit is contained in:
parent
4c0d89d25a
commit
62e7bd1cbe
1 changed files with 4 additions and 32 deletions
|
|
@ -3,16 +3,16 @@ import json
|
|||
|
||||
import aiohttp
|
||||
|
||||
from aiogram.types.chat_member import ChatMember
|
||||
from aiogram.types.file import File
|
||||
from aiogram.types.user_profile_photos import UserProfilePhotos
|
||||
from aiogram.types.webhook_info import WebhookInfo
|
||||
from . import api
|
||||
from .api import ApiMethods
|
||||
from .types.chat import Chat
|
||||
from .types.chat_member import ChatMember
|
||||
from .types.file import File
|
||||
from .types.message import Message
|
||||
from .types.update import Update
|
||||
from .types.user import User
|
||||
from .types.user_profile_photos import UserProfilePhotos
|
||||
from .types.webhook_info import WebhookInfo
|
||||
from .utils.payload import generate_payload
|
||||
|
||||
|
||||
|
|
@ -79,15 +79,6 @@ class AIOGramBot:
|
|||
return self.prepare_object(User.de_json(raw))
|
||||
|
||||
async def get_updates(self, offset=None, limit=None, timeout=None, allowed_updates=None):
|
||||
"""
|
||||
offset Integer Optional Identifier of the first update to be returned. Must be greater by one than the highest among the identifiers of previously received updates. By default, updates starting with the earliest unconfirmed update are returned. An update is considered confirmed as soon as getUpdates is called with an offset higher than its update_id. The negative offset can be specified to retrieve updates starting from -offset update from the end of the updates queue. All previous updates will forgotten.
|
||||
limit Integer Optional Limits the number of updates to be retrieved. Values between 1—100 are accepted. Defaults to 100.
|
||||
timeout Integer Optional Timeout in seconds for long polling. Defaults to 0, i.e. usual short polling. Should be positive, short polling should be used for testing purposes only.
|
||||
allowed_updates Array of String Optional List the types of updates you want your bot to receive. For example, specify [“message”, “edited_channel_post”, “callback_query”] to only receive updates of these types. See Update for a complete list of available update types. Specify an empty list to receive all updates regardless of type (default). If not specified, the previous setting will be used.
|
||||
|
||||
Please note that this parameter doesn't affect updates created before the call to the getUpdates, so unwanted updates may be received for a short period of time.
|
||||
:return:
|
||||
"""
|
||||
payload = generate_payload(**locals())
|
||||
raw = await self.request(ApiMethods.GET_UPDATES, payload)
|
||||
return [self.prepare_object(Update.de_json(raw_update)) for raw_update in raw]
|
||||
|
|
@ -114,17 +105,6 @@ class AIOGramBot:
|
|||
|
||||
async def send_message(self, chat_id, text, parse_mode=None, disable_web_page_preview=None,
|
||||
disable_notification=None, reply_to_message_id=None, reply_markup=None):
|
||||
"""
|
||||
chat_id Integer or String Yes Unique identifier for the target chat or username of the target channel (in the format @channelusername)
|
||||
text String Yes Text of the message to be sent
|
||||
parse_mode String Optional Send Markdown or HTML, if you want Telegram apps to show bold, italic, fixed-width text or inline URLs in your bot's message.
|
||||
disable_web_page_preview Boolean Optional Disables link previews for links in this message
|
||||
disable_notification Boolean Optional Sends the message silently. iOS users will not receive a notification, Android users will receive a notification with no sound.
|
||||
reply_to_message_id Integer Optional If the message is a reply, ID of the original message
|
||||
reply_markup InlineKeyboardMarkup or ReplyKeyboardMarkup or ReplyKeyboardRemove or ForceReply Optional Additional interface options. A JSON-serialized object for an inline keyboard, custom reply keyboard, instructions to remove reply keyboard or to force a reply from the user.
|
||||
:return:
|
||||
"""
|
||||
|
||||
if reply_markup and hasattr(reply_markup, 'to_json'):
|
||||
reply_markup = json.dumps(reply_markup.to_json())
|
||||
|
||||
|
|
@ -136,14 +116,6 @@ class AIOGramBot:
|
|||
return self.prepare_object(Message.de_json(message))
|
||||
|
||||
async def forward_message(self, chat_id, from_chat_id, message_id, disable_notification=None):
|
||||
"""
|
||||
chat_id Integer or String Yes Unique identifier for the target chat or username of the target channel (in the format @channelusername)
|
||||
from_chat_id Integer or String Yes Unique identifier for the chat where the original message was sent (or channel username in the format @channelusername)
|
||||
disable_notification Boolean Optional Sends the message silently. iOS users will not receive a notification, Android users will receive a notification with no sound.
|
||||
message_id Integer Yes Message identifier in the chat specified in from_chat_id
|
||||
:return:
|
||||
"""
|
||||
|
||||
payload = generate_payload(**locals())
|
||||
message = await self.request(ApiMethods.FORWARD_MESSAGE, payload)
|
||||
return self.prepare_object(Message.de_json(message))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue