Check and update for full compatibility to Bot API up to 5.3

Pre-release of 4.0.0
This commit is contained in:
Badiboy 2021-08-18 23:27:28 +03:00
parent 022ef6a64c
commit 2bc052ad5a
5 changed files with 59 additions and 26 deletions

View File

@ -1,12 +1,17 @@
# <p align="center">pyTelegramBotAPI
<p align="center">A simple, but extensible Python implementation for the <a href="https://core.telegram.org/bots/api">Telegram Bot API</a>.
[![PyPi Package Version](https://img.shields.io/pypi/v/pyTelegramBotAPI.svg)](https://pypi.python.org/pypi/pyTelegramBotAPI)
[![Supported Python versions](https://img.shields.io/pypi/pyversions/pyTelegramBotAPI.svg)](https://pypi.python.org/pypi/pyTelegramBotAPI)
[![Build Status](https://travis-ci.org/eternnoir/pyTelegramBotAPI.svg?branch=master)](https://travis-ci.org/eternnoir/pyTelegramBotAPI)
[![PyPi downloads](https://img.shields.io/pypi/dm/pyTelegramBotAPI.svg)](https://pypi.org/project/pyTelegramBotAPI/)
# <p align="center">pyTelegramBotAPI</p>
<p align="center">A simple, but extensible Python implementation for the <a href="https://core.telegram.org/bots/api">Telegram Bot API</a>.</p>
##<p align="center">Supported Bot API version: <a href="https://core.telegram.org/bots/api#june-25-2021">5.3</a>!</p>
##Contents
* [Getting started.](#getting-started)
* [Writing your first bot](#writing-your-first-bot)
* [Prerequisites](#prerequisites)
@ -603,21 +608,20 @@ apihelper.proxy = {'https':'socks5://userproxy:password@proxy_address:port'}
## API conformance
_Checking is in progress..._
✅ [Bot API 5.1](https://core.telegram.org/bots/api#march-9-2021) _- To be checked..._
* [Bot API 5.3](https://core.telegram.org/bots/api#june-25-2021) - ChatMemberXXX classes are full copies of ChatMember
* ✔ [Bot API 5.2](https://core.telegram.org/bots/api#april-26-2021)
* ✔ [Bot API 5.1](https://core.telegram.org/bots/api#march-9-2021)
* ✔ [Bot API 5.0](https://core.telegram.org/bots/api-changelog#november-4-2020)
* ✔ [Bot API 4.9](https://core.telegram.org/bots/api-changelog#june-4-2020)
* ✔ [Bot API 4.8](https://core.telegram.org/bots/api-changelog#april-24-2020)
* ✔ [Bot API 4.7](https://core.telegram.org/bots/api-changelog#march-30-2020)
* ✔ [Bot API 4.6](https://core.telegram.org/bots/api-changelog#january-23-2020)
* [Bot API 4.5](https://core.telegram.org/bots/api-changelog#december-31-2019) - No nested MessageEntities and Markdown2 support.
* [Bot API 4.5](https://core.telegram.org/bots/api-changelog#december-31-2019) - No nested MessageEntities and Markdown2 support
* ✔ [Bot API 4.4](https://core.telegram.org/bots/api-changelog#july-29-2019)
* ✔ [Bot API 4.3](https://core.telegram.org/bots/api-changelog#may-31-2019)
* ✔ [Bot API 4.2](https://core.telegram.org/bots/api-changelog#april-14-2019)
* [Bot API 4.1](https://core.telegram.org/bots/api-changelog#august-27-2018) - No Passport support.
* [Bot API 4.0](https://core.telegram.org/bots/api-changelog#july-26-2018) - No Passport support.
* [Bot API 4.1](https://core.telegram.org/bots/api-changelog#august-27-2018) - No Passport support
* [Bot API 4.0](https://core.telegram.org/bots/api-changelog#july-26-2018) - No Passport support
* ✔ [Bot API 3.6](https://core.telegram.org/bots/api-changelog#february-13-2018)
* ✔ [Bot API 3.5](https://core.telegram.org/bots/api-changelog#november-17-2017)
* ✔ [Bot API 3.4](https://core.telegram.org/bots/api-changelog#october-11-2017)

View File

@ -1985,7 +1985,7 @@ class TeleBot:
timeout: Optional[int]=None,
allow_sending_without_reply: Optional[bool]=None,
max_tip_amount: Optional[int] = None,
suggested_tip_amounts: Optional[list]=None) -> types.Message:
suggested_tip_amounts: Optional[List[int]]=None) -> types.Message:
"""
Sends invoice
:param chat_id: Unique identifier for the target private chat

View File

@ -973,11 +973,11 @@ def create_chat_invite_link(token, chat_id, expire_date, member_limit):
}
if expire_date is not None:
payload['expire_date'] = expire_date
if isinstance(payload['expire_date'], datetime):
payload['expire_date'] = payload['expire_date'].timestamp()
if member_limit is not None:
else:
payload['expire_date'] = expire_date
if member_limit:
payload['member_limit'] = member_limit
return _make_request(token, method_url, params=payload, method='post')
@ -991,9 +991,10 @@ def edit_chat_invite_link(token, chat_id, invite_link, expire_date, member_limit
}
if expire_date is not None:
payload['expire_date'] = expire_date
if isinstance(payload['expire_date'], datetime):
payload['expire_date'] = payload['expire_date'].timestamp()
else:
payload['expire_date'] = expire_date
if member_limit is not None:
payload['member_limit'] = member_limit
@ -1258,7 +1259,7 @@ def get_game_high_scores(token, user_id, chat_id=None, message_id=None, inline_m
def send_invoice(
token, chat_id, title, description, invoice_payload, provider_token, currency, prices,
start_parameter, photo_url=None, photo_size=None, photo_width=None, photo_height=None,
start_parameter = 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,
disable_notification=None, reply_to_message_id=None, reply_markup=None, provider_data=None,
@ -1298,8 +1299,10 @@ def send_invoice(
"""
method_url = r'sendInvoice'
payload = {'chat_id': chat_id, 'title': title, 'description': description, 'payload': invoice_payload,
'provider_token': provider_token, 'start_parameter': start_parameter, 'currency': currency,
'provider_token': provider_token, 'currency': currency,
'prices': _convert_list_json_serializable(prices)}
if start_parameter:
payload['start_parameter'] = start_parameter
if photo_url:
payload['photo_url'] = photo_url
if photo_size:

View File

@ -441,12 +441,10 @@ class Message(JsonDeserializable):
opts['voice_chat_ended'] = VoiceChatEnded.de_json(obj['voice_chat_ended'])
content_type = 'voice_chat_ended'
if 'voice_chat_participants_invited' in obj:
opts['voice_chat_participants_invited'] = VoiceChatParticipantsInvited.de_json(
obj['voice_chat_participants_invited'])
opts['voice_chat_participants_invited'] = VoiceChatParticipantsInvited.de_json(obj['voice_chat_participants_invited'])
content_type = 'voice_chat_participants_invited'
if 'message_auto_delete_timer_changed' in obj:
opts['message_auto_delete_timer_changed'] = MessageAutoDeleteTimerChanged.de_json(
obj['message_auto_delete_timer_changed'])
opts['message_auto_delete_timer_changed'] = MessageAutoDeleteTimerChanged.de_json(obj['message_auto_delete_timer_changed'])
content_type = 'message_auto_delete_timer_changed'
if 'reply_markup' in obj:
opts['reply_markup'] = InlineKeyboardMarkup.de_json(obj['reply_markup'])
@ -1232,6 +1230,29 @@ class ChatMember(JsonDeserializable):
self.until_date: int = until_date
class ChatMemberOwner(ChatMember):
pass
class ChatMemberAdministrator(ChatMember):
pass
class ChatMemberMember(ChatMember):
pass
class ChatMemberRestricted(ChatMember):
pass
class ChatMemberLeft(ChatMember):
pass
class ChatMemberBanned(ChatMember):
pass
class ChatPermissions(JsonDeserializable, JsonSerializable, Dictionaryable):
@classmethod
def de_json(cls, json_string):
@ -2744,14 +2765,18 @@ class ChatInviteLink(JsonSerializable, JsonDeserializable, Dictionaryable):
return json.dumps(self.to_dict())
def to_dict(self):
return {
json_dict = {
"invite_link": self.invite_link,
"creator": self.creator.to_dict(),
"is_primary": self.is_primary,
"is_revoked": self.is_revoked,
"expire_date": self.expire_date,
"member_limit": self.member_limit
"is_revoked": self.is_revoked
}
if self.expire_date:
json_dict["expire_date"] = self.expire_date
if self.member_limit:
json_dict["member_limit"] = self.member_limit
return json_dict
class ProximityAlertTriggered(JsonDeserializable):
@classmethod
@ -2778,6 +2803,7 @@ class VoiceChatStarted(JsonDeserializable):
"""
pass
class VoiceChatScheduled(JsonDeserializable):
@classmethod
def de_json(cls, json_string):

View File

@ -1,3 +1,3 @@
# Versions should comply with PEP440.
# This line is parsed in setup.py:
__version__ = '3.8.2'
__version__ = '3.8.3'