Skip to content

Commit

Permalink
Add references to wiki (#3306)
Browse files Browse the repository at this point in the history
  • Loading branch information
lemontree210 committed Oct 31, 2022
1 parent 8fa8511 commit 985203d
Show file tree
Hide file tree
Showing 44 changed files with 243 additions and 21 deletions.
9 changes: 8 additions & 1 deletion telegram/_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,12 @@ class Bot(TelegramObject, AbstractAsyncContextManager):
.. seealso:: :attr:`telegram.ext.Application.bot`,
:attr:`telegram.ext.CallbackContext.bot`,
:attr:`telegram.ext.Updater.bot`
:attr:`telegram.ext.Updater.bot`,
`Your First Bot <https://github.com/\
python-telegram-bot/python-telegram-bot/wiki/Extensions-–-Your-first-Bot>`_,
`Builder Pattern <https://github.com/\
python-telegram-bot/python-telegram-bot/wiki/Builder-Pattern>`_,
:any:`Raw API Bot Example <examples.rawapibot>`
.. versionadded:: 13.2
Objects of this class are comparable in terms of equality. Two objects of this class are
Expand Down Expand Up @@ -3528,6 +3533,8 @@ async def set_webhook(
If you're having any trouble setting up webhooks, please check out this `guide to
Webhooks`_.
.. seealso:: :any:`Custom Webhook Bot Example <examples.customwebhookbot>`
Args:
url (:obj:`str`): HTTPS url to send updates to. Use an empty string to remove webhook
integration.
Expand Down
2 changes: 1 addition & 1 deletion telegram/_chatmember.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class ChatMember(TelegramObject):
Objects of this class are comparable in terms of equality. Two objects of this class are
considered equal, if their :attr:`user` and :attr:`status` are equal.
.. seealso:: :any:`Chat Member Example <examples.chatmemberbot>`
.. seealso:: :any:`Chat Member Bot Example <examples.chatmemberbot>`
.. versionchanged:: 20.0
Expand Down
2 changes: 2 additions & 0 deletions telegram/_chatmemberupdated.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ class ChatMemberUpdated(TelegramObject):
Note:
In Python :keyword:`from` is a reserved word use :paramref:`from_user` instead.
.. seealso:: :any:`Chat Member Bot Example <examples.chatmemberbot>`
Args:
chat (:class:`telegram.Chat`): Chat the user belongs to.
from_user (:class:`telegram.User`): Performer of the action, which resulted in the change.
Expand Down
3 changes: 3 additions & 0 deletions telegram/_inline/inlinekeyboardbutton.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ class InlineKeyboardButton(TelegramObject):
Tip:
The value entered here will be available in :attr:`telegram.CallbackQuery.data`.
.. seealso:: `Arbitrary callback_data <https://github.com/\
python-telegram-bot/python-telegram-bot/wiki/Arbitrary-callback_data>`_
web_app (:obj:`telegram.WebAppInfo`, optional): Description of the `Web App
<https://core.telegram.org/bots/webapps>`_ that will be launched when the user presses
the button. The Web App will be able to send an arbitrary message on behalf of the user
Expand Down
2 changes: 2 additions & 0 deletions telegram/_inline/inlinequeryresult.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ class InlineQueryResult(TelegramObject):
All URLs passed in inline query results will be available to end users and therefore must
be assumed to be *public*.
.. seealso:: :any:`Inline Bot Example <examples.inlinebot>`
Args:
type (:obj:`str`): Type of the result.
id (:obj:`str`): Unique identifier for this result, 1-64 Bytes.
Expand Down
2 changes: 2 additions & 0 deletions telegram/_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,8 @@ class Message(TelegramObject):
author_signature (:obj:`str`): Optional. Signature of the post author for messages in
channels, or the custom title of an anonymous group administrator.
passport_data (:class:`telegram.PassportData`): Optional. Telegram Passport data.
.. seealso:: :any:`Passport Bot Example <examples.passportbot>`
poll (:class:`telegram.Poll`): Optional. Message is a native poll,
information about the poll.
dice (:class:`telegram.Dice`): Optional. Message is a dice with random value.
Expand Down
3 changes: 3 additions & 0 deletions telegram/_replykeyboardmarkup.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ class ReplyKeyboardMarkup(TelegramObject):
A user requests to change the bot's language, bot replies to the request with a keyboard
to select the new language. Other users in the group don't see the keyboard.
.. seealso:: :any:`Conversationbot Example <examples.conversationbot>`,
:any:`Conversationbot Example 2 <examples.conversationbot2>`
Args:
keyboard (List[List[:obj:`str` | :class:`telegram.KeyboardButton`]]): Array of button rows,
each represented by an Array of :class:`telegram.KeyboardButton` objects.
Expand Down
3 changes: 3 additions & 0 deletions telegram/_replykeyboardremove.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ class ReplyKeyboardRemove(TelegramObject):
User will not be able to summon this keyboard; if you want to hide the keyboard from
sight but keep it accessible, use :attr:`telegram.ReplyKeyboardMarkup.one_time_keyboard`.
.. seealso:: :any:`Conversationbot Example <examples.conversationbot>`,
:any:`Conversationbot Example 2 <examples.conversationbot2>`
Args:
selective (:obj:`bool`, optional): Use this parameter if you want to remove the keyboard
for specific users only. Targets:
Expand Down
6 changes: 6 additions & 0 deletions telegram/_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ class Update(TelegramObject):
Note:
At most one of the optional parameters can be present in any given update.
.. seealso:: `Your First Bot <https://github.com/\
python-telegram-bot/python-telegram-bot/wiki/Extensions-–-Your-first-Bot>`_
Args:
update_id (:obj:`int`): The update's unique identifier. Update identifiers start from a
certain positive number and increase sequentially. This ID becomes especially handy if
Expand Down Expand Up @@ -104,6 +107,9 @@ class Update(TelegramObject):
chosen_inline_result (:class:`telegram.ChosenInlineResult`): Optional. The result of an
inline query that was chosen by a user.
callback_query (:class:`telegram.CallbackQuery`): Optional. New incoming callback query.
.. seealso:: :any:`Arbitrary Callback Data Bot Example
<examples.arbitrarycallbackdatabot>`
shipping_query (:class:`telegram.ShippingQuery`): Optional. New incoming shipping query.
pre_checkout_query (:class:`telegram.PreCheckoutQuery`): Optional. New incoming
pre-checkout query.
Expand Down
18 changes: 16 additions & 2 deletions telegram/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,12 @@ def _lstrip_str(in_s: str, lstr: str) -> str:


class TelegramError(Exception):
"""Base class for Telegram errors."""
"""
Base class for Telegram errors.
.. seealso:: `Exceptions, Warnings and Logging <https://github.com/\
python-telegram-bot/python-telegram-bot/wiki/Exceptions%2C-Warnings-and-Logging>`_
"""

__slots__ = ("message",)

Expand Down Expand Up @@ -84,6 +89,8 @@ def __reduce__(self) -> Tuple[type, Tuple[str]]:
class Forbidden(TelegramError):
"""Raised when the bot has not enough rights to perform the requested action.
.. seealso:: :any:`Raw API Bot Example <examples.rawapibot>`
.. versionchanged:: 20.0
This class was previously named ``Unauthorized``.
"""
Expand All @@ -107,7 +114,10 @@ def __init__(self, message: str = None) -> None:


class NetworkError(TelegramError):
"""Base class for exceptions due to networking errors."""
"""Base class for exceptions due to networking errors.
.. seealso:: :any:`Raw API Bot Example <examples.rawapibot>`
"""

__slots__ = ()

Expand Down Expand Up @@ -137,6 +147,10 @@ class ChatMigrated(TelegramError):
"""
Raised when the requested group chat migrated to supergroup and has a new chat id.
.. seealso:: `Storing Bot, User and Chat Related Data <https://github.com/\
python-telegram-bot/python-telegram-bot/wiki/Storing-bot%2C-user-and-\
chat-related-data>`_,
Args:
new_chat_id (:obj:`int`): The new chat id of the group.
Expand Down
3 changes: 3 additions & 0 deletions telegram/ext/_aioratelimiter.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ class AIORateLimiter(BaseRateLimiter[int]):
welcome you to implement your own subclass of :class:`~telegram.ext.BaseRateLimiter`.
Feel free to check out the source code of this class for inspiration.
.. seealso:: `Avoiding Flood Limits <https://github.com/\
python-telegram-bot/python-telegram-bot/wiki/Avoiding-flood-limits>`_
.. versionadded:: 20.0
Args:
Expand Down
26 changes: 24 additions & 2 deletions telegram/ext/_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ class Application(Generic[BT, CCT, UD, CD, BD, JQ], AbstractAsyncContextManager)
finally:
await application.shutdown()
.. seealso:: `Your First Bot <https://github.com/\
python-telegram-bot/python-telegram-bot/wiki/Extensions-–-Your-first-Bot>`_,
`Architecture Overview <https://github.com/\
python-telegram-bot/python-telegram-bot/wiki/Architecture>`_,
:any:`Echobot Example <examples.echobot>`
.. versionchanged:: 20.0
* Initialization is now done through the :class:`telegram.ext.ApplicationBuilder`.
Expand Down Expand Up @@ -323,6 +329,9 @@ def running(self) -> bool:
def concurrent_updates(self) -> int:
""":obj:`int`: The number of concurrent updates that will be processed in parallel. A
value of ``0`` indicates updates are *not* being processed concurrently.
.. seealso:: `Concurrency <https://github.com/\
python-telegram-bot/python-telegram-bot/wiki/Concurrency>`_
"""
return self._concurrent_updates

Expand Down Expand Up @@ -713,7 +722,8 @@ def run_webhook(
.. seealso::
:meth:`initialize`, :meth:`start`, :meth:`stop`, :meth:`shutdown`
:meth:`telegram.ext.Updater.start_webhook`, :meth:`telegram.ext.Updater.stop`,
:meth:`run_polling`
:meth:`run_polling`,
`Webhooks <https://github.com/python-telegram-bot/python-telegram-bot/wiki/Webhooks>`_
Args:
listen (:obj:`str`, optional): IP-Address to listen on. Defaults to
Expand Down Expand Up @@ -858,6 +868,9 @@ def create_task(self, coroutine: Coroutine, update: object = None) -> asyncio.Ta
* If the application is currently running, tasks created by this method will be
awaited with :meth:`stop`.
.. seealso:: `Concurrency <https://github.com/\
python-telegram-bot/python-telegram-bot/wiki/Concurrency>`_
Args:
coroutine (:term:`coroutine function`): The coroutine to run as task.
update (:obj:`object`, optional): If set, will be passed to :meth:`process_error`
Expand Down Expand Up @@ -974,6 +987,9 @@ async def process_update(self, update: object) -> None:
"""Processes a single update and marks the update to be updated by the persistence later.
Exceptions raised by handler callbacks will be processed by :meth:`process_update`.
.. seealso:: `Concurrency <https://github.com/\
python-telegram-bot/python-telegram-bot/wiki/Concurrency>`_
.. versionchanged:: 20.0
Persistence is now updated in an interval set by
:attr:`telegram.ext.BasePersistence.update_interval`.
Expand Down Expand Up @@ -1213,6 +1229,10 @@ def migrate_chat_data(
to the asynchronous nature of these features. Please make sure that your program can
avoid or handle such situations.
.. seealso:: `Storing Bot, User and Chat Related Data <https://github.com/\
python-telegram-bot/python-telegram-bot/wiki/Storing-bot%2C-user-and-\
chat-related-data>`_,
Args:
message (:class:`telegram.Message`, optional): A message with either
:attr:`~telegram.Message.migrate_from_chat_id` or
Expand Down Expand Up @@ -1429,7 +1449,9 @@ def add_error_handler(
Note:
Attempts to add the same callback multiple times will be ignored.
.. seealso:: :any:`Errorhandler Example <examples.errorhandlerbot>`
.. seealso:: :any:`Errorhandler Example <examples.errorhandlerbot>`,
`Exceptions, Warnings and Logging <https://github.com/\
python-telegram-bot/python-telegram-bot/wiki/Exceptions%2C-Warnings-and-Logging>`_
Args:
callback (:term:`coroutine function`): The callback function for this error handler.
Expand Down
9 changes: 7 additions & 2 deletions telegram/ext/_applicationbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ class ApplicationBuilder(Generic[BT, CCT, UD, CD, BD, JQ]):
* Unless a custom :class:`telegram.Bot` instance is set via :meth:`bot`, :meth:`build` will
use :class:`telegram.ext.ExtBot` for the bot.
.. seealso:: `Your First Bot <https://github.com/\
python-telegram-bot/python-telegram-bot/wiki/Extensions-–-Your-first-Bot>`_,
`Builder Pattern for Application <https://github.com/\
python-telegram-bot/python-telegram-bot/wiki/Builder-Pattern>`_
.. _`builder pattern`: https://en.wikipedia.org/wiki/Builder_pattern
"""

Expand Down Expand Up @@ -714,8 +719,8 @@ def arbitrary_callback_data(
cached in memory. If not called, only strings can be used as callback data and no data will
be stored in memory.
.. seealso:: `Arbitrary callback_data <https://github.com/python-telegram-bot\
/python-telegram-bot/wiki/Arbitrary-callback_data>`_,
.. seealso:: `Arbitrary callback_data <https://github.com/\
python-telegram-bot/python-telegram-bot/wiki/Arbitrary-callback_data>`_,
:any:`examples.arbitrarycallbackdatabot`
Args:
Expand Down
5 changes: 5 additions & 0 deletions telegram/ext/_basepersistence.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ class BasePersistence(Generic[UD, CD, BD], ABC):
type of the argument of :meth:`refresh_bot_data` and the return value of
:meth:`get_bot_data`.
.. seealso:: `Architecture Overview <https://github.com/\
python-telegram-bot/python-telegram-bot/wiki/Architecture>`_,
`Making Your Bot Persistent <https://github.com/\
python-telegram-bot/python-telegram-bot/wiki/Making-your-bot-persistent>`_
.. versionchanged:: 20.0
* The parameters and attributes ``store_*_data`` were replaced by :attr:`store_data`.
Expand Down
5 changes: 5 additions & 0 deletions telegram/ext/_baseratelimiter.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ class BaseRateLimiter(ABC, Generic[RLARGS]):
Hint:
Requests to :meth:`~telegram.Bot.get_updates` are never rate limited.
.. seealso:: `Architecture Overview <https://github.com/\
python-telegram-bot/python-telegram-bot/wiki/Architecture>`_,
`Avoiding Flood Limits <https://github.com/\
python-telegram-bot/python-telegram-bot/wiki/Avoiding-flood-limits>`_
.. versionadded:: 20.0
"""

Expand Down
23 changes: 22 additions & 1 deletion telegram/ext/_callbackcontext.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ class CallbackContext(Generic[BT, UD, CD, BD]):
3. The type of :attr:`chat_data` (if :attr:`chat_data` is not :obj:`None`).
4. The type of :attr:`bot_data` (if :attr:`bot_data` is not :obj:`None`).
.. seealso:: :attr:`telegram.ext.ContextTypes.DEFAULT_TYPE`
.. seealso:: :attr:`telegram.ext.ContextTypes.DEFAULT_TYPE`,
`Job Queue <https://github.com/python-telegram-bot/
python-telegram-bot/wiki/Extensions-%E2%80%93-JobQueue>`_,
:any:`Context Types Bot Example <examples.contexttypesbot>`,
:any:`Custom Webhook Bot Example <examples.customwebhookbot>`
Args:
application (:class:`telegram.ext.Application`): The application associated with this
Expand Down Expand Up @@ -138,6 +142,10 @@ def application(self) -> "Application[BT, CCT, UD, CD, BD, Any]":
def bot_data(self) -> BD:
""":obj:`ContextTypes.bot_data`: Optional. An object that can be used to keep any data in.
For each update it will be the same :attr:`ContextTypes.bot_data`. Defaults to :obj:`dict`.
.. seealso:: `Storing Bot, User and Chat Related Data <https://github.com/\
python-telegram-bot/python-telegram-bot/wiki/Storing-bot%2C-user-and-\
chat-related-data>`_,
"""
return self.application.bot_data

Expand All @@ -159,6 +167,10 @@ def chat_data(self) -> Optional[CD]:
<https://github.com/python-telegram-bot/python-telegram-bot/wiki/
Storing-bot,-user-and-chat-related-data#chat-migration>`_.
.. seealso:: `Storing Bot, User and Chat Related Data <https://github.com/\
python-telegram-bot/python-telegram-bot/wiki/Storing-bot%2C-user-and-\
chat-related-data>`_,
.. versionchanged:: 20.0
The chat data is now also present in error handlers if the error is caused by a job.
"""
Expand All @@ -178,6 +190,10 @@ def user_data(self) -> Optional[UD]:
For each update from the same user it will be the same :obj:`ContextTypes.user_data`.
Defaults to :obj:`dict`.
.. seealso:: `Storing Bot, User and Chat Related Data <https://github.com/\
python-telegram-bot/python-telegram-bot/wiki/Storing-bot%2C-user-and\
-chat-related-data>`_,
.. versionchanged:: 20.0
The user data is now also present in error handlers if the error is caused by a job.
"""
Expand Down Expand Up @@ -225,6 +241,9 @@ def drop_callback_data(self, callback_query: CallbackQuery) -> None:
Will *not* raise exceptions in case the data is not found in the cache.
*Will* raise :exc:`KeyError` in case the callback query can not be found in the cache.
.. seealso:: `Arbitrary callback_data <https://github.com/\
python-telegram-bot/python-telegram-bot/wiki/Arbitrary-callback_data>`_
Args:
callback_query (:class:`telegram.CallbackQuery`): The callback query.
Expand Down Expand Up @@ -365,6 +384,8 @@ def job_queue(self) -> Optional["JobQueue"]:
:class:`telegram.ext.JobQueue`: The :class:`JobQueue` used by the
:class:`telegram.ext.Application`.
.. seealso:: `Job Queue <https://github.com/python-telegram-bot/
python-telegram-bot/wiki/Extensions-%E2%80%93-JobQueue>`_
"""
return self._application.job_queue

Expand Down
10 changes: 8 additions & 2 deletions telegram/ext/_callbackdatacache.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ class InvalidCallbackData(TelegramError):
"""
Raised when the received callback data has been tempered with or deleted from cache.
.. seealso:: `Arbitrary callback_data <https://github.com/\
python-telegram-bot/python-telegram-bot/wiki/Arbitrary-callback_data>`_,
:any:`Arbitrary Callback Data Bot Example <examples.arbitrarycallbackdatabot>`
.. versionadded:: 13.6
Args:
Expand Down Expand Up @@ -95,8 +99,10 @@ class CallbackDataCache:
If necessary, will drop the least recently used items.
.. seealso:: :attr:`telegram.ext.ExtBot.callback_data_cache`,
`Arbitrary callback_data <https://github.com/python-telegram-bot/
python-telegram-bot/wiki/Arbitrary-callback_data>`_,
`Architecture Overview <https://github.com/\
python-telegram-bot/python-telegram-bot/wiki/Architecture>`_,
`Arbitrary callback_data <https://github.com/\
python-telegram-bot/python-telegram-bot/wiki/Arbitrary-callback_data>`_,
`Arbitrary Callback Data Example <examples.arbitrarycallbackdatabot.html>`_
.. versionadded:: 13.6
Expand Down
6 changes: 6 additions & 0 deletions telegram/ext/_callbackqueryhandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,18 @@ async def callback(update: Update, context: CallbackContext)
If :attr:`telegram.CallbackQuery.data` is :obj:`None`, the
:class:`telegram.CallbackQuery` update will not be handled.
.. seealso:: `Arbitrary callback_data <https://github.com/\
python-telegram-bot/python-telegram-bot/wiki/Arbitrary-callback_data>`_
.. versionchanged:: 13.6
Added support for arbitrary callback data.
block (:obj:`bool`, optional): Determines whether the return value of the callback should
be awaited before processing the next handler in
:meth:`telegram.ext.Application.process_update`. Defaults to :obj:`True`.
.. seealso:: `Concurrency <https://github.com/\
python-telegram-bot/python-telegram-bot/wiki/Concurrency>`_
Attributes:
callback (:term:`coroutine function`): The callback function for this handler.
pattern (:func:`re.Pattern <re.compile>` | :obj:`callable` | :obj:`type`): Optional.
Expand Down

0 comments on commit 985203d

Please sign in to comment.