mirror of
https://github.com/eternnoir/pyTelegramBotAPI.git
synced 2023-08-10 21:12:57 +03:00
Merge pull request #1270 from Badiboy/master
Check and update for full compatibility to Bot API up to 5.3
This commit is contained in:
commit
6e871b8eb1
24
README.md
24
README.md
@ -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>.
|
|
||||||
|
|
||||||
[](https://pypi.python.org/pypi/pyTelegramBotAPI)
|
[](https://pypi.python.org/pypi/pyTelegramBotAPI)
|
||||||
[](https://pypi.python.org/pypi/pyTelegramBotAPI)
|
[](https://pypi.python.org/pypi/pyTelegramBotAPI)
|
||||||
[](https://travis-ci.org/eternnoir/pyTelegramBotAPI)
|
[](https://travis-ci.org/eternnoir/pyTelegramBotAPI)
|
||||||
[](https://pypi.org/project/pyTelegramBotAPI/)
|
[](https://pypi.org/project/pyTelegramBotAPI/)
|
||||||
|
|
||||||
|
# <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>.
|
||||||
|
|
||||||
|
## <p align="center">Supported Bot API version: <a href="https://core.telegram.org/bots/api#june-25-2021">5.3</a>!
|
||||||
|
|
||||||
|
##Contents
|
||||||
|
|
||||||
* [Getting started.](#getting-started)
|
* [Getting started.](#getting-started)
|
||||||
* [Writing your first bot](#writing-your-first-bot)
|
* [Writing your first bot](#writing-your-first-bot)
|
||||||
* [Prerequisites](#prerequisites)
|
* [Prerequisites](#prerequisites)
|
||||||
@ -603,21 +608,20 @@ apihelper.proxy = {'https':'socks5://userproxy:password@proxy_address:port'}
|
|||||||
|
|
||||||
## API conformance
|
## API conformance
|
||||||
|
|
||||||
_Checking is in progress..._
|
* ➕ [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) _- To be checked..._
|
* ✔ [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 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.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.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.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.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.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.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.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.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.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.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.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)
|
* ✔ [Bot API 3.4](https://core.telegram.org/bots/api-changelog#october-11-2017)
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
py==1.10.0
|
|
||||||
pytest==3.0.2
|
pytest==3.0.2
|
||||||
requests==2.20.0
|
requests==2.20.0
|
||||||
wheel==0.24.0
|
wheel==0.24.0
|
||||||
|
1
setup.py
1
setup.py
@ -25,6 +25,7 @@ setup(name='pyTelegramBotAPI',
|
|||||||
install_requires=['requests'],
|
install_requires=['requests'],
|
||||||
extras_require={
|
extras_require={
|
||||||
'json': 'ujson',
|
'json': 'ujson',
|
||||||
|
'PIL': 'Pillow',
|
||||||
'redis': 'redis>=3.4.1'
|
'redis': 'redis>=3.4.1'
|
||||||
},
|
},
|
||||||
classifiers=[
|
classifiers=[
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from __future__ import print_function
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
@ -1986,7 +1985,7 @@ class TeleBot:
|
|||||||
timeout: Optional[int]=None,
|
timeout: Optional[int]=None,
|
||||||
allow_sending_without_reply: Optional[bool]=None,
|
allow_sending_without_reply: Optional[bool]=None,
|
||||||
max_tip_amount: Optional[int] = 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
|
Sends invoice
|
||||||
:param chat_id: Unique identifier for the target private chat
|
:param chat_id: Unique identifier for the target private chat
|
||||||
|
@ -973,11 +973,11 @@ def create_chat_invite_link(token, chat_id, expire_date, member_limit):
|
|||||||
}
|
}
|
||||||
|
|
||||||
if expire_date is not None:
|
if expire_date is not None:
|
||||||
payload['expire_date'] = expire_date
|
|
||||||
if isinstance(payload['expire_date'], datetime):
|
if isinstance(payload['expire_date'], datetime):
|
||||||
payload['expire_date'] = payload['expire_date'].timestamp()
|
payload['expire_date'] = payload['expire_date'].timestamp()
|
||||||
|
else:
|
||||||
if member_limit is not None:
|
payload['expire_date'] = expire_date
|
||||||
|
if member_limit:
|
||||||
payload['member_limit'] = member_limit
|
payload['member_limit'] = member_limit
|
||||||
|
|
||||||
return _make_request(token, method_url, params=payload, method='post')
|
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:
|
if expire_date is not None:
|
||||||
payload['expire_date'] = expire_date
|
|
||||||
if isinstance(payload['expire_date'], datetime):
|
if isinstance(payload['expire_date'], datetime):
|
||||||
payload['expire_date'] = payload['expire_date'].timestamp()
|
payload['expire_date'] = payload['expire_date'].timestamp()
|
||||||
|
else:
|
||||||
|
payload['expire_date'] = expire_date
|
||||||
|
|
||||||
if member_limit is not None:
|
if member_limit is not None:
|
||||||
payload['member_limit'] = member_limit
|
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(
|
def send_invoice(
|
||||||
token, chat_id, title, description, invoice_payload, provider_token, currency, prices,
|
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,
|
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,
|
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,
|
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'
|
method_url = r'sendInvoice'
|
||||||
payload = {'chat_id': chat_id, 'title': title, 'description': description, 'payload': invoice_payload,
|
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)}
|
'prices': _convert_list_json_serializable(prices)}
|
||||||
|
if start_parameter:
|
||||||
|
payload['start_parameter'] = start_parameter
|
||||||
if photo_url:
|
if photo_url:
|
||||||
payload['photo_url'] = photo_url
|
payload['photo_url'] = photo_url
|
||||||
if photo_size:
|
if photo_size:
|
||||||
|
@ -441,12 +441,10 @@ class Message(JsonDeserializable):
|
|||||||
opts['voice_chat_ended'] = VoiceChatEnded.de_json(obj['voice_chat_ended'])
|
opts['voice_chat_ended'] = VoiceChatEnded.de_json(obj['voice_chat_ended'])
|
||||||
content_type = 'voice_chat_ended'
|
content_type = 'voice_chat_ended'
|
||||||
if 'voice_chat_participants_invited' in obj:
|
if 'voice_chat_participants_invited' in obj:
|
||||||
opts['voice_chat_participants_invited'] = VoiceChatParticipantsInvited.de_json(
|
opts['voice_chat_participants_invited'] = VoiceChatParticipantsInvited.de_json(obj['voice_chat_participants_invited'])
|
||||||
obj['voice_chat_participants_invited'])
|
|
||||||
content_type = 'voice_chat_participants_invited'
|
content_type = 'voice_chat_participants_invited'
|
||||||
if 'message_auto_delete_timer_changed' in obj:
|
if 'message_auto_delete_timer_changed' in obj:
|
||||||
opts['message_auto_delete_timer_changed'] = MessageAutoDeleteTimerChanged.de_json(
|
opts['message_auto_delete_timer_changed'] = MessageAutoDeleteTimerChanged.de_json(obj['message_auto_delete_timer_changed'])
|
||||||
obj['message_auto_delete_timer_changed'])
|
|
||||||
content_type = 'message_auto_delete_timer_changed'
|
content_type = 'message_auto_delete_timer_changed'
|
||||||
if 'reply_markup' in obj:
|
if 'reply_markup' in obj:
|
||||||
opts['reply_markup'] = InlineKeyboardMarkup.de_json(obj['reply_markup'])
|
opts['reply_markup'] = InlineKeyboardMarkup.de_json(obj['reply_markup'])
|
||||||
@ -1232,6 +1230,29 @@ class ChatMember(JsonDeserializable):
|
|||||||
self.until_date: int = until_date
|
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):
|
class ChatPermissions(JsonDeserializable, JsonSerializable, Dictionaryable):
|
||||||
@classmethod
|
@classmethod
|
||||||
def de_json(cls, json_string):
|
def de_json(cls, json_string):
|
||||||
@ -2744,14 +2765,18 @@ class ChatInviteLink(JsonSerializable, JsonDeserializable, Dictionaryable):
|
|||||||
return json.dumps(self.to_dict())
|
return json.dumps(self.to_dict())
|
||||||
|
|
||||||
def to_dict(self):
|
def to_dict(self):
|
||||||
return {
|
json_dict = {
|
||||||
"invite_link": self.invite_link,
|
"invite_link": self.invite_link,
|
||||||
"creator": self.creator.to_dict(),
|
"creator": self.creator.to_dict(),
|
||||||
"is_primary": self.is_primary,
|
"is_primary": self.is_primary,
|
||||||
"is_revoked": self.is_revoked,
|
"is_revoked": self.is_revoked
|
||||||
"expire_date": self.expire_date,
|
|
||||||
"member_limit": self.member_limit
|
|
||||||
}
|
}
|
||||||
|
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):
|
class ProximityAlertTriggered(JsonDeserializable):
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -2778,6 +2803,7 @@ class VoiceChatStarted(JsonDeserializable):
|
|||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class VoiceChatScheduled(JsonDeserializable):
|
class VoiceChatScheduled(JsonDeserializable):
|
||||||
@classmethod
|
@classmethod
|
||||||
def de_json(cls, json_string):
|
def de_json(cls, json_string):
|
||||||
|
@ -4,16 +4,16 @@ import re
|
|||||||
import string
|
import string
|
||||||
import threading
|
import threading
|
||||||
import traceback
|
import traceback
|
||||||
import warnings
|
|
||||||
import functools
|
|
||||||
from typing import Any, Callable, List, Dict, Optional, Union
|
from typing import Any, Callable, List, Dict, Optional, Union
|
||||||
|
|
||||||
|
# noinspection PyPep8Naming
|
||||||
import queue as Queue
|
import queue as Queue
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from telebot import types
|
from telebot import types
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
# noinspection PyPackageRequirements
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
pil_imported = True
|
pil_imported = True
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
# Versions should comply with PEP440.
|
# Versions should comply with PEP440.
|
||||||
# This line is parsed in setup.py:
|
# This line is parsed in setup.py:
|
||||||
__version__ = '3.8.2'
|
__version__ = '3.8.3'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user