mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-09 09:22:03 +00:00
Optimize parameters parser
This commit is contained in:
parent
74b09b5c4b
commit
050b3ba113
3 changed files with 11 additions and 128 deletions
|
|
@ -64,7 +64,13 @@ def _compose_data(params, files=None):
|
||||||
|
|
||||||
if params:
|
if params:
|
||||||
for key, value in params.items():
|
for key, value in params.items():
|
||||||
data.add_field(key, str(value))
|
if isinstance(value, dict):
|
||||||
|
value = json.dumps(value)
|
||||||
|
elif hasattr(value, 'to_json'):
|
||||||
|
value = json.dumps(value.to_json())
|
||||||
|
else:
|
||||||
|
value = str(value)
|
||||||
|
data.add_field(key, value)
|
||||||
|
|
||||||
if files:
|
if files:
|
||||||
for key, f in files.items():
|
for key, f in files.items():
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ import io
|
||||||
import aiohttp
|
import aiohttp
|
||||||
|
|
||||||
from . import api
|
from . import api
|
||||||
from ..utils import json
|
|
||||||
from ..utils.payload import generate_payload
|
from ..utils.payload import generate_payload
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -166,17 +165,12 @@ class BaseBot:
|
||||||
async def send_photo(self, chat_id, photo, caption=None, disable_notification=None, reply_to_message_id=None,
|
async def send_photo(self, chat_id, photo, caption=None, disable_notification=None, reply_to_message_id=None,
|
||||||
reply_markup=None) -> dict:
|
reply_markup=None) -> dict:
|
||||||
_message_type = 'photo'
|
_message_type = 'photo'
|
||||||
if reply_markup and isinstance(reply_markup, dict):
|
|
||||||
reply_markup = json.dumps(reply_markup)
|
|
||||||
|
|
||||||
payload = generate_payload(**locals(), exclude=[_message_type])
|
payload = generate_payload(**locals(), exclude=[_message_type])
|
||||||
return await self.send_file(_message_type, api.Methods.SEND_PHOTO, photo, payload)
|
return await self.send_file(_message_type, api.Methods.SEND_PHOTO, photo, payload)
|
||||||
|
|
||||||
async def send_audio(self, chat_id, audio, caption=None, duration=None, performer=None, title=None,
|
async def send_audio(self, chat_id, audio, caption=None, duration=None, performer=None, title=None,
|
||||||
disable_notification=None, reply_to_message_id=None, reply_markup=None) -> dict:
|
disable_notification=None, reply_to_message_id=None, reply_markup=None) -> dict:
|
||||||
_message_type = 'audio'
|
_message_type = 'audio'
|
||||||
if reply_markup and isinstance(reply_markup, dict):
|
|
||||||
reply_markup = json.dumps(reply_markup)
|
|
||||||
|
|
||||||
payload = generate_payload(**locals(), exclude=[_message_type])
|
payload = generate_payload(**locals(), exclude=[_message_type])
|
||||||
return await self.send_file(_message_type, api.Methods.SEND_AUDIO, audio, payload)
|
return await self.send_file(_message_type, api.Methods.SEND_AUDIO, audio, payload)
|
||||||
|
|
@ -184,18 +178,12 @@ class BaseBot:
|
||||||
async def send_document(self, chat_id, document, caption=None, disable_notification=None, reply_to_message_id=None,
|
async def send_document(self, chat_id, document, caption=None, disable_notification=None, reply_to_message_id=None,
|
||||||
reply_markup=None) -> dict:
|
reply_markup=None) -> dict:
|
||||||
_message_type = 'document'
|
_message_type = 'document'
|
||||||
if reply_markup and isinstance(reply_markup, dict):
|
|
||||||
reply_markup = json.dumps(reply_markup)
|
|
||||||
|
|
||||||
payload = generate_payload(**locals(), exclude=[_message_type])
|
payload = generate_payload(**locals(), exclude=[_message_type])
|
||||||
return await self.send_file(_message_type, api.Methods.SEND_DOCUMENT, document, payload)
|
return await self.send_file(_message_type, api.Methods.SEND_DOCUMENT, document, payload)
|
||||||
|
|
||||||
async def send_sticker(self, chat_id, sticker, disable_notification=None, reply_to_message_id=None,
|
async def send_sticker(self, chat_id, sticker, disable_notification=None, reply_to_message_id=None,
|
||||||
reply_markup=None) -> dict:
|
reply_markup=None) -> dict:
|
||||||
_message_type = 'sticker'
|
_message_type = 'sticker'
|
||||||
if reply_markup and isinstance(reply_markup, dict):
|
|
||||||
reply_markup = json.dumps(reply_markup)
|
|
||||||
|
|
||||||
payload = generate_payload(**locals(), exclude=[_message_type])
|
payload = generate_payload(**locals(), exclude=[_message_type])
|
||||||
return await self.send_file(_message_type, api.Methods.SEND_STICKER, sticker, payload)
|
return await self.send_file(_message_type, api.Methods.SEND_STICKER, sticker, payload)
|
||||||
|
|
||||||
|
|
@ -211,17 +199,12 @@ class BaseBot:
|
||||||
async def create_new_sticker_set(self, name: str, title: str, png_sticker, emojis: str, is_mask: bool = None,
|
async def create_new_sticker_set(self, name: str, title: str, png_sticker, emojis: str, is_mask: bool = None,
|
||||||
mask_position: dict or str = None) -> bool:
|
mask_position: dict or str = None) -> bool:
|
||||||
_message_type = 'png_sticker'
|
_message_type = 'png_sticker'
|
||||||
if mask_position and isinstance(mask_position, dict):
|
|
||||||
mask_position = json.dumps(mask_position)
|
|
||||||
|
|
||||||
payload = generate_payload(**locals(), exclude=[_message_type])
|
payload = generate_payload(**locals(), exclude=[_message_type])
|
||||||
return await self.send_file(_message_type, api.Methods.CREATE_NEW_STICKER_SET, png_sticker, payload)
|
return await self.send_file(_message_type, api.Methods.CREATE_NEW_STICKER_SET, png_sticker, payload)
|
||||||
|
|
||||||
async def add_sticker_to_set(self, user_id: int, name: str, png_sticker, emojis: str,
|
async def add_sticker_to_set(self, user_id: int, name: str, png_sticker, emojis: str,
|
||||||
mask_position: str or dict) -> bool:
|
mask_position: str or dict) -> bool:
|
||||||
_message_type = 'png_sticker'
|
_message_type = 'png_sticker'
|
||||||
if mask_position and isinstance(mask_position, dict):
|
|
||||||
mask_position = json.dumps(mask_position)
|
|
||||||
payload = generate_payload(**locals(), exclude=[_message_type])
|
payload = generate_payload(**locals(), exclude=[_message_type])
|
||||||
|
|
||||||
return await self.send_file(_message_type, api.Methods.ADD_STICKER_TO_SET, png_sticker, payload)
|
return await self.send_file(_message_type, api.Methods.ADD_STICKER_TO_SET, png_sticker, payload)
|
||||||
|
|
@ -237,51 +220,33 @@ class BaseBot:
|
||||||
async def send_video(self, chat_id, video, duration=None, width=None, height=None, caption=None,
|
async def send_video(self, chat_id, video, duration=None, width=None, height=None, caption=None,
|
||||||
disable_notification=None, reply_to_message_id=None, reply_markup=None) -> dict:
|
disable_notification=None, reply_to_message_id=None, reply_markup=None) -> dict:
|
||||||
_message_type = 'video'
|
_message_type = 'video'
|
||||||
if reply_markup and isinstance(reply_markup, dict):
|
|
||||||
reply_markup = json.dumps(reply_markup)
|
|
||||||
|
|
||||||
payload = generate_payload(**locals(), exclude=[_message_type])
|
payload = generate_payload(**locals(), exclude=[_message_type])
|
||||||
return await self.send_file(_message_type, api.Methods.SEND_VIDEO, video, payload)
|
return await self.send_file(_message_type, api.Methods.SEND_VIDEO, video, payload)
|
||||||
|
|
||||||
async def send_voice(self, chat_id, voice, caption=None, duration=None, disable_notification=None,
|
async def send_voice(self, chat_id, voice, caption=None, duration=None, disable_notification=None,
|
||||||
reply_to_message_id=None, reply_markup=None) -> dict:
|
reply_to_message_id=None, reply_markup=None) -> dict:
|
||||||
_message_type = 'voice'
|
_message_type = 'voice'
|
||||||
if reply_markup and isinstance(reply_markup, dict):
|
|
||||||
reply_markup = json.dumps(reply_markup)
|
|
||||||
|
|
||||||
payload = generate_payload(**locals(), exclude=[_message_type])
|
payload = generate_payload(**locals(), exclude=[_message_type])
|
||||||
return await self.send_file(_message_type, api.Methods.SEND_VOICE, voice, payload)
|
return await self.send_file(_message_type, api.Methods.SEND_VOICE, voice, payload)
|
||||||
|
|
||||||
async def send_video_note(self, chat_id, video_note, duration=None, length=None, disable_notification=None,
|
async def send_video_note(self, chat_id, video_note, duration=None, length=None, disable_notification=None,
|
||||||
reply_to_message_id=None, reply_markup=None) -> dict:
|
reply_to_message_id=None, reply_markup=None) -> dict:
|
||||||
_message_type = 'video_note'
|
_message_type = 'video_note'
|
||||||
if reply_markup and isinstance(reply_markup, dict):
|
|
||||||
reply_markup = json.dumps(reply_markup)
|
|
||||||
|
|
||||||
payload = generate_payload(**locals(), exclude=[_message_type])
|
payload = generate_payload(**locals(), exclude=[_message_type])
|
||||||
return await self.send_file(_message_type, api.Methods.SEND_VIDEO_NOTE, video_note, payload)
|
return await self.send_file(_message_type, api.Methods.SEND_VIDEO_NOTE, video_note, payload)
|
||||||
|
|
||||||
async def send_location(self, chat_id, latitude, longitude, disable_notification=None, reply_to_message_id=None,
|
async def send_location(self, chat_id, latitude, longitude, disable_notification=None, reply_to_message_id=None,
|
||||||
reply_markup=None) -> dict:
|
reply_markup=None) -> dict:
|
||||||
if reply_markup and isinstance(reply_markup, dict):
|
|
||||||
reply_markup = json.dumps(reply_markup)
|
|
||||||
|
|
||||||
payload = generate_payload(**locals())
|
payload = generate_payload(**locals())
|
||||||
return await self.request(api.Methods.SEND_LOCATION, payload)
|
return await self.request(api.Methods.SEND_LOCATION, payload)
|
||||||
|
|
||||||
async def send_venue(self, chat_id, latitude, longitude, title, address, foursquare_id, disable_notification=None,
|
async def send_venue(self, chat_id, latitude, longitude, title, address, foursquare_id, disable_notification=None,
|
||||||
reply_to_message_id=None, reply_markup=None) -> dict:
|
reply_to_message_id=None, reply_markup=None) -> dict:
|
||||||
if reply_markup and isinstance(reply_markup, dict):
|
|
||||||
reply_markup = json.dumps(reply_markup)
|
|
||||||
|
|
||||||
payload = generate_payload(**locals())
|
payload = generate_payload(**locals())
|
||||||
return await self.request(api.Methods.SEND_VENUE, payload)
|
return await self.request(api.Methods.SEND_VENUE, payload)
|
||||||
|
|
||||||
async def send_contact(self, chat_id, phone_number, first_name, last_name=None, disable_notification=None,
|
async def send_contact(self, chat_id, phone_number, first_name, last_name=None, disable_notification=None,
|
||||||
reply_to_message_id=None, reply_markup=None) -> dict:
|
reply_to_message_id=None, reply_markup=None) -> dict:
|
||||||
if reply_markup and isinstance(reply_markup, dict):
|
|
||||||
reply_markup = json.dumps(reply_markup)
|
|
||||||
|
|
||||||
payload = generate_payload(**locals())
|
payload = generate_payload(**locals())
|
||||||
return await self.request(api.Methods.SEND_CONTACT, payload)
|
return await self.request(api.Methods.SEND_CONTACT, payload)
|
||||||
|
|
||||||
|
|
@ -322,19 +287,10 @@ class BaseBot:
|
||||||
return await self.request(api.Methods.EXPORT_CHAT_INVITE_LINK, payload)
|
return await self.request(api.Methods.EXPORT_CHAT_INVITE_LINK, payload)
|
||||||
|
|
||||||
async def set_chat_photo(self, chat_id: int, photo) -> bool:
|
async def set_chat_photo(self, chat_id: int, photo) -> bool:
|
||||||
|
_message_type = 'photo'
|
||||||
payload = generate_payload(**locals(), exclude=['photo'])
|
payload = generate_payload(**locals(), exclude=['photo'])
|
||||||
|
|
||||||
if isinstance(photo, str):
|
return await self.send_file(_message_type, api.Methods.SET_CHAT_PHOTO, photo, payload)
|
||||||
payload['photo'] = photo
|
|
||||||
req = self.request(api.Methods.SET_CHAT_PHOTO, payload)
|
|
||||||
elif isinstance(photo, io.IOBase):
|
|
||||||
data = {'photo': photo.read()}
|
|
||||||
req = self.request(api.Methods.SET_CHAT_PHOTO, payload, data)
|
|
||||||
else:
|
|
||||||
data = {'photo': photo}
|
|
||||||
req = self.request(api.Methods.SET_CHAT_PHOTO, payload, data)
|
|
||||||
|
|
||||||
return await req
|
|
||||||
|
|
||||||
async def delete_chat_photo(self, chat_id: int) -> bool:
|
async def delete_chat_photo(self, chat_id: int) -> bool:
|
||||||
payload = generate_payload(**locals())
|
payload = generate_payload(**locals())
|
||||||
|
|
@ -392,17 +348,11 @@ class BaseBot:
|
||||||
|
|
||||||
async def answer_inline_query(self, inline_query_id, results, cache_time=None, is_personal=None, next_offset=None,
|
async def answer_inline_query(self, inline_query_id, results, cache_time=None, is_personal=None, next_offset=None,
|
||||||
switch_pm_text=None, switch_pm_parameter=None) -> bool:
|
switch_pm_text=None, switch_pm_parameter=None) -> bool:
|
||||||
if isinstance(results, list):
|
|
||||||
results = json.dumps([item for item in results])
|
|
||||||
|
|
||||||
payload = generate_payload(**locals())
|
payload = generate_payload(**locals())
|
||||||
return await self.request(api.Methods.ANSWER_INLINE_QUERY, payload)
|
return await self.request(api.Methods.ANSWER_INLINE_QUERY, payload)
|
||||||
|
|
||||||
async def edit_message_text(self, text, chat_id=None, message_id=None, inline_message_id=None, parse_mode=None,
|
async def edit_message_text(self, text, chat_id=None, message_id=None, inline_message_id=None, parse_mode=None,
|
||||||
disable_web_page_preview=None, reply_markup=None) -> dict or bool:
|
disable_web_page_preview=None, reply_markup=None) -> dict or bool:
|
||||||
if reply_markup and isinstance(reply_markup, dict):
|
|
||||||
reply_markup = json.dumps(reply_markup)
|
|
||||||
|
|
||||||
payload = generate_payload(**locals())
|
payload = generate_payload(**locals())
|
||||||
raw = await self.request(api.Methods.EDIT_MESSAGE_TEXT, payload)
|
raw = await self.request(api.Methods.EDIT_MESSAGE_TEXT, payload)
|
||||||
if raw is True:
|
if raw is True:
|
||||||
|
|
@ -411,9 +361,6 @@ class BaseBot:
|
||||||
|
|
||||||
async def edit_message_caption(self, chat_id=None, message_id=None, inline_message_id=None, caption=None,
|
async def edit_message_caption(self, chat_id=None, message_id=None, inline_message_id=None, caption=None,
|
||||||
reply_markup=None) -> dict or bool:
|
reply_markup=None) -> dict or bool:
|
||||||
if reply_markup and isinstance(reply_markup, dict):
|
|
||||||
reply_markup = json.dumps(reply_markup)
|
|
||||||
|
|
||||||
payload = generate_payload(**locals())
|
payload = generate_payload(**locals())
|
||||||
raw = await self.request(api.Methods.EDIT_MESSAGE_CAPTION, payload)
|
raw = await self.request(api.Methods.EDIT_MESSAGE_CAPTION, payload)
|
||||||
if raw is True:
|
if raw is True:
|
||||||
|
|
@ -422,9 +369,6 @@ class BaseBot:
|
||||||
|
|
||||||
async def edit_message_reply_markup(self, chat_id=None, message_id=None, inline_message_id=None,
|
async def edit_message_reply_markup(self, chat_id=None, message_id=None, inline_message_id=None,
|
||||||
reply_markup=None) -> dict or bool:
|
reply_markup=None) -> dict or bool:
|
||||||
if reply_markup and isinstance(reply_markup, dict):
|
|
||||||
reply_markup = json.dumps(reply_markup)
|
|
||||||
|
|
||||||
payload = generate_payload(**locals())
|
payload = generate_payload(**locals())
|
||||||
raw = await self.request(api.Methods.EDIT_MESSAGE_REPLY_MARKUP, payload)
|
raw = await self.request(api.Methods.EDIT_MESSAGE_REPLY_MARKUP, payload)
|
||||||
if raw is True:
|
if raw is True:
|
||||||
|
|
@ -442,21 +386,12 @@ class BaseBot:
|
||||||
need_shipping_address: bool = None, is_flexible: bool = None,
|
need_shipping_address: bool = None, is_flexible: bool = None,
|
||||||
disable_notification: bool = None, reply_to_message_id: int = None,
|
disable_notification: bool = None, reply_to_message_id: int = None,
|
||||||
reply_markup: dict or str = None) -> dict:
|
reply_markup: dict or str = None) -> dict:
|
||||||
if reply_markup and isinstance(reply_markup, dict):
|
|
||||||
reply_markup = json.dumps(reply_markup)
|
|
||||||
|
|
||||||
if isinstance(prices, list):
|
|
||||||
prices = json.dumps(prices)
|
|
||||||
|
|
||||||
payload_ = generate_payload(**locals())
|
payload_ = generate_payload(**locals())
|
||||||
|
|
||||||
return await self.request(api.Methods.SEND_INVOICE, payload_)
|
return await self.request(api.Methods.SEND_INVOICE, payload_)
|
||||||
|
|
||||||
async def answer_shipping_query(self, shipping_query_id: str, ok: bool,
|
async def answer_shipping_query(self, shipping_query_id: str, ok: bool,
|
||||||
shipping_options: [dict] = None, error_message: str = None) -> bool:
|
shipping_options: [dict] = None, error_message: str = None) -> bool:
|
||||||
if shipping_options and isinstance(shipping_options, list):
|
|
||||||
shipping_options = json.dumps(shipping_options)
|
|
||||||
|
|
||||||
payload = generate_payload(**locals())
|
payload = generate_payload(**locals())
|
||||||
|
|
||||||
return await self.request(api.Methods.ANSWER_SHIPPING_QUERY, payload)
|
return await self.request(api.Methods.ANSWER_SHIPPING_QUERY, payload)
|
||||||
|
|
@ -469,9 +404,6 @@ class BaseBot:
|
||||||
async def send_game(self, chat_id: int, game_short_name: str, disable_notification: bool = None,
|
async def send_game(self, chat_id: int, game_short_name: str, disable_notification: bool = None,
|
||||||
reply_to_message_id: int = None,
|
reply_to_message_id: int = None,
|
||||||
reply_markup: dict = None) -> dict:
|
reply_markup: dict = None) -> dict:
|
||||||
if reply_markup and isinstance(reply_markup, dict):
|
|
||||||
reply_markup = json.dumps(reply_markup)
|
|
||||||
|
|
||||||
payload = generate_payload(**locals())
|
payload = generate_payload(**locals())
|
||||||
|
|
||||||
return await self.request(api.Methods.SEND_GAME, payload)
|
return await self.request(api.Methods.SEND_GAME, payload)
|
||||||
|
|
@ -481,10 +413,7 @@ class BaseBot:
|
||||||
inline_message_id: str = None) -> dict or bool:
|
inline_message_id: str = None) -> dict or bool:
|
||||||
payload = generate_payload(**locals())
|
payload = generate_payload(**locals())
|
||||||
|
|
||||||
raw = self.request(api.Methods.SET_GAME_SCORE, payload)
|
return self.request(api.Methods.SET_GAME_SCORE, payload)
|
||||||
if raw is True:
|
|
||||||
return raw
|
|
||||||
return raw
|
|
||||||
|
|
||||||
async def get_game_high_scores(self, user_id: int, chat_id: int = None, message_id: int = None,
|
async def get_game_high_scores(self, user_id: int, chat_id: int = None, message_id: int = None,
|
||||||
inline_message_id: str = None) -> dict:
|
inline_message_id: str = None) -> dict:
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
import datetime
|
import datetime
|
||||||
from ..utils import json
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from .base import BaseBot
|
from .base import BaseBot
|
||||||
from .. import types
|
from .. import types
|
||||||
|
from ..utils import json
|
||||||
|
|
||||||
|
|
||||||
class Bot(BaseBot):
|
class Bot(BaseBot):
|
||||||
|
|
@ -130,9 +130,6 @@ class Bot(BaseBot):
|
||||||
:param reply_markup: :class:`aiogram.types.Serializable`
|
:param reply_markup: :class:`aiogram.types.Serializable`
|
||||||
:return: :class:`aiogram.types.Message`
|
:return: :class:`aiogram.types.Message`
|
||||||
"""
|
"""
|
||||||
if reply_markup and hasattr(reply_markup, 'to_json'):
|
|
||||||
reply_markup = json.dumps(reply_markup.to_json())
|
|
||||||
|
|
||||||
if hasattr(reply_to_message_id, 'message_id'):
|
if hasattr(reply_to_message_id, 'message_id'):
|
||||||
reply_to_message_id = reply_to_message_id.message_id
|
reply_to_message_id = reply_to_message_id.message_id
|
||||||
|
|
||||||
|
|
@ -166,9 +163,6 @@ class Bot(BaseBot):
|
||||||
:param reply_markup: :class:`aiogram.types.Serializable`
|
:param reply_markup: :class:`aiogram.types.Serializable`
|
||||||
:return: :class:`aiogram.types.Message`
|
:return: :class:`aiogram.types.Message`
|
||||||
"""
|
"""
|
||||||
if reply_markup and hasattr(reply_markup, 'to_json'):
|
|
||||||
reply_markup = json.dumps(reply_markup.to_json())
|
|
||||||
|
|
||||||
if hasattr(reply_to_message_id, 'message_id'):
|
if hasattr(reply_to_message_id, 'message_id'):
|
||||||
reply_to_message_id = reply_to_message_id.message_id
|
reply_to_message_id = reply_to_message_id.message_id
|
||||||
|
|
||||||
|
|
@ -193,9 +187,6 @@ class Bot(BaseBot):
|
||||||
:param reply_markup: :class:`aiogram.types.Serializable`
|
:param reply_markup: :class:`aiogram.types.Serializable`
|
||||||
:return: :class:`aiogram.types.Message`
|
:return: :class:`aiogram.types.Message`
|
||||||
"""
|
"""
|
||||||
if reply_markup and hasattr(reply_markup, 'to_json'):
|
|
||||||
reply_markup = json.dumps(reply_markup.to_json())
|
|
||||||
|
|
||||||
if hasattr(reply_to_message_id, 'message_id'):
|
if hasattr(reply_to_message_id, 'message_id'):
|
||||||
reply_to_message_id = reply_to_message_id.message_id
|
reply_to_message_id = reply_to_message_id.message_id
|
||||||
|
|
||||||
|
|
@ -216,9 +207,6 @@ class Bot(BaseBot):
|
||||||
:param reply_markup: :class:`aiogram.types.Serializable`
|
:param reply_markup: :class:`aiogram.types.Serializable`
|
||||||
:return: :class:`aiogram.types.Message`
|
:return: :class:`aiogram.types.Message`
|
||||||
"""
|
"""
|
||||||
if reply_markup and hasattr(reply_markup, 'to_json'):
|
|
||||||
reply_markup = json.dumps(reply_markup.to_json())
|
|
||||||
|
|
||||||
if hasattr(reply_to_message_id, 'message_id'):
|
if hasattr(reply_to_message_id, 'message_id'):
|
||||||
reply_to_message_id = reply_to_message_id.message_id
|
reply_to_message_id = reply_to_message_id.message_id
|
||||||
|
|
||||||
|
|
@ -238,9 +226,6 @@ class Bot(BaseBot):
|
||||||
:param reply_markup: :class:`aiogram.types.Serializable`
|
:param reply_markup: :class:`aiogram.types.Serializable`
|
||||||
:return: :class:`aiogram.types.Message`
|
:return: :class:`aiogram.types.Message`
|
||||||
"""
|
"""
|
||||||
if reply_markup and hasattr(reply_markup, 'to_json'):
|
|
||||||
reply_markup = json.dumps(reply_markup.to_json())
|
|
||||||
|
|
||||||
if hasattr(reply_to_message_id, 'message_id'):
|
if hasattr(reply_to_message_id, 'message_id'):
|
||||||
reply_to_message_id = reply_to_message_id.message_id
|
reply_to_message_id = reply_to_message_id.message_id
|
||||||
|
|
||||||
|
|
@ -282,9 +267,6 @@ class Bot(BaseBot):
|
||||||
:param mask_position:
|
:param mask_position:
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
if isinstance(mask_position, types.MaskPosition):
|
|
||||||
mask_position = json.dumps(mask_position.to_json())
|
|
||||||
|
|
||||||
return await super(Bot, self).create_new_sticker_set(name, title, png_sticker, emojis, is_mask, mask_position)
|
return await super(Bot, self).create_new_sticker_set(name, title, png_sticker, emojis, is_mask, mask_position)
|
||||||
|
|
||||||
async def add_sticker_to_set(self, user_id: int, name: str, png_sticker, emojis: str,
|
async def add_sticker_to_set(self, user_id: int, name: str, png_sticker, emojis: str,
|
||||||
|
|
@ -299,8 +281,6 @@ class Bot(BaseBot):
|
||||||
:param mask_position:
|
:param mask_position:
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
if isinstance(mask_position, types.MaskPosition):
|
|
||||||
mask_position = json.dumps(mask_position.to_json())
|
|
||||||
return await super(Bot, self).add_sticker_to_set(user_id, name, png_sticker, emojis, mask_position)
|
return await super(Bot, self).add_sticker_to_set(user_id, name, png_sticker, emojis, mask_position)
|
||||||
|
|
||||||
async def set_sticker_position_in_set(self, sticker: str, position: int) -> bool:
|
async def set_sticker_position_in_set(self, sticker: str, position: int) -> bool:
|
||||||
|
|
@ -339,9 +319,6 @@ class Bot(BaseBot):
|
||||||
:param reply_markup: :class:`aiogram.types.Serializable`
|
:param reply_markup: :class:`aiogram.types.Serializable`
|
||||||
:return: :class:`aiogram.types.Message`
|
:return: :class:`aiogram.types.Message`
|
||||||
"""
|
"""
|
||||||
if reply_markup and hasattr(reply_markup, 'to_json'):
|
|
||||||
reply_markup = json.dumps(reply_markup.to_json())
|
|
||||||
|
|
||||||
if hasattr(reply_to_message_id, 'message_id'):
|
if hasattr(reply_to_message_id, 'message_id'):
|
||||||
reply_to_message_id = reply_to_message_id.message_id
|
reply_to_message_id = reply_to_message_id.message_id
|
||||||
|
|
||||||
|
|
@ -366,9 +343,6 @@ class Bot(BaseBot):
|
||||||
:param reply_markup: :class:`aiogram.types.Serializable`
|
:param reply_markup: :class:`aiogram.types.Serializable`
|
||||||
:return: :class:`aiogram.types.Message`
|
:return: :class:`aiogram.types.Message`
|
||||||
"""
|
"""
|
||||||
if reply_markup and hasattr(reply_markup, 'to_json'):
|
|
||||||
reply_markup = json.dumps(reply_markup.to_json())
|
|
||||||
|
|
||||||
if hasattr(reply_to_message_id, 'message_id'):
|
if hasattr(reply_to_message_id, 'message_id'):
|
||||||
reply_to_message_id = reply_to_message_id.message_id
|
reply_to_message_id = reply_to_message_id.message_id
|
||||||
|
|
||||||
|
|
@ -390,9 +364,6 @@ class Bot(BaseBot):
|
||||||
:param reply_markup: :class:`aiogram.types.Serializable`
|
:param reply_markup: :class:`aiogram.types.Serializable`
|
||||||
:return: :class:`aiogram.types.Message`
|
:return: :class:`aiogram.types.Message`
|
||||||
"""
|
"""
|
||||||
if reply_markup and hasattr(reply_markup, 'to_json'):
|
|
||||||
reply_markup = json.dumps(reply_markup.to_json())
|
|
||||||
|
|
||||||
if hasattr(reply_to_message_id, 'message_id'):
|
if hasattr(reply_to_message_id, 'message_id'):
|
||||||
reply_to_message_id = reply_to_message_id.message_id
|
reply_to_message_id = reply_to_message_id.message_id
|
||||||
|
|
||||||
|
|
@ -413,9 +384,6 @@ class Bot(BaseBot):
|
||||||
:param reply_markup: :class:`aiogram.types.Serializable`
|
:param reply_markup: :class:`aiogram.types.Serializable`
|
||||||
:return: :class:`aiogram.types.Message`
|
:return: :class:`aiogram.types.Message`
|
||||||
"""
|
"""
|
||||||
if reply_markup and hasattr(reply_markup, 'to_json'):
|
|
||||||
reply_markup = json.dumps(reply_markup.to_json())
|
|
||||||
|
|
||||||
if hasattr(reply_to_message_id, 'message_id'):
|
if hasattr(reply_to_message_id, 'message_id'):
|
||||||
reply_to_message_id = reply_to_message_id.message_id
|
reply_to_message_id = reply_to_message_id.message_id
|
||||||
|
|
||||||
|
|
@ -438,9 +406,6 @@ class Bot(BaseBot):
|
||||||
:param reply_markup: :class:`aiogram.types.Serializable`
|
:param reply_markup: :class:`aiogram.types.Serializable`
|
||||||
:return: :class:`aiogram.types.Message`
|
:return: :class:`aiogram.types.Message`
|
||||||
"""
|
"""
|
||||||
if reply_markup and hasattr(reply_markup, 'to_json'):
|
|
||||||
reply_markup = json.dumps(reply_markup.to_json())
|
|
||||||
|
|
||||||
if hasattr(reply_to_message_id, 'message_id'):
|
if hasattr(reply_to_message_id, 'message_id'):
|
||||||
reply_to_message_id = reply_to_message_id.message_id
|
reply_to_message_id = reply_to_message_id.message_id
|
||||||
|
|
||||||
|
|
@ -462,9 +427,6 @@ class Bot(BaseBot):
|
||||||
:param reply_markup: :class:`aiogram.types.Serializable`
|
:param reply_markup: :class:`aiogram.types.Serializable`
|
||||||
:return: :class:`aiogram.types.Message`
|
:return: :class:`aiogram.types.Message`
|
||||||
"""
|
"""
|
||||||
if reply_markup and hasattr(reply_markup, 'to_json'):
|
|
||||||
reply_markup = json.dumps(reply_markup.to_json())
|
|
||||||
|
|
||||||
if hasattr(reply_to_message_id, 'message_id'):
|
if hasattr(reply_to_message_id, 'message_id'):
|
||||||
reply_to_message_id = reply_to_message_id.message_id
|
reply_to_message_id = reply_to_message_id.message_id
|
||||||
|
|
||||||
|
|
@ -762,9 +724,6 @@ class Bot(BaseBot):
|
||||||
:param reply_markup:
|
:param reply_markup:
|
||||||
:return: :class:`aiogram.types.Message` or bool
|
:return: :class:`aiogram.types.Message` or bool
|
||||||
"""
|
"""
|
||||||
if reply_markup and hasattr(reply_markup, 'to_json'):
|
|
||||||
reply_markup = json.dumps(reply_markup.to_json())
|
|
||||||
|
|
||||||
if hasattr(message_id, 'message_id'):
|
if hasattr(message_id, 'message_id'):
|
||||||
message_id = message_id.message_id
|
message_id = message_id.message_id
|
||||||
|
|
||||||
|
|
@ -790,9 +749,6 @@ class Bot(BaseBot):
|
||||||
:param reply_markup:
|
:param reply_markup:
|
||||||
:return: :class:`aiogram.types.Message` or bool
|
:return: :class:`aiogram.types.Message` or bool
|
||||||
"""
|
"""
|
||||||
if reply_markup and hasattr(reply_markup, 'to_json'):
|
|
||||||
reply_markup = json.dumps(reply_markup.to_json())
|
|
||||||
|
|
||||||
if hasattr(message_id, 'message_id'):
|
if hasattr(message_id, 'message_id'):
|
||||||
message_id = message_id.message_id
|
message_id = message_id.message_id
|
||||||
|
|
||||||
|
|
@ -816,9 +772,6 @@ class Bot(BaseBot):
|
||||||
:param reply_markup:
|
:param reply_markup:
|
||||||
:return: :class:`aiogram.types.Message` or bool
|
:return: :class:`aiogram.types.Message` or bool
|
||||||
"""
|
"""
|
||||||
if reply_markup and hasattr(reply_markup, 'to_json'):
|
|
||||||
reply_markup = json.dumps(reply_markup.to_json())
|
|
||||||
|
|
||||||
if hasattr(message_id, 'message_id'):
|
if hasattr(message_id, 'message_id'):
|
||||||
message_id = message_id.message_id
|
message_id = message_id.message_id
|
||||||
|
|
||||||
|
|
@ -879,8 +832,6 @@ class Bot(BaseBot):
|
||||||
:param reply_markup: :class:`aiogram.types.InlineReplyMarkup`
|
:param reply_markup: :class:`aiogram.types.InlineReplyMarkup`
|
||||||
:return: :class:`aiogram.types.Message`
|
:return: :class:`aiogram.types.Message`
|
||||||
"""
|
"""
|
||||||
if reply_markup and hasattr(reply_markup, 'to_json'):
|
|
||||||
reply_markup = json.dumps(reply_markup.to_json())
|
|
||||||
prices = json.dumps([item.to_json() for item in prices])
|
prices = json.dumps([item.to_json() for item in prices])
|
||||||
|
|
||||||
message = await super(Bot, self).send_invoice(chat_id, title, description, payload, provider_token,
|
message = await super(Bot, self).send_invoice(chat_id, title, description, payload, provider_token,
|
||||||
|
|
@ -935,9 +886,6 @@ class Bot(BaseBot):
|
||||||
:param reply_markup: :class:`aiogram.types.InlineKeyboardMarkup`
|
:param reply_markup: :class:`aiogram.types.InlineKeyboardMarkup`
|
||||||
:return: :class:`aiogram.types.Message`
|
:return: :class:`aiogram.types.Message`
|
||||||
"""
|
"""
|
||||||
if reply_markup and hasattr(reply_markup, 'to_json'):
|
|
||||||
reply_markup = json.dumps(reply_markup.to_json())
|
|
||||||
|
|
||||||
message = await super(Bot, self).send_game(chat_id, game_short_name, disable_notification, reply_to_message_id,
|
message = await super(Bot, self).send_game(chat_id, game_short_name, disable_notification, reply_to_message_id,
|
||||||
reply_markup)
|
reply_markup)
|
||||||
return self.prepare_object(types.Message.de_json(message))
|
return self.prepare_object(types.Message.de_json(message))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue