mirror of
https://github.com/eternnoir/pyTelegramBotAPI.git
synced 2023-08-10 21:12:57 +03:00
Fix some code hints
This commit is contained in:
parent
da57174635
commit
7c7a063fb6
@ -2,7 +2,6 @@
|
|||||||
[![PyPi Package Version](https://img.shields.io/pypi/v/pyTelegramBotAPI.svg)](https://pypi.python.org/pypi/pyTelegramBotAPI)
|
[![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)
|
[![Supported Python versions](https://img.shields.io/pypi/pyversions/pyTelegramBotAPI.svg)](https://pypi.python.org/pypi/pyTelegramBotAPI)
|
||||||
[![Documentation Status](https://readthedocs.org/projects/pytba/badge/?version=latest)](https://pytba.readthedocs.io/en/latest/?badge=latest)
|
[![Documentation Status](https://readthedocs.org/projects/pytba/badge/?version=latest)](https://pytba.readthedocs.io/en/latest/?badge=latest)
|
||||||
[![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/)
|
[![PyPi downloads](https://img.shields.io/pypi/dm/pyTelegramBotAPI.svg)](https://pypi.org/project/pyTelegramBotAPI/)
|
||||||
[![PyPi status](https://img.shields.io/pypi/status/pytelegrambotapi.svg?style=flat-square)](https://pypi.python.org/pypi/pytelegrambotapi)
|
[![PyPi status](https://img.shields.io/pypi/status/pytelegrambotapi.svg?style=flat-square)](https://pypi.python.org/pypi/pytelegrambotapi)
|
||||||
|
|
||||||
|
@ -451,7 +451,7 @@ class TeleBot:
|
|||||||
drop_pending_updates: Optional[bool] = None,
|
drop_pending_updates: Optional[bool] = None,
|
||||||
timeout: Optional[int]=None,
|
timeout: Optional[int]=None,
|
||||||
secret_token: Optional[str]=None,
|
secret_token: Optional[str]=None,
|
||||||
secret_token_length: Optional[int]=20,):
|
secret_token_length: Optional[int]=20):
|
||||||
"""
|
"""
|
||||||
This class sets webhooks and listens to a given url and port.
|
This class sets webhooks and listens to a given url and port.
|
||||||
|
|
||||||
@ -1906,6 +1906,8 @@ class TeleBot:
|
|||||||
:param message_thread_id: Identifier of a message thread, in which the message will be sent
|
:param message_thread_id: Identifier of a message thread, in which the message will be sent
|
||||||
:type message_thread_id: :obj:`int`
|
:type message_thread_id: :obj:`int`
|
||||||
|
|
||||||
|
:param thumb: Deprecated. Use thumbnail instead
|
||||||
|
|
||||||
:return: On success, the sent Message is returned.
|
:return: On success, the sent Message is returned.
|
||||||
:rtype: :class:`telebot.types.Message`
|
:rtype: :class:`telebot.types.Message`
|
||||||
"""
|
"""
|
||||||
@ -2072,6 +2074,8 @@ class TeleBot:
|
|||||||
:param message_thread_id: The thread to which the message will be sent
|
:param message_thread_id: The thread to which the message will be sent
|
||||||
:type message_thread_id: :obj:`int`
|
:type message_thread_id: :obj:`int`
|
||||||
|
|
||||||
|
:param thumb: Deprecated. Use thumbnail instead
|
||||||
|
|
||||||
:return: On success, the sent Message is returned.
|
:return: On success, the sent Message is returned.
|
||||||
:rtype: :class:`telebot.types.Message`
|
:rtype: :class:`telebot.types.Message`
|
||||||
"""
|
"""
|
||||||
@ -2256,6 +2260,8 @@ class TeleBot:
|
|||||||
:param has_spoiler: Pass True, if the video should be sent as a spoiler
|
:param has_spoiler: Pass True, if the video should be sent as a spoiler
|
||||||
:type has_spoiler: :obj:`bool`
|
:type has_spoiler: :obj:`bool`
|
||||||
|
|
||||||
|
:param thumb: Deprecated. Use thumbnail instead
|
||||||
|
|
||||||
:return: On success, the sent Message is returned.
|
:return: On success, the sent Message is returned.
|
||||||
:rtype: :class:`telebot.types.Message`
|
:rtype: :class:`telebot.types.Message`
|
||||||
"""
|
"""
|
||||||
@ -2359,6 +2365,8 @@ class TeleBot:
|
|||||||
:param has_spoiler: Pass True, if the animation should be sent as a spoiler
|
:param has_spoiler: Pass True, if the animation should be sent as a spoiler
|
||||||
:type has_spoiler: :obj:`bool`
|
:type has_spoiler: :obj:`bool`
|
||||||
|
|
||||||
|
:param thumb: Deprecated. Use thumbnail instead
|
||||||
|
|
||||||
:return: On success, the sent Message is returned.
|
:return: On success, the sent Message is returned.
|
||||||
:rtype: :class:`telebot.types.Message`
|
:rtype: :class:`telebot.types.Message`
|
||||||
"""
|
"""
|
||||||
@ -2438,6 +2446,8 @@ class TeleBot:
|
|||||||
:param message_thread_id: Identifier of a message thread, in which the video note will be sent
|
:param message_thread_id: Identifier of a message thread, in which the video note will be sent
|
||||||
:type message_thread_id: :obj:`int`
|
:type message_thread_id: :obj:`int`
|
||||||
|
|
||||||
|
:param thumb: Deprecated. Use thumbnail instead
|
||||||
|
|
||||||
:return: On success, the sent Message is returned.
|
:return: On success, the sent Message is returned.
|
||||||
:rtype: :class:`telebot.types.Message`
|
:rtype: :class:`telebot.types.Message`
|
||||||
"""
|
"""
|
||||||
@ -6740,7 +6750,6 @@ class TeleBot:
|
|||||||
if not process_handler: continue
|
if not process_handler: continue
|
||||||
for i in inspect.signature(handler['function']).parameters:
|
for i in inspect.signature(handler['function']).parameters:
|
||||||
params.append(i)
|
params.append(i)
|
||||||
result = None
|
|
||||||
if len(params) == 1:
|
if len(params) == 1:
|
||||||
result = handler['function'](message)
|
result = handler['function'](message)
|
||||||
elif "data" in params:
|
elif "data" in params:
|
||||||
|
@ -1479,7 +1479,8 @@ def send_invoice(
|
|||||||
:param max_tip_amount: The maximum accepted amount for tips in the smallest units of the currency
|
:param max_tip_amount: The maximum accepted amount for tips in the smallest units of the currency
|
||||||
:param suggested_tip_amounts: A JSON-serialized array of suggested amounts of tips in the smallest units of the currency.
|
:param suggested_tip_amounts: A JSON-serialized array of suggested amounts of tips in the smallest units of the currency.
|
||||||
At most 4 suggested tip amounts can be specified. The suggested tip amounts must be positive, passed in a strictly increased order and must not exceed max_tip_amount.
|
At most 4 suggested tip amounts can be specified. The suggested tip amounts must be positive, passed in a strictly increased order and must not exceed max_tip_amount.
|
||||||
:param protect_content:
|
:param protect_content: Protects the contents of the sent message from forwarding and saving
|
||||||
|
:param message_thread_id: Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
method_url = r'sendInvoice'
|
method_url = r'sendInvoice'
|
||||||
|
@ -209,8 +209,8 @@ class AsyncTeleBot:
|
|||||||
:param allowed_updates: Array of string. List the types of updates you want your bot to receive.
|
:param allowed_updates: Array of string. List the types of updates you want your bot to receive.
|
||||||
:type allowed_updates: :obj:`list`, optional
|
:type allowed_updates: :obj:`list`, optional
|
||||||
|
|
||||||
:param long_polling_timeout: Timeout in seconds for long polling.
|
:param request_timeout: Timeout in seconds for request.
|
||||||
:type long_polling_timeout: :obj:`int`, optional
|
:type request_timeout: :obj:`int`, optional
|
||||||
|
|
||||||
:return: An Array of Update objects is returned.
|
:return: An Array of Update objects is returned.
|
||||||
:rtype: :obj:`list` of :class:`telebot.types.Update`
|
:rtype: :obj:`list` of :class:`telebot.types.Update`
|
||||||
@ -511,7 +511,6 @@ class AsyncTeleBot:
|
|||||||
if not process_update: continue
|
if not process_update: continue
|
||||||
for i in signature(handler['function']).parameters:
|
for i in signature(handler['function']).parameters:
|
||||||
params.append(i)
|
params.append(i)
|
||||||
result = None
|
|
||||||
if len(params) == 1:
|
if len(params) == 1:
|
||||||
result = await handler['function'](message)
|
result = await handler['function'](message)
|
||||||
elif "data" in params:
|
elif "data" in params:
|
||||||
@ -2072,6 +2071,8 @@ class AsyncTeleBot:
|
|||||||
:param drop_pending_updates: Pass True to drop all pending updates
|
:param drop_pending_updates: Pass True to drop all pending updates
|
||||||
:param timeout: Integer. Request connection timeout
|
:param timeout: Integer. Request connection timeout
|
||||||
:param secret_token: Secret token to be used to verify the webhook request.
|
:param secret_token: Secret token to be used to verify the webhook request.
|
||||||
|
:param secret_token_length: Length of a secret token, defaults to 20
|
||||||
|
:param debug: Debug mode, defaults to False
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -2079,12 +2080,9 @@ class AsyncTeleBot:
|
|||||||
if not secret_token:
|
if not secret_token:
|
||||||
secret_token = ''.join(random.choices(string.ascii_uppercase + string.digits, k=secret_token_length))
|
secret_token = ''.join(random.choices(string.ascii_uppercase + string.digits, k=secret_token_length))
|
||||||
|
|
||||||
|
|
||||||
if not url_path:
|
if not url_path:
|
||||||
url_path = self.token + '/'
|
url_path = self.token + '/'
|
||||||
if url_path[-1] != '/': url_path += '/'
|
if url_path[-1] != '/': url_path += '/'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protocol = "https" if certificate else "http"
|
protocol = "https" if certificate else "http"
|
||||||
if not webhook_url:
|
if not webhook_url:
|
||||||
@ -2093,8 +2091,6 @@ class AsyncTeleBot:
|
|||||||
if certificate and certificate_key:
|
if certificate and certificate_key:
|
||||||
ssl_ctx = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
|
ssl_ctx = ssl.create_default_context(ssl.Purpose.CLIENT_AUTH)
|
||||||
ssl_ctx.load_cert_chain(certificate, certificate_key)
|
ssl_ctx.load_cert_chain(certificate, certificate_key)
|
||||||
else:
|
|
||||||
ssl_ctx = None
|
|
||||||
|
|
||||||
# open certificate if it exists
|
# open certificate if it exists
|
||||||
cert_file = open(certificate, 'rb') if certificate else None
|
cert_file = open(certificate, 'rb') if certificate else None
|
||||||
@ -2769,6 +2765,8 @@ class AsyncTeleBot:
|
|||||||
:param message_thread_id: Identifier of a message thread, in which the message will be sent
|
:param message_thread_id: Identifier of a message thread, in which the message will be sent
|
||||||
:type message_thread_id: :obj:`int`
|
:type message_thread_id: :obj:`int`
|
||||||
|
|
||||||
|
:param thumb: Deprecated. Use thumbnail instead
|
||||||
|
|
||||||
:return: On success, the sent Message is returned.
|
:return: On success, the sent Message is returned.
|
||||||
:rtype: :class:`telebot.types.Message`
|
:rtype: :class:`telebot.types.Message`
|
||||||
"""
|
"""
|
||||||
@ -2934,6 +2932,8 @@ class AsyncTeleBot:
|
|||||||
:param message_thread_id: Identifier of a message thread, in which the message will be sent
|
:param message_thread_id: Identifier of a message thread, in which the message will be sent
|
||||||
:type message_thread_id: :obj:`int`
|
:type message_thread_id: :obj:`int`
|
||||||
|
|
||||||
|
:param thumb: Deprecated. Use thumbnail instead
|
||||||
|
|
||||||
:return: On success, the sent Message is returned.
|
:return: On success, the sent Message is returned.
|
||||||
:rtype: :class:`telebot.types.Message`
|
:rtype: :class:`telebot.types.Message`
|
||||||
"""
|
"""
|
||||||
@ -3116,6 +3116,8 @@ class AsyncTeleBot:
|
|||||||
:param has_spoiler: Pass True, if the video should be sent as a spoiler
|
:param has_spoiler: Pass True, if the video should be sent as a spoiler
|
||||||
:type has_spoiler: :obj:`bool`
|
:type has_spoiler: :obj:`bool`
|
||||||
|
|
||||||
|
:param thumb: Deprecated. Use thumbnail instead
|
||||||
|
|
||||||
:return: On success, the sent Message is returned.
|
:return: On success, the sent Message is returned.
|
||||||
:rtype: :class:`telebot.types.Message`
|
:rtype: :class:`telebot.types.Message`
|
||||||
"""
|
"""
|
||||||
@ -3220,6 +3222,8 @@ class AsyncTeleBot:
|
|||||||
:param has_spoiler: Pass True, if the animation should be sent as a spoiler
|
:param has_spoiler: Pass True, if the animation should be sent as a spoiler
|
||||||
:type has_spoiler: :obj:`bool`
|
:type has_spoiler: :obj:`bool`
|
||||||
|
|
||||||
|
:param thumb: Deprecated. Use thumbnail instead
|
||||||
|
|
||||||
:return: On success, the sent Message is returned.
|
:return: On success, the sent Message is returned.
|
||||||
:rtype: :class:`telebot.types.Message`
|
:rtype: :class:`telebot.types.Message`
|
||||||
"""
|
"""
|
||||||
@ -3299,6 +3303,8 @@ class AsyncTeleBot:
|
|||||||
:param message_thread_id: Identifier of a message thread, in which the video note will be sent
|
:param message_thread_id: Identifier of a message thread, in which the video note will be sent
|
||||||
:type message_thread_id: :obj:`int`
|
:type message_thread_id: :obj:`int`
|
||||||
|
|
||||||
|
:param thumb: Deprecated. Use thumbnail instead
|
||||||
|
|
||||||
:return: On success, the sent Message is returned.
|
:return: On success, the sent Message is returned.
|
||||||
:rtype: :class:`telebot.types.Message`
|
:rtype: :class:`telebot.types.Message`
|
||||||
"""
|
"""
|
||||||
@ -5609,7 +5615,7 @@ class AsyncTeleBot:
|
|||||||
|
|
||||||
async def create_new_sticker_set(
|
async def create_new_sticker_set(
|
||||||
self, user_id: int, name: str, title: str,
|
self, user_id: int, name: str, title: str,
|
||||||
emojis: Optional[str]=None,
|
emojis: Optional[List[str]]=None,
|
||||||
png_sticker: Union[Any, str]=None,
|
png_sticker: Union[Any, str]=None,
|
||||||
tgs_sticker: Union[Any, str]=None,
|
tgs_sticker: Union[Any, str]=None,
|
||||||
webm_sticker: Union[Any, str]=None,
|
webm_sticker: Union[Any, str]=None,
|
||||||
|
@ -173,6 +173,7 @@ async def get_file_url(token, file_id):
|
|||||||
if FILE_URL is None:
|
if FILE_URL is None:
|
||||||
return "https://api.telegram.org/file/bot{0}/{1}".format(token, (await get_file(token, file_id))['file_path'])
|
return "https://api.telegram.org/file/bot{0}/{1}".format(token, (await get_file(token, file_id))['file_path'])
|
||||||
else:
|
else:
|
||||||
|
# noinspection PyUnresolvedReferences
|
||||||
return FILE_URL.format(token, (await get_file(token, file_id))['file_path'])
|
return FILE_URL.format(token, (await get_file(token, file_id))['file_path'])
|
||||||
|
|
||||||
|
|
||||||
@ -180,6 +181,7 @@ async def download_file(token, file_path):
|
|||||||
if FILE_URL is None:
|
if FILE_URL is None:
|
||||||
url = "https://api.telegram.org/file/bot{0}/{1}".format(token, file_path)
|
url = "https://api.telegram.org/file/bot{0}/{1}".format(token, file_path)
|
||||||
else:
|
else:
|
||||||
|
# noinspection PyUnresolvedReferences
|
||||||
url = FILE_URL.format(token, file_path)
|
url = FILE_URL.format(token, file_path)
|
||||||
session = await session_manager.get_session()
|
session = await session_manager.get_session()
|
||||||
async with session.get(url, proxy=proxy) as response:
|
async with session.get(url, proxy=proxy) as response:
|
||||||
@ -1433,8 +1435,8 @@ async def send_invoice(
|
|||||||
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,
|
||||||
timeout=None, allow_sending_without_reply=None, max_tip_amount=None, suggested_tip_amounts=None, protect_content=None,
|
timeout=None, allow_sending_without_reply=None, max_tip_amount=None, suggested_tip_amounts=None,
|
||||||
message_thread_id=None):
|
protect_content=None, message_thread_id=None):
|
||||||
"""
|
"""
|
||||||
Use this method to send invoices. On success, the sent Message is returned.
|
Use this method to send invoices. On success, the sent Message is returned.
|
||||||
:param token: Bot's token (you don't need to fill this)
|
:param token: Bot's token (you don't need to fill this)
|
||||||
@ -1466,7 +1468,8 @@ async def send_invoice(
|
|||||||
:param max_tip_amount: The maximum accepted amount for tips in the smallest units of the currency
|
:param max_tip_amount: The maximum accepted amount for tips in the smallest units of the currency
|
||||||
:param suggested_tip_amounts: A JSON-serialized array of suggested amounts of tips in the smallest units of the currency.
|
:param suggested_tip_amounts: A JSON-serialized array of suggested amounts of tips in the smallest units of the currency.
|
||||||
At most 4 suggested tip amounts can be specified. The suggested tip amounts must be positive, passed in a strictly increased order and must not exceed max_tip_amount.
|
At most 4 suggested tip amounts can be specified. The suggested tip amounts must be positive, passed in a strictly increased order and must not exceed max_tip_amount.
|
||||||
:param protect_content:
|
:param protect_content: Protects the contents of the sent message from forwarding and saving
|
||||||
|
:param message_thread_id: Unique identifier for the target message thread (topic) of the forum; for forum supergroups only
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
method_url = r'sendInvoice'
|
method_url = r'sendInvoice'
|
||||||
|
Loading…
Reference in New Issue
Block a user