Skip to content

telegram module

Messaging using python-telegram-bot.


self_decorator function

self_decorator(
    func
)

Pass bot object to func command.


send_action function

send_action(
    action
)

Sends action while processing func command.

Suitable only for bound callbacks taking arguments self, update, context and optionally other.


LogHandler class

LogHandler()

Handler to log user updates.

Superclasses

  • abc.ABC
  • telegram.ext._handlers.basehandler.BaseHandler
  • typing.Generic

check_update method

LogHandler.check_update(
    update
)

This method is called to determine if an update should be handled by this handler instance. It should always be overridden.

Note

Custom updates types can be handled by the application. Therefore, an implementation of this method should always check the type of :paramref:update.

Args

update : :obj:object| :class:telegram.Update``
The update to be tested.

Returns

Either
obj:None or :obj:False if the update should not be handled. Otherwise an
object that will be passed to
meth:handle_update and

:meth:collect_additional_context when the update gets handled.


TelegramBot class

TelegramBot(
    giphy_kwargs=None,
    **kwargs
)

Blocking Telegram bot for python-telegram-bot 20 and later.

**kwargs are passed to telegram.ext.ApplicationBuilder when they match a builder method and to telegram.ext.Updater.start_polling from start.

Superclasses

Inherited members


application property

Application.


chat_ids property

Chat ids that ever interacted with this bot.

A chat id is added upon receiving the "/start" command.


chat_migration_callback method

TelegramBot.chat_migration_callback(
    update,
    context
)

Chat migration callback.


custom_handlers property

Custom handlers to add.

Override to add custom handlers. Order counts.


dispatcher property

Dispatcher-like application.


error_callback method

TelegramBot.error_callback(
    update,
    context,
    *args
)

Error callback.


help_callback method

TelegramBot.help_callback(
    update,
    context
)

Help command callback.


help_message property

Message to be sent upon "/help" command.

Override to define your own message.


log_handler property

Log handler.


running property

Whether the bot is running.


send method

TelegramBot.send(
    kind,
    chat_id,
    *args,
    log_msg=None,
    **kwargs
)

Send message of any kind to chat_id.


send_giphy method

TelegramBot.send_giphy(
    chat_id,
    text,
    *args,
    giphy_kwargs=None,
    **kwargs
)

Send GIPHY from text to chat_id.


send_giphy_to_all method

TelegramBot.send_giphy_to_all(
    text,
    *args,
    giphy_kwargs=None,
    **kwargs
)

Send GIPHY from text to all in TelegramBot.chat_ids.


send_message method

TelegramBot.send_message(
    chat_id,
    text,
    *args,
    **kwargs
)

Send text message to chat_id.


send_message_to_all method

TelegramBot.send_message_to_all(
    text,
    *args,
    **kwargs
)

Send text message to all in TelegramBot.chat_ids.


send_to_all method

TelegramBot.send_to_all(
    kind,
    *args,
    **kwargs
)

Send message of any kind to all in TelegramBot.chat_ids.


start method

TelegramBot.start(
    in_background=False,
    **kwargs
)

Start the bot.

**kwargs are passed to telegram.ext.Updater.start_polling and override settings under messaging.telegram in settings.


start_callback method

TelegramBot.start_callback(
    update,
    context
)

Start command callback.


start_message property

Message to be sent upon "/start" command.

Override to define your own message.


started_callback method

TelegramBot.started_callback()

Callback once the bot has been started.

Override to execute custom commands upon starting the bot.


stop method

TelegramBot.stop()

Stop the bot.


unknown_callback method

TelegramBot.unknown_callback(
    update,
    context
)

Unknown command callback.


updater property

Updater.