mirror of
https://github.com/eternnoir/pyTelegramBotAPI.git
synced 2023-08-10 21:12:57 +03:00
Merge pull request #1199 from SwissCorePy/master
added InputInvoiceMessageContent and tgs_sticker support
This commit is contained in:
commit
0f0ce934dc
@ -2104,8 +2104,9 @@ class TeleBot:
|
||||
|
||||
def create_new_sticker_set(
|
||||
self, user_id: int, name: str, title: str,
|
||||
png_sticker: Union[Any, str],
|
||||
emojis: str,
|
||||
png_sticker: Union[Any, str],
|
||||
tgs_sticker: Union[Any, str],
|
||||
contains_masks: Optional[bool]=None,
|
||||
mask_position: Optional[types.MaskPosition]=None) -> bool:
|
||||
"""
|
||||
@ -2115,29 +2116,38 @@ class TeleBot:
|
||||
:param user_id:
|
||||
:param name:
|
||||
:param title:
|
||||
:param png_sticker:
|
||||
:param emojis:
|
||||
:param png_sticker:
|
||||
:param tgs_sticker:
|
||||
:param contains_masks:
|
||||
:param mask_position:
|
||||
:return:
|
||||
"""
|
||||
return apihelper.create_new_sticker_set(self.token, user_id, name, title, png_sticker, emojis,
|
||||
contains_masks, mask_position)
|
||||
|
||||
return apihelper.create_new_sticker_set(
|
||||
self.token, user_id, name, title, emojis, png_sticker, tgs_sticker,
|
||||
contains_masks, mask_position)
|
||||
|
||||
|
||||
def add_sticker_to_set(
|
||||
self, user_id: int, name: str, png_sticker: Union[Any, str],
|
||||
emojis: str, mask_position: Optional[types.MaskPosition]=None) -> bool:
|
||||
self, user_id: int, name: str, emojis: str,
|
||||
png_sticker: Optional[Union[Any, str]]=None,
|
||||
tgs_sticker: Optional[Union[Any, str]]=None,
|
||||
mask_position: Optional[types.MaskPosition]=None) -> bool:
|
||||
"""
|
||||
Use this method to add a new sticker to a set created by the bot. Returns True on success.
|
||||
Use this method to add a new sticker to a set created by the bot.
|
||||
It's required to pass `png_sticker` or `tgs_sticker`.
|
||||
Returns True on success.
|
||||
:param user_id:
|
||||
:param name:
|
||||
:param png_sticker:
|
||||
:param emojis:
|
||||
:param png_sticker: Required if `tgs_sticker` is None
|
||||
:param tgs_sticker: Required if `png_sticker` is None
|
||||
:param mask_position:
|
||||
:return:
|
||||
"""
|
||||
return apihelper.add_sticker_to_set(self.token, user_id, name, png_sticker, emojis, mask_position)
|
||||
return apihelper.add_sticker_to_set(
|
||||
self.token, user_id, name, emojis, png_sticker, tgs_sticker, mask_position)
|
||||
|
||||
|
||||
def set_sticker_position_in_set(self, sticker: str, position: int) -> bool:
|
||||
"""
|
||||
|
@ -245,7 +245,7 @@ def send_message(
|
||||
payload['connect-timeout'] = timeout
|
||||
if entities:
|
||||
payload['entities'] = json.dumps(types.MessageEntity.to_list_of_dicts(entities))
|
||||
if allow_sending_without_reply:
|
||||
if allow_sending_without_reply is not None:
|
||||
payload['allow_sending_without_reply'] = allow_sending_without_reply
|
||||
return _make_request(token, method_url, params=payload, method='post')
|
||||
|
||||
@ -422,7 +422,7 @@ def send_dice(
|
||||
payload['reply_markup'] = _convert_markup(reply_markup)
|
||||
if timeout:
|
||||
payload['connect-timeout'] = timeout
|
||||
if 'allow_sending_without_reply':
|
||||
if allow_sending_without_reply is not None:
|
||||
payload['allow_sending_without_reply'] = allow_sending_without_reply
|
||||
return _make_request(token, method_url, params=payload)
|
||||
|
||||
@ -455,7 +455,7 @@ def send_photo(
|
||||
payload['connect-timeout'] = timeout
|
||||
if caption_entities:
|
||||
payload['caption_entities'] = json.dumps(types.MessageEntity.to_list_of_dicts(caption_entities))
|
||||
if allow_sending_without_reply:
|
||||
if allow_sending_without_reply is not None:
|
||||
payload['allow_sending_without_reply'] = allow_sending_without_reply
|
||||
return _make_request(token, method_url, params=payload, files=files, method='post')
|
||||
|
||||
@ -473,7 +473,7 @@ def send_media_group(
|
||||
payload['reply_to_message_id'] = reply_to_message_id
|
||||
if timeout:
|
||||
payload['connect-timeout'] = timeout
|
||||
if allow_sending_without_reply:
|
||||
if allow_sending_without_reply is not None:
|
||||
payload['allow_sending_without_reply'] = allow_sending_without_reply
|
||||
return _make_request(
|
||||
token, method_url, params=payload,
|
||||
@ -499,7 +499,7 @@ def send_location(
|
||||
payload['proximity_alert_radius'] = proximity_alert_radius
|
||||
if reply_to_message_id:
|
||||
payload['reply_to_message_id'] = reply_to_message_id
|
||||
if allow_sending_without_reply:
|
||||
if allow_sending_without_reply is not None:
|
||||
payload['allow_sending_without_reply'] = allow_sending_without_reply
|
||||
if reply_markup:
|
||||
payload['reply_markup'] = _convert_markup(reply_markup)
|
||||
@ -573,7 +573,7 @@ def send_venue(
|
||||
payload['reply_markup'] = _convert_markup(reply_markup)
|
||||
if timeout:
|
||||
payload['connect-timeout'] = timeout
|
||||
if allow_sending_without_reply:
|
||||
if allow_sending_without_reply is not None:
|
||||
payload['allow_sending_without_reply'] = allow_sending_without_reply
|
||||
if google_place_id:
|
||||
payload['google_place_id'] = google_place_id
|
||||
@ -600,7 +600,7 @@ def send_contact(
|
||||
payload['reply_markup'] = _convert_markup(reply_markup)
|
||||
if timeout:
|
||||
payload['connect-timeout'] = timeout
|
||||
if allow_sending_without_reply:
|
||||
if allow_sending_without_reply is not None:
|
||||
payload['allow_sending_without_reply'] = allow_sending_without_reply
|
||||
return _make_request(token, method_url, params=payload)
|
||||
|
||||
@ -653,7 +653,7 @@ def send_video(token, chat_id, data, duration=None, caption=None, reply_to_messa
|
||||
payload['height'] = height
|
||||
if caption_entities:
|
||||
payload['caption_entities'] = json.dumps(types.MessageEntity.to_list_of_dicts(caption_entities))
|
||||
if allow_sending_without_reply:
|
||||
if allow_sending_without_reply is not None:
|
||||
payload['allow_sending_without_reply'] = allow_sending_without_reply
|
||||
return _make_request(token, method_url, params=payload, files=files, method='post')
|
||||
|
||||
@ -693,7 +693,7 @@ def send_animation(
|
||||
payload['thumb'] = thumb
|
||||
if caption_entities:
|
||||
payload['caption_entities'] = json.dumps(types.MessageEntity.to_list_of_dicts(caption_entities))
|
||||
if allow_sending_without_reply:
|
||||
if allow_sending_without_reply is not None:
|
||||
payload['allow_sending_without_reply'] = allow_sending_without_reply
|
||||
return _make_request(token, method_url, params=payload, files=files, method='post')
|
||||
|
||||
@ -724,7 +724,7 @@ def send_voice(token, chat_id, voice, caption=None, duration=None, reply_to_mess
|
||||
payload['connect-timeout'] = timeout
|
||||
if caption_entities:
|
||||
payload['caption_entities'] = json.dumps(types.MessageEntity.to_list_of_dicts(caption_entities))
|
||||
if allow_sending_without_reply:
|
||||
if allow_sending_without_reply is not None:
|
||||
payload['allow_sending_without_reply'] = allow_sending_without_reply
|
||||
return _make_request(token, method_url, params=payload, files=files, method='post')
|
||||
|
||||
@ -760,7 +760,7 @@ def send_video_note(token, chat_id, data, duration=None, length=None, reply_to_m
|
||||
files = {'thumb': thumb}
|
||||
else:
|
||||
payload['thumb'] = thumb
|
||||
if allow_sending_without_reply:
|
||||
if allow_sending_without_reply is not None:
|
||||
payload['allow_sending_without_reply'] = allow_sending_without_reply
|
||||
return _make_request(token, method_url, params=payload, files=files, method='post')
|
||||
|
||||
@ -803,14 +803,14 @@ def send_audio(token, chat_id, audio, caption=None, duration=None, performer=Non
|
||||
payload['thumb'] = thumb
|
||||
if caption_entities:
|
||||
payload['caption_entities'] = json.dumps(types.MessageEntity.to_list_of_dicts(caption_entities))
|
||||
if allow_sending_without_reply:
|
||||
if allow_sending_without_reply is not None:
|
||||
payload['allow_sending_without_reply'] = allow_sending_without_reply
|
||||
return _make_request(token, method_url, params=payload, files=files, method='post')
|
||||
|
||||
|
||||
def send_data(token, chat_id, data, data_type, reply_to_message_id=None, reply_markup=None, parse_mode=None,
|
||||
disable_notification=None, timeout=None, caption=None, thumb=None, caption_entities=None,
|
||||
allow_sending_without_reply=None):
|
||||
allow_sending_without_reply=None, disable_content_type_detection=None):
|
||||
method_url = get_method_by_type(data_type)
|
||||
payload = {'chat_id': chat_id}
|
||||
files = None
|
||||
@ -840,8 +840,10 @@ def send_data(token, chat_id, data, data_type, reply_to_message_id=None, reply_m
|
||||
payload['thumb'] = thumb
|
||||
if caption_entities:
|
||||
payload['caption_entities'] = json.dumps(types.MessageEntity.to_list_of_dicts(caption_entities))
|
||||
if allow_sending_without_reply:
|
||||
if allow_sending_without_reply is not None:
|
||||
payload['allow_sending_without_reply'] = allow_sending_without_reply
|
||||
if method_url == 'sendDocument' and disable_content_type_detection is not None:
|
||||
payload['disable_content_type_detection'] = disable_content_type_detection
|
||||
return _make_request(token, method_url, params=payload, files=files, method='post')
|
||||
|
||||
|
||||
@ -1157,7 +1159,7 @@ def send_game(
|
||||
payload['reply_markup'] = _convert_markup(reply_markup)
|
||||
if timeout:
|
||||
payload['connect-timeout'] = timeout
|
||||
if allow_sending_without_reply:
|
||||
if allow_sending_without_reply is not None:
|
||||
payload['allow_sending_without_reply'] = allow_sending_without_reply
|
||||
return _make_request(token, method_url, params=payload)
|
||||
|
||||
@ -1290,7 +1292,7 @@ def send_invoice(
|
||||
payload['provider_data'] = provider_data
|
||||
if timeout:
|
||||
payload['connect-timeout'] = timeout
|
||||
if allow_sending_without_reply:
|
||||
if allow_sending_without_reply is not None:
|
||||
payload['allow_sending_without_reply'] = allow_sending_without_reply
|
||||
return _make_request(token, method_url, params=payload)
|
||||
|
||||
@ -1388,15 +1390,17 @@ def upload_sticker_file(token, user_id, png_sticker):
|
||||
|
||||
|
||||
def create_new_sticker_set(
|
||||
token, user_id, name, title, png_sticker, emojis,
|
||||
token, user_id, name, title, emojis, png_sticker, tgs_sticker,
|
||||
contains_masks=None, mask_position=None):
|
||||
method_url = 'createNewStickerSet'
|
||||
payload = {'user_id': user_id, 'name': name, 'title': title, 'emojis': emojis}
|
||||
stype = 'png_sticker' if png_sticker else 'tgs_sticker'
|
||||
sticker = png_sticker or tgs_sticker
|
||||
files = None
|
||||
if not util.is_string(png_sticker):
|
||||
files = {'png_sticker': png_sticker}
|
||||
if not util.is_string(sticker):
|
||||
files = {stype: sticker}
|
||||
else:
|
||||
payload['png_sticker'] = png_sticker
|
||||
payload[stype] = sticker
|
||||
if contains_masks is not None:
|
||||
payload['contains_masks'] = contains_masks
|
||||
if mask_position:
|
||||
@ -1404,14 +1408,16 @@ def create_new_sticker_set(
|
||||
return _make_request(token, method_url, params=payload, files=files, method='post')
|
||||
|
||||
|
||||
def add_sticker_to_set(token, user_id, name, png_sticker, emojis, mask_position):
|
||||
def add_sticker_to_set(token, user_id, name, emojis, png_sticker, tgs_sticker, mask_position):
|
||||
method_url = 'addStickerToSet'
|
||||
payload = {'user_id': user_id, 'name': name, 'emojis': emojis}
|
||||
stype = 'png_sticker' if png_sticker else 'tgs_sticker'
|
||||
sticker = png_sticker or tgs_sticker
|
||||
files = None
|
||||
if not util.is_string(png_sticker):
|
||||
files = {'png_sticker': png_sticker}
|
||||
if not util.is_string(sticker):
|
||||
files = {stype: sticker}
|
||||
else:
|
||||
payload['png_sticker'] = png_sticker
|
||||
payload[stype] = sticker
|
||||
if mask_position:
|
||||
payload['mask_position'] = mask_position.to_json()
|
||||
return _make_request(token, method_url, params=payload, files=files, method='post')
|
||||
|
190
telebot/types.py
190
telebot/types.py
@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import logging
|
||||
from typing import Dict, List, Union
|
||||
from typing import Dict, List, Optional, Union
|
||||
|
||||
try:
|
||||
import ujson as json
|
||||
@ -146,7 +146,7 @@ class ChatMemberUpdated(JsonDeserializable):
|
||||
self.date: int = date
|
||||
self.old_chat_member: ChatMember = old_chat_member
|
||||
self.new_chat_member: ChatMember = new_chat_member
|
||||
self.invite_link: Union[ChatInviteLink, None] = invite_link
|
||||
self.invite_link: Optional[ChatInviteLink] = invite_link
|
||||
|
||||
|
||||
class WebhookInfo(JsonDeserializable):
|
||||
@ -461,49 +461,49 @@ class Message(JsonDeserializable):
|
||||
self.from_user: User = from_user
|
||||
self.date: int = date
|
||||
self.chat: Chat = chat
|
||||
self.forward_from: Union[User, None] = None
|
||||
self.forward_from_chat: Union[Chat, None] = None
|
||||
self.forward_from_message_id: Union[int, None] = None
|
||||
self.forward_signature: Union[str, None] = None
|
||||
self.forward_sender_name: Union[str, None] = None
|
||||
self.forward_date: Union[int, None] = None
|
||||
self.reply_to_message: Union[Message, None] = None
|
||||
self.via_bot: Union[User, None] = None
|
||||
self.edit_date: Union[int, None] = None
|
||||
self.media_group_id: Union[str, None] = None
|
||||
self.author_signature: Union[str, None] = None
|
||||
self.text: Union[str, None] = None
|
||||
self.entities: Union[List[MessageEntity], None] = None
|
||||
self.caption_entities: Union[List[MessageEntity], None] = None
|
||||
self.audio: Union[Audio, None] = None
|
||||
self.document: Union[Document, None] = None
|
||||
self.photo: Union[List[PhotoSize], None] = None
|
||||
self.sticker: Union[Sticker, None] = None
|
||||
self.video: Union[Video, None] = None
|
||||
self.video_note: Union[VideoNote, None] = None
|
||||
self.voice: Union[Voice, None] = None
|
||||
self.caption: Union[str, None] = None
|
||||
self.contact: Union[Contact, None] = None
|
||||
self.location: Union[Location, None] = None
|
||||
self.venue: Union[Venue, None] = None
|
||||
self.animation: Union[Animation, None] = None
|
||||
self.dice: Union[Dice, None] = None
|
||||
self.new_chat_member: Union[User, None] = None # Deprecated since Bot API 3.0. Not processed anymore
|
||||
self.new_chat_members: Union[List[User], None] = None
|
||||
self.left_chat_member: Union[User, None] = None
|
||||
self.new_chat_title: Union[str, None] = None
|
||||
self.new_chat_photo: Union[List[PhotoSize], None] = None
|
||||
self.delete_chat_photo: Union[bool, None] = None
|
||||
self.group_chat_created: Union[bool, None] = None
|
||||
self.supergroup_chat_created: Union[bool, None] = None
|
||||
self.channel_chat_created: Union[bool, None] = None
|
||||
self.migrate_to_chat_id: Union[int, None] = None
|
||||
self.migrate_from_chat_id: Union[int, None] = None
|
||||
self.pinned_message: Union[Message, None] = None
|
||||
self.invoice: Union[Invoice, None] = None
|
||||
self.successful_payment: Union[SuccessfulPayment, None] = None
|
||||
self.connected_website: Union[str, None] = None
|
||||
self.reply_markup: Union[InlineKeyboardMarkup, None] = None
|
||||
self.forward_from: Optional[User] = None
|
||||
self.forward_from_chat: Optional[Chat] = None
|
||||
self.forward_from_message_id: Optional[int] = None
|
||||
self.forward_signature: Optional[str] = None
|
||||
self.forward_sender_name: Optional[str] = None
|
||||
self.forward_date: Optional[int] = None
|
||||
self.reply_to_message: Optional[Message] = None
|
||||
self.via_bot: Optional[User] = None
|
||||
self.edit_date: Optional[int] = None
|
||||
self.media_group_id: Optional[str] = None
|
||||
self.author_signature: Optional[str] = None
|
||||
self.text: Optional[str] = None
|
||||
self.entities: Optional[List[MessageEntity]] = None
|
||||
self.caption_entities: Optional[List[MessageEntity]] = None
|
||||
self.audio: Optional[Audio] = None
|
||||
self.document: Optional[Document] = None
|
||||
self.photo: Optional[List[PhotoSize]] = None
|
||||
self.sticker: Optional[Sticker] = None
|
||||
self.video: Optional[Video] = None
|
||||
self.video_note: Optional[VideoNote] = None
|
||||
self.voice: Optional[Voice] = None
|
||||
self.caption: Optional[str] = None
|
||||
self.contact: Optional[Contact] = None
|
||||
self.location: Optional[Location] = None
|
||||
self.venue: Optional[Venue] = None
|
||||
self.animation: Optional[Animation] = None
|
||||
self.dice: Optional[Dice] = None
|
||||
self.new_chat_member: Optional[User] = None # Deprecated since Bot API 3.0. Not processed anymore
|
||||
self.new_chat_members: Optional[List[User]] = None
|
||||
self.left_chat_member: Optional[User] = None
|
||||
self.new_chat_title: Optional[str] = None
|
||||
self.new_chat_photo: Optional[List[PhotoSize]] = None
|
||||
self.delete_chat_photo: Optional[bool] = None
|
||||
self.group_chat_created: Optional[bool] = None
|
||||
self.supergroup_chat_created: Optional[bool] = None
|
||||
self.channel_chat_created: Optional[bool] = None
|
||||
self.migrate_to_chat_id: Optional[int] = None
|
||||
self.migrate_from_chat_id: Optional[int] = None
|
||||
self.pinned_message: Optional[Message] = None
|
||||
self.invoice: Optional[Invoice] = None
|
||||
self.successful_payment: Optional[SuccessfulPayment] = None
|
||||
self.connected_website: Optional[str] = None
|
||||
self.reply_markup: Optional[InlineKeyboardMarkup] = None
|
||||
for key in options:
|
||||
setattr(self, key, options[key])
|
||||
self.json = json_string
|
||||
@ -649,11 +649,11 @@ class PhotoSize(JsonDeserializable):
|
||||
return cls(**obj)
|
||||
|
||||
def __init__(self, file_id, file_unique_id, width, height, file_size=None, **kwargs):
|
||||
self.file_size: int = file_size
|
||||
self.file_unique_id: str = file_unique_id
|
||||
self.height: int = height
|
||||
self.width: int = width
|
||||
self.file_id: str = file_id
|
||||
self.file_unique_id: str = file_unique_id
|
||||
self.width: int = width
|
||||
self.height: int = height
|
||||
self.file_size: int = file_size
|
||||
|
||||
|
||||
class Audio(JsonDeserializable):
|
||||
@ -1314,7 +1314,7 @@ class InputTextMessageContent(Dictionaryable):
|
||||
json_dict['parse_mode'] = self.parse_mode
|
||||
if self.entities:
|
||||
json_dict['entities'] = MessageEntity.to_list_of_dicts(self.entities)
|
||||
if self.disable_web_page_preview:
|
||||
if self.disable_web_page_preview is not None:
|
||||
json_dict['disable_web_page_preview'] = self.disable_web_page_preview
|
||||
return json_dict
|
||||
|
||||
@ -1387,6 +1387,73 @@ class InputContactMessageContent(Dictionaryable):
|
||||
return json_dict
|
||||
|
||||
|
||||
class InputInvoiceMessageContent(Dictionaryable):
|
||||
def __init__(self, title, description, payload, provider_token, currency, prices,
|
||||
max_tip_amount=None, suggested_tip_amounts=None, provider_data=None,
|
||||
photo_url=None, photo_size=None, photo_width=None, photo_height=None,
|
||||
need_name=None, need_phone_number=None, need_email=None, need_shipping_address=None,
|
||||
send_phone_number_to_provider=None, send_email_to_provider=None,
|
||||
is_flexible=None):
|
||||
self.title: str = title
|
||||
self.description: str = description
|
||||
self.payload: str = payload
|
||||
self.provider_token: str = provider_token
|
||||
self.currency: str = currency
|
||||
self.prices: List[LabeledPrice] = prices
|
||||
self.max_tip_amount: Optional[int] = max_tip_amount
|
||||
self.suggested_tip_amounts: Optional[List[int]] = suggested_tip_amounts
|
||||
self.provider_data: Optional[str] = provider_data
|
||||
self.photo_url: Optional[str] = photo_url
|
||||
self.photo_size: Optional[int] = photo_size
|
||||
self.photo_width: Optional[int] = photo_width
|
||||
self.photo_height: Optional[int] = photo_height
|
||||
self.need_name: Optional[bool] = need_name
|
||||
self.need_phone_number: Optional[bool] = need_phone_number
|
||||
self.need_email: Optional[bool] = need_email
|
||||
self.need_shipping_address: Optional[bool] = need_shipping_address
|
||||
self.send_phone_number_to_provider: Optional[bool] = send_phone_number_to_provider
|
||||
self.send_email_to_provider: Optional[bool] = send_email_to_provider
|
||||
self.is_flexible: Optional[bool] = is_flexible
|
||||
|
||||
def to_dict(self):
|
||||
json_dict = {
|
||||
'title': self.title,
|
||||
'description': self.description,
|
||||
'payload': self.payload,
|
||||
'provider_token': self.provider_token,
|
||||
'currency': self.currency,
|
||||
'prices': [LabeledPrice.to_dict(lp) for lp in self.prices]
|
||||
}
|
||||
if self.max_tip_amount:
|
||||
json_dict['max_tip_amount'] = self.max_tip_amount
|
||||
if self.suggested_tip_amounts:
|
||||
json_dict['suggested_tip_amounts'] = self.suggested_tip_amounts
|
||||
if self.provider_data:
|
||||
json_dict['provider_data'] = self.provider_data
|
||||
if self.photo_url:
|
||||
json_dict['photo_url'] = self.photo_url
|
||||
if self.photo_size:
|
||||
json_dict['photo_size'] = self.photo_size
|
||||
if self.photo_width:
|
||||
json_dict['photo_width'] = self.photo_width
|
||||
if self.photo_height:
|
||||
json_dict['photo_height'] = self.photo_height
|
||||
if self.need_name is not None:
|
||||
json_dict['need_name'] = self.need_name
|
||||
if self.need_phone_number is not None:
|
||||
json_dict['need_phone_number'] = self.need_phone_number
|
||||
if self.need_email is not None:
|
||||
json_dict['need_email'] = self.need_email
|
||||
if self.need_shipping_address is not None:
|
||||
json_dict['need_shipping_address'] = self.need_shipping_address
|
||||
if self.send_phone_number_to_provider is not None:
|
||||
json_dict['send_phone_number_to_provider'] = self.send_phone_number_to_provider
|
||||
if self.send_email_to_provider is not None:
|
||||
json_dict['send_email_to_provider'] = self.send_email_to_provider
|
||||
if self.is_flexible is not None:
|
||||
json_dict['is_flexible'] = self.is_flexible
|
||||
|
||||
|
||||
class ChosenInlineResult(JsonDeserializable):
|
||||
@classmethod
|
||||
def de_json(cls, json_string):
|
||||
@ -2135,10 +2202,13 @@ class LabeledPrice(JsonSerializable):
|
||||
self.label: str = label
|
||||
self.amount: int = amount
|
||||
|
||||
def to_json(self):
|
||||
return json.dumps({
|
||||
def to_dict(self):
|
||||
return {
|
||||
'label': self.label, 'amount': self.amount
|
||||
})
|
||||
}
|
||||
|
||||
def to_json(self):
|
||||
return json.dumps(self.to_dict())
|
||||
|
||||
|
||||
class Invoice(JsonDeserializable):
|
||||
@ -2341,11 +2411,12 @@ class MaskPosition(Dictionaryable, JsonDeserializable, JsonSerializable):
|
||||
# InputMedia
|
||||
|
||||
class InputMedia(Dictionaryable, JsonSerializable):
|
||||
def __init__(self, type, media, caption=None, parse_mode=None):
|
||||
def __init__(self, type, media, caption=None, parse_mode=None, caption_entities=None):
|
||||
self.type: str = type
|
||||
self.media: str = media
|
||||
self.caption: str = caption
|
||||
self.parse_mode: str = parse_mode
|
||||
self.caption: Optional[str] = caption
|
||||
self.parse_mode: Optional[str] = parse_mode
|
||||
self.caption_entities: Optional[List[MessageEntity]] = caption_entities
|
||||
|
||||
if util.is_string(self.media):
|
||||
self._media_name = ''
|
||||
@ -2363,6 +2434,8 @@ class InputMedia(Dictionaryable, JsonSerializable):
|
||||
json_dict['caption'] = self.caption
|
||||
if self.parse_mode:
|
||||
json_dict['parse_mode'] = self.parse_mode
|
||||
if self.caption_entities:
|
||||
json_dict['caption_entities'] = [MessageEntity.to_dict(entity) for entity in self.caption_entities]
|
||||
return json_dict
|
||||
|
||||
def convert_input_media(self):
|
||||
@ -2451,14 +2524,17 @@ class InputMediaAudio(InputMedia):
|
||||
|
||||
|
||||
class InputMediaDocument(InputMedia):
|
||||
def __init__(self, media, thumb=None, caption=None, parse_mode=None):
|
||||
def __init__(self, media, thumb=None, caption=None, parse_mode=None, disable_content_type_detection=None):
|
||||
super(InputMediaDocument, self).__init__(type="document", media=media, caption=caption, parse_mode=parse_mode)
|
||||
self.thumb = thumb
|
||||
self.disable_content_type_detection = disable_content_type_detection
|
||||
|
||||
def to_dict(self):
|
||||
ret = super(InputMediaDocument, self).to_dict()
|
||||
if self.thumb:
|
||||
ret['thumb'] = self.thumb
|
||||
if self.disable_content_type_detection is not None:
|
||||
ret['disable_content_type_detection'] = self.disable_content_type_detection
|
||||
return ret
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user