1
0
mirror of https://github.com/eternnoir/pyTelegramBotAPI.git synced 2023-08-10 21:12:57 +03:00

Fix documentation

This commit is contained in:
coder2020official
2022-03-07 14:24:28 +05:00
parent 854f6a9506
commit c8fb83c97c
8 changed files with 113 additions and 128 deletions

View File

@@ -28,14 +28,6 @@ Asynchronous storage for states
:undoc-members: :undoc-members:
:show-inheritance: :show-inheritance:
asyncio_helper file
-------------------
.. automodule:: telebot.asyncio_helper
:members:
:undoc-members:
:show-inheritance:
Asyncio handler backends Asyncio handler backends
------------------------ ------------------------

View File

@@ -25,7 +25,7 @@ Pypi: `Pypi <https://pypi.org/project/pyTelegramBotAPI/>`__
Source: `Github repository <https://github.com/eternnoir/pyTelegramBotAPI>`__ Source: `Github repository <https://github.com/eternnoir/pyTelegramBotAPI>`__
Some features: Some features:
------------- --------------
Easy to learn and use. Easy to learn and use.
Easy to understand. Easy to understand.

View File

@@ -3,8 +3,6 @@ Installation Guide
================== ==================
:toctree
Using PIP Using PIP
---------- ----------
.. code-block:: bash .. code-block:: bash

View File

@@ -33,11 +33,3 @@ handler_backends file
:undoc-members: :undoc-members:
:show-inheritance: :show-inheritance:
apihelper
------------------------
.. automodule:: telebot.apihelper
:members:
:undoc-members:
:show-inheritance:

View File

@@ -343,7 +343,7 @@ class TeleBot:
:param offset: Integer. Identifier of the first update to be returned. :param offset: Integer. Identifier of the first update to be returned.
:param limit: Integer. Limits the number of updates to be retrieved. :param limit: Integer. Limits the number of updates to be retrieved.
:param timeout: Integer. Request connection timeout :param timeout: Integer. Request connection timeout
:param long_polling_timeout. Timeout in seconds for long polling. :param long_polling_timeout: Timeout in seconds for long polling.
:return: array of Updates :return: array of Updates
""" """
json_updates = apihelper.get_updates(self.token, offset, limit, timeout, allowed_updates, long_polling_timeout) json_updates = apihelper.get_updates(self.token, offset, limit, timeout, allowed_updates, long_polling_timeout)
@@ -932,8 +932,7 @@ class TeleBot:
Telegram documentation: https://core.telegram.org/bots/api#deletechatstickerset Telegram documentation: https://core.telegram.org/bots/api#deletechatstickerset
:param chat_id: Unique identifier for the target chat or username of the target supergroup :param chat_id: Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
(in the format @supergroupusername)
:return: API reply. :return: API reply.
""" """
result = apihelper.delete_chat_sticker_set(self.token, chat_id) result = apihelper.delete_chat_sticker_set(self.token, chat_id)
@@ -1199,7 +1198,7 @@ class TeleBot:
:param duration: Duration of sent audio in seconds :param duration: Duration of sent audio in seconds
:param reply_to_message_id: :param reply_to_message_id:
:param reply_markup: :param reply_markup:
:param parse_mode :param parse_mode:
:param disable_notification: :param disable_notification:
:param timeout: :param timeout:
:param caption_entities: :param caption_entities:
@@ -1742,11 +1741,10 @@ class TeleBot:
If user is restricted for more than 366 days or less than 30 seconds from the current time, If user is restricted for more than 366 days or less than 30 seconds from the current time,
they are considered to be restricted forever they are considered to be restricted forever
:param can_send_messages: Pass True, if the user can send text messages, contacts, locations and venues :param can_send_messages: Pass True, if the user can send text messages, contacts, locations and venues
:param can_send_media_messages Pass True, if the user can send audios, documents, photos, videos, video notes :param can_send_media_messages: Pass True, if the user can send audios, documents, photos, videos, video notes
and voice notes, implies can_send_messages and voice notes, implies can_send_messages
:param can_send_polls: Pass True, if the user is allowed to send polls, implies can_send_messages :param can_send_polls: Pass True, if the user is allowed to send polls, implies can_send_messages
:param can_send_other_messages: Pass True, if the user can send animations, games, stickers and :param can_send_other_messages: Pass True, if the user can send animations, games, stickers and use inline bots, implies can_send_media_messages
use inline bots, implies can_send_media_messages
:param can_add_web_page_previews: Pass True, if the user may add web page previews to their messages, :param can_add_web_page_previews: Pass True, if the user may add web page previews to their messages,
implies can_send_media_messages implies can_send_media_messages
:param can_change_info: Pass True, if the user is allowed to change the chat title, photo and other settings. :param can_change_info: Pass True, if the user is allowed to change the chat title, photo and other settings.
@@ -2010,8 +2008,7 @@ class TeleBot:
Use this method to delete a chat photo. Photos can't be changed for private chats. Use this method to delete a chat photo. Photos can't be changed for private chats.
The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
Returns True on success. Returns True on success.
Note: In regular groups (non-supergroups), this method will only work if the All Members Are Admins Note: In regular groups (non-supergroups), this method will only work if the All Members Are Admins setting is off in the target group.
setting is off in the target group.
Telegram documentation: https://core.telegram.org/bots/api#deletechatphoto Telegram documentation: https://core.telegram.org/bots/api#deletechatphoto
@@ -2990,6 +2987,8 @@ class TeleBot:
Example: Example:
.. code-block:: python
bot = TeleBot('TOKEN') bot = TeleBot('TOKEN')
# Handles all messages which text matches regexp. # Handles all messages which text matches regexp.

View File

@@ -584,6 +584,8 @@ class AsyncTeleBot:
Example: Example:
.. code-block:: python
bot = TeleBot('TOKEN') bot = TeleBot('TOKEN')
# Handles all messages which text matches regexp. # Handles all messages which text matches regexp.
@@ -950,6 +952,7 @@ class AsyncTeleBot:
""" """
Description: TBD Description: TBD
:param func: :param func:
:param kwargs: :param kwargs:
:return: :return:
@@ -1491,9 +1494,8 @@ class AsyncTeleBot:
Telegram documentation: https://core.telegram.org/bots/api#getchatadministrators Telegram documentation: https://core.telegram.org/bots/api#getchatadministrators
:param chat_id: Unique identifier for the target chat or username :param chat_id: Unique identifier for the target chat or username of the target supergroup or channel (in the format @channelusername)
of the target supergroup or channel (in the format @channelusername) :return: API reply.
:return:
""" """
result = await asyncio_helper.get_chat_administrators(self.token, chat_id) result = await asyncio_helper.get_chat_administrators(self.token, chat_id)
return [types.ChatMember.de_json(r) for r in result] return [types.ChatMember.de_json(r) for r in result]
@@ -1527,10 +1529,9 @@ class AsyncTeleBot:
Telegram documentation: https://core.telegram.org/bots/api#setchatstickerset Telegram documentation: https://core.telegram.org/bots/api#setchatstickerset
:param chat_id: Unique identifier for the target chat or username of the target supergroup :param chat_id: Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
(in the format @supergroupusername)
:param sticker_set_name: Name of the sticker set to be set as the group sticker set :param sticker_set_name: Name of the sticker set to be set as the group sticker set
:return: :return: API reply.
""" """
result = await asyncio_helper.set_chat_sticker_set(self.token, chat_id, sticker_set_name) result = await asyncio_helper.set_chat_sticker_set(self.token, chat_id, sticker_set_name)
return result return result
@@ -1543,8 +1544,7 @@ class AsyncTeleBot:
Telegram documentation: https://core.telegram.org/bots/api#deletechatstickerset Telegram documentation: https://core.telegram.org/bots/api#deletechatstickerset
:param chat_id: Unique identifier for the target chat or username of the target supergroup :param chat_id: Unique identifier for the target chat or username of the target supergroup (in the format @supergroupusername)
(in the format @supergroupusername)
:return: API reply. :return: API reply.
""" """
result = await asyncio_helper.delete_chat_sticker_set(self.token, chat_id) result = await asyncio_helper.delete_chat_sticker_set(self.token, chat_id)
@@ -1767,10 +1767,10 @@ class AsyncTeleBot:
:param caption: :param caption:
:param duration: Duration of the audio in seconds :param duration: Duration of the audio in seconds
:param performer: Performer :param performer: Performer
:param title:Track name :param title: Track name
:param reply_to_message_id: If the message is a reply, ID of the original message :param reply_to_message_id: If the message is a reply, ID of the original message
:param reply_markup: :param reply_markup:
:param parse_mode :param parse_mode:
:param disable_notification: :param disable_notification:
:param timeout: :param timeout:
:param thumb: :param thumb:
@@ -1810,7 +1810,7 @@ class AsyncTeleBot:
:param duration: Duration of sent audio in seconds :param duration: Duration of sent audio in seconds
:param reply_to_message_id: :param reply_to_message_id:
:param reply_markup: :param reply_markup:
:param parse_mode :param parse_mode:
:param disable_notification: :param disable_notification:
:param timeout: :param timeout:
:param caption_entities: :param caption_entities:
@@ -2338,8 +2338,7 @@ class AsyncTeleBot:
Telegram documentation: https://core.telegram.org/bots/api#restrictchatmember Telegram documentation: https://core.telegram.org/bots/api#restrictchatmember
:param chat_id: Int or String : Unique identifier for the target group or username of the target supergroup :param chat_id: Int or String : Unique identifier for the target group or username of the target supergroup or channel (in the format @channelusername)
or channel (in the format @channelusername)
:param user_id: Int : Unique identifier of the target user :param user_id: Int : Unique identifier of the target user
:param until_date: Date when restrictions will be lifted for the user, unix time. :param until_date: Date when restrictions will be lifted for the user, unix time.
If user is restricted for more than 366 days or less than 30 seconds from the current time, If user is restricted for more than 366 days or less than 30 seconds from the current time,
@@ -2540,10 +2539,9 @@ class AsyncTeleBot:
Telegram documentation: https://core.telegram.org/bots/api#revokechatinvitelink Telegram documentation: https://core.telegram.org/bots/api#revokechatinvitelink
:param chat_id: Id: Unique identifier for the target chat or username of the target channel :param chat_id: Id: Unique identifier for the target chat or username of the target channel(in the format @channelusername)
(in the format @channelusername)
:param invite_link: The invite link to revoke :param invite_link: The invite link to revoke
:return: :return: API reply.
""" """
return types.ChatInviteLink.de_json( return types.ChatInviteLink.de_json(
await asyncio_helper.revoke_chat_invite_link(self.token, chat_id, invite_link) await asyncio_helper.revoke_chat_invite_link(self.token, chat_id, invite_link)
@@ -2598,13 +2596,11 @@ class AsyncTeleBot:
Use this method to set a new profile photo for the chat. Photos can't be changed for private chats. Use this method to set a new profile photo for the chat. Photos can't be changed for private chats.
The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
Returns True on success. Returns True on success.
Note: In regular groups (non-supergroups), this method will only work if the All Members Are Admins Note: In regular groups (non-supergroups), this method will only work if the All Members Are Admins setting is off in the target group.
setting is off in the target group.
Telegram documentation: https://core.telegram.org/bots/api#setchatphoto Telegram documentation: https://core.telegram.org/bots/api#setchatphoto
:param chat_id: Int or Str: Unique identifier for the target chat or username of the target channel :param chat_id: Int or Str: Unique identifier for the target chat or username of the target channel (in the format @channelusername)
(in the format @channelusername)
:param photo: InputFile: New chat photo, uploaded using multipart/form-data :param photo: InputFile: New chat photo, uploaded using multipart/form-data
:return: :return:
""" """

View File

@@ -1043,7 +1043,7 @@ class InlineKeyboardMarkup(Dictionaryable, JsonSerializable, JsonDeserializable)
This object represents an inline keyboard that appears This object represents an inline keyboard that appears
right next to the message it belongs to. right next to the message it belongs to.
:return: :return: None
""" """
if row_width > self.max_row_keys: if row_width > self.max_row_keys:
# Todo: Will be replaced with Exception in future releases # Todo: Will be replaced with Exception in future releases

View File

@@ -350,15 +350,18 @@ def quick_markup(values: Dict[str, Dict[str, Any]], row_width: int=2) -> types.I
This is useful to avoid always typing 'btn1 = InlineKeyboardButton(...)' 'btn2 = InlineKeyboardButton(...)' This is useful to avoid always typing 'btn1 = InlineKeyboardButton(...)' 'btn2 = InlineKeyboardButton(...)'
Example: Example:
.. code-block:: python
quick_markup({ quick_markup({
'Twitter': {'url': 'https://twitter.com'}, 'Twitter': {'url': 'https://twitter.com'},
'Facebook': {'url': 'https://facebook.com'}, 'Facebook': {'url': 'https://facebook.com'},
'Back': {'callback_data': 'whatever'} 'Back': {'callback_data': 'whatever'}
}, row_width=2): }, row_width=2):
returns an InlineKeyboardMarkup with two buttons in a row, one leading to Twitter, the other to facebook # returns an InlineKeyboardMarkup with two buttons in a row, one leading to Twitter, the other to facebook
and a back button below # and a back button below
kwargs can be: # kwargs can be:
{ {
'url': None, 'url': None,
'callback_data': None, 'callback_data': None,
@@ -485,11 +488,16 @@ def antiflood(function, *args, **kwargs):
Use this function inside loops in order to avoid getting TooManyRequests error. Use this function inside loops in order to avoid getting TooManyRequests error.
Example: Example:
.. code-block:: python3
from telebot.util import antiflood from telebot.util import antiflood
for chat_id in chat_id_list: for chat_id in chat_id_list:
msg = antiflood(bot.send_message, chat_id, text) msg = antiflood(bot.send_message, chat_id, text)
You want get the :param function:
:param args:
:param kwargs:
:return: None
""" """
from telebot.apihelper import ApiTelegramException from telebot.apihelper import ApiTelegramException
from time import sleep from time import sleep