Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

warning to install optional dependencies #3393

Merged
merged 11 commits into from Dec 2, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/source/examples.rst
Expand Up @@ -40,6 +40,7 @@ up a job to send a message to that user after 30 seconds. The user can
also cancel the timer by sending ``/unset``. To learn more about the
``JobQueue``, read `this wiki
article <https://github.com/python-telegram-bot/python-telegram-bot/wiki/Extensions-%E2%80%93-JobQueue>`__.
Note: To use JobQueue, you must install ptb via ``pip install python-telegram-bot[job-queue]``
clot27 marked this conversation as resolved.
Show resolved Hide resolved

:any:`examples.conversationbot`
-------------------------------
Expand Down Expand Up @@ -115,6 +116,7 @@ Don’t forget to enable and configure payments with
`@BotFather <https://telegram.me/BotFather>`_. Check out this
`guide <https://github.com/python-telegram-bot/python-telegram-bot/wiki/Telegram-Passport>`__
on Telegram passports in PTB.
Note: To use telegram passport, you must install ptb via ``pip install python-telegram-bot[passport]``
clot27 marked this conversation as resolved.
Show resolved Hide resolved

:any:`examples.paymentbot`
--------------------------
Expand Down Expand Up @@ -162,6 +164,7 @@ combination with ``telegram.ext.Application``.

This example showcases how PTBs “arbitrary callback data” feature can be
used.
Note: To use arbitrary callback data, you must install ptb via ``pip install python-telegram-bot[callback-data]``
clot27 marked this conversation as resolved.
Show resolved Hide resolved

Pure API
--------
Expand Down
3 changes: 3 additions & 0 deletions examples/arbitrarycallbackdatabot.py
Expand Up @@ -6,6 +6,9 @@

For detailed info on arbitrary callback data, see the wiki page at
https://github.com/python-telegram-bot/python-telegram-bot/wiki/Arbitrary-callback_data

Note:
To use arbitrary callback data, you must install ptb via `pip install python-telegram-bot[callback-data]`
clot27 marked this conversation as resolved.
Show resolved Hide resolved
"""
import logging
from typing import List, Tuple, cast
Expand Down
2 changes: 2 additions & 0 deletions examples/passportbot.py
Expand Up @@ -10,6 +10,8 @@
See https://github.com/python-telegram-bot/python-telegram-bot/wiki/Telegram-Passport
for how to use Telegram Passport properly with python-telegram-bot.

Note:
To use telegram passport, you must install PTB via `pip install python-telegram-bot[passport]`
clot27 marked this conversation as resolved.
Show resolved Hide resolved
"""
import logging
from pathlib import Path
Expand Down
3 changes: 3 additions & 0 deletions examples/timerbot.py
Expand Up @@ -16,6 +16,9 @@
Basic Alarm Bot example, sends a message after a set time.
Press Ctrl-C on the command line or send a signal to the process to stop the
bot.

Note:
To use arbitrary callback data you must install ptb via `pip install python-telegram-bot[callback-data]`
clot27 marked this conversation as resolved.
Show resolved Hide resolved
"""

import logging
Expand Down
6 changes: 6 additions & 0 deletions telegram/ext/_callbackcontext.py
Expand Up @@ -22,6 +22,7 @@
from telegram._callbackquery import CallbackQuery
from telegram._update import Update
from telegram.ext._extbot import ExtBot
from telegram._utils.warnings import warn
from telegram.ext._utils.types import BD, BT, CD, UD

if TYPE_CHECKING:
Expand Down Expand Up @@ -389,6 +390,11 @@ def job_queue(self) -> Optional["JobQueue"]:
.. seealso:: `Job Queue <https://github.com/python-telegram-bot/
python-telegram-bot/wiki/Extensions-%E2%80%93-JobQueue>`_
"""
if self._application.job_queue is None:
warn(
"No `JobQueue` Set up. To use `JobQueue`, you must install PTB via"
clot27 marked this conversation as resolved.
Show resolved Hide resolved
"`pip install python-telegram-bot[job_queue]`."
)
return self._application.job_queue

@property
Expand Down