From 022ef6a64cf4a0ef957a35ee6932fa4866de567d Mon Sep 17 00:00:00 2001 From: Badiboy Date: Wed, 18 Aug 2021 22:16:30 +0300 Subject: [PATCH 1/3] Dependecies clearing --- requirements.txt | 1 - setup.py | 1 + telebot/__init__.py | 1 - telebot/util.py | 4 ++-- 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/requirements.txt b/requirements.txt index cf9236360..3a014e7d8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,3 @@ -py==1.10.0 pytest==3.0.2 requests==2.20.0 wheel==0.24.0 diff --git a/setup.py b/setup.py index b3e8158cf..7b6277638 100644 --- a/setup.py +++ b/setup.py @@ -25,6 +25,7 @@ def read(filename): install_requires=['requests'], extras_require={ 'json': 'ujson', + 'PIL': 'Pillow', 'redis': 'redis>=3.4.1' }, classifiers=[ diff --git a/telebot/__init__.py b/telebot/__init__.py index 35cad2bd2..57ed008bb 100644 --- a/telebot/__init__.py +++ b/telebot/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import print_function from datetime import datetime import logging diff --git a/telebot/util.py b/telebot/util.py index 34d08ed64..d0a58b011 100644 --- a/telebot/util.py +++ b/telebot/util.py @@ -4,16 +4,16 @@ import string import threading import traceback -import warnings -import functools from typing import Any, Callable, List, Dict, Optional, Union +# noinspection PyPep8Naming import queue as Queue import logging from telebot import types try: + # noinspection PyPackageRequirements from PIL import Image from io import BytesIO pil_imported = True From 2bc052ad5a4a0d716e33ab36d32b7e94975dcf55 Mon Sep 17 00:00:00 2001 From: Badiboy Date: Wed, 18 Aug 2021 23:27:28 +0300 Subject: [PATCH 2/3] Check and update for full compatibility to Bot API up to 5.3 Pre-release of 4.0.0 --- README.md | 24 ++++++++++++++---------- telebot/__init__.py | 2 +- telebot/apihelper.py | 15 +++++++++------ telebot/types.py | 42 ++++++++++++++++++++++++++++++++++-------- telebot/version.py | 2 +- 5 files changed, 59 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 76fe3276a..93e188c80 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,17 @@ -#

pyTelegramBotAPI - -

A simple, but extensible Python implementation for the Telegram Bot API. [![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/) +#

pyTelegramBotAPI

+ +

A simple, but extensible Python implementation for the Telegram Bot API.

+ +##

Supported Bot API version: 5.3!

+ +##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) diff --git a/telebot/__init__.py b/telebot/__init__.py index 57ed008bb..e9aaff69f 100644 --- a/telebot/__init__.py +++ b/telebot/__init__.py @@ -1985,7 +1985,7 @@ def send_invoice( 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 diff --git a/telebot/apihelper.py b/telebot/apihelper.py index 4b19f241c..0d3820fa1 100644 --- a/telebot/apihelper.py +++ b/telebot/apihelper.py @@ -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: diff --git a/telebot/types.py b/telebot/types.py index dfcfb8ff8..1d8bdc060 100644 --- a/telebot/types.py +++ b/telebot/types.py @@ -441,12 +441,10 @@ def de_json(cls, json_string): 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 @@ def __init__(self, user, status, custom_title=None, is_anonymous=None, can_be_ed 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 @@ def to_json(self): 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 @@ def __init__(self): """ pass + class VoiceChatScheduled(JsonDeserializable): @classmethod def de_json(cls, json_string): diff --git a/telebot/version.py b/telebot/version.py index 80f0f16f0..afeff5596 100644 --- a/telebot/version.py +++ b/telebot/version.py @@ -1,3 +1,3 @@ # Versions should comply with PEP440. # This line is parsed in setup.py: -__version__ = '3.8.2' +__version__ = '3.8.3' From f6359bc32c12a49db9a35cbddb1591f393edda90 Mon Sep 17 00:00:00 2001 From: Badiboy Date: Wed, 18 Aug 2021 23:29:40 +0300 Subject: [PATCH 3/3] Readme fix --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 93e188c80..d1baef754 100644 --- a/README.md +++ b/README.md @@ -4,11 +4,11 @@ [![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/) -#

pyTelegramBotAPI

+#

pyTelegramBotAPI -

A simple, but extensible Python implementation for the Telegram Bot API.

+

A simple, but extensible Python implementation for the Telegram Bot API. -##

Supported Bot API version: 5.3!

+##

Supported Bot API version: 5.3! ##Contents