Module contents

Modules used during debug

async spotted.debug.error_handler(update, context)[source]

Logs the error and notifies the admins.

Parameters:
async spotted.debug.log_message(update, _)[source]

Log the message that caused the update

Parameters:
  • update (Update) – update event

  • context – context passed by the handler

spotted.debug package

Submodules

spotted.debug.log_manager module

Handles the logging of events

class spotted.debug.log_manager.CallbackContext(application, chat_id=None, user_id=None)[source]

Bases: Generic[BT, UD, CD, BD]

This is a context object passed to the callback called by telegram.ext.BaseHandler or by the telegram.ext.Application in an error handler added by telegram.ext.Application.add_error_handler or to the callback of a telegram.ext.Job.

Note

telegram.ext.Application will create a single context for an entire update. This means that if you got 2 handlers in different groups and they both get called, they will receive the same CallbackContext object (of course with proper attributes like matches differing). This allows you to add custom attributes in a lower handler group callback, and then subsequently access those attributes in a higher handler group callback. Note that the attributes on CallbackContext might change in the future, so make sure to use a fairly unique name for the attributes.

Warning

Do not combine custom attributes with telegram.ext.BaseHandler.block set to False or telegram.ext.Application.concurrent_updates set to True. Due to how those work, it will almost certainly execute the callbacks for an update out of order, and the attributes that you think you added will not be present.

This class is a Generic class and accepts four type variables:

  1. The type of bot. Must be telegram.Bot or a subclass of that class.

  2. The type of user_data (if user_data is not None).

  3. The type of chat_data (if chat_data is not None).

  4. The type of bot_data (if bot_data is not None).

Examples

  • Context Types Bot

  • Custom Webhook Bot

See also

telegram.ext.ContextTypes.DEFAULT_TYPE, Job Queue <Extensions---JobQueue>

Parameters:
  • application (Application[TypeVar(BT, bound= Bot), TypeVar(ST, bound= CallbackContext[Any, Any, Any, Any]), TypeVar(UD), TypeVar(CD), TypeVar(BD), Any]) – The application associated with this context.

  • chat_id (int | None, default: None) –

    The ID of the chat associated with this object. Used to provide chat_data.

    Added in version 20.0.

  • user_id (int | None, default: None) –

    The ID of the user associated with this object. Used to provide user_data.

    Added in version 20.0.

coroutine

Optional. Only present in error handlers if the error was caused by an awaitable run with Application.create_task() or a handler callback with block=False.

Type:

awaitable

matches

Optional. If the associated update originated from a filters.Regex, this will contain a list of match objects for every pattern where re.search(pattern, string) returned a match. Note that filters short circuit, so combined regex filters will not always be evaluated.

Type:

list[re.Match]

args

Optional. Arguments passed to a command if the associated update is handled by telegram.ext.CommandHandler, telegram.ext.PrefixHandler or telegram.ext.StringCommandHandler. It contains a list of the words in the text after the command, using any whitespace string as a delimiter.

Type:

list[str]

error

Optional. The error that was raised. Only present when passed to an error handler registered with telegram.ext.Application.add_error_handler.

Type:

Exception

job

Optional. The job which originated this callback. Only present when passed to the callback of telegram.ext.Job or in error handlers if the error is caused by a job.

Changed in version 20.0: job is now also present in error handlers if the error is caused by a job.

Type:

telegram.ext.Job

property application: Application[BT, ST, UD, CD, BD, Any]

The application associated with this context.

Type:

telegram.ext.Application

args: list[str] | None
property bot: BT

The bot associated with this context.

Type:

telegram.Bot

property bot_data: BD

Optional. An object that can be used to keep any data in. For each update it will be the same ContextTypes.bot_data. Defaults to dict.

See also

Storing Bot, User and Chat Related Data            <Storing-bot%2C-user-and-chat-related-data>

Type:

ContextTypes.bot_data

property chat_data: CD | None

Optional. An object that can be used to keep any data in. For each update from the same chat id it will be the same ContextTypes.chat_data. Defaults to dict.

Warning

When a group chat migrates to a supergroup, its chat id will change and the chat_data needs to be transferred. For details see our wiki page <Storing-bot,-user-and-chat-related-data#chat-migration>.

See also

Storing Bot, User and Chat Related Data            <Storing-bot%2C-user-and-chat-related-data>

Changed in version 20.0: The chat data is now also present in error handlers if the error is caused by a job.

Type:

ContextTypes.chat_data

coroutine: Generator[Future[object] | None, None, Any] | Awaitable[Any] | None
drop_callback_data(callback_query)[source]

Deletes the cached data for the specified callback query.

Added in version 13.6.

Note

Will not raise exceptions in case the data is not found in the cache. Will raise KeyError in case the callback query can not be found in the cache.

See also

Arbitrary callback_data <Arbitrary-callback_data>

Parameters:

callback_query (CallbackQuery) – The callback query.

Raises:

KeyError | RuntimeErrorKeyError, if the callback query can not be found in the cache and RuntimeError, if the bot doesn’t allow for arbitrary callback data.

Return type:

None

error: Exception | None
classmethod from_error(update, error, application, job=None, coroutine=None)[source]

Constructs an instance of telegram.ext.CallbackContext to be passed to the error handlers.

Changed in version 20.0: Removed arguments async_args and async_kwargs.

Parameters:
  • update (object) – The update associated with the error. May be None, e.g. for errors in job callbacks.

  • error (Exception) – The error.

  • application (Application[TypeVar(BT, bound= Bot), TypeVar(CCT, bound= CallbackContext[Any, Any, Any, Any]), TypeVar(UD), TypeVar(CD), TypeVar(BD), Any]) – The application associated with this context.

  • job (Job[Any] | None, default: None) –

    The job associated with the error.

    Added in version 20.0.

  • coroutine (Generator[Future[object] | None, None, Any] | Awaitable[Any] | None, default: None) –

    The awaitable associated with this error if the error was caused by a coroutine run with Application.create_task() or a handler callback with block=False.

    Added in version 20.0.

    Changed in version 20.2: Accepts asyncio.Future and generator-based coroutine functions.

Returns:

TypeVar(CCT, bound= CallbackContext[Any, Any, Any, Any])telegram.ext.CallbackContext

classmethod from_job(job, application)[source]

Constructs an instance of telegram.ext.CallbackContext to be passed to a job callback.

See also

telegram.ext.JobQueue()

Parameters:
  • job (Job[TypeVar(CCT, bound= CallbackContext[Any, Any, Any, Any])]) – The job.

  • application (Application[Any, TypeVar(CCT, bound= CallbackContext[Any, Any, Any, Any]), Any, Any, Any, Any]) – The application associated with this context.

Returns:

TypeVar(CCT, bound= CallbackContext[Any, Any, Any, Any])telegram.ext.CallbackContext

classmethod from_update(update, application)[source]

Constructs an instance of telegram.ext.CallbackContext to be passed to the handlers.

Parameters:
Returns:

TypeVar(CCT, bound= CallbackContext[Any, Any, Any, Any])telegram.ext.CallbackContext

job: Job[Any] | None
property job_queue: JobQueue[ST] | None

The JobQueue used by the telegram.ext.Application.

See also

Job Queue <Extensions---JobQueue>

Type:

telegram.ext.JobQueue

property match: Match[str] | None

The first match from matches. Useful if you are only filtering using a single regex filter. Returns None if matches is empty.

Type:

re.Match

matches: list[Match[str]] | None
async refresh_data()[source]

If application uses persistence, calls telegram.ext.BasePersistence.refresh_bot_data() on bot_data, telegram.ext.BasePersistence.refresh_chat_data() on chat_data and telegram.ext.BasePersistence.refresh_user_data() on user_data, if appropriate.

Will be called by telegram.ext.Application.process_update() and telegram.ext.Job.run().

Added in version 13.6.

Return type:

None

update(data)[source]

Updates self.__slots__ with the passed data.

Parameters:

data (dict[str, object]) – The data.

Return type:

None

property update_queue: Queue[object]

The asyncio.Queue instance used by the telegram.ext.Application and (usually) the telegram.ext.Updater associated with this context.

Type:

asyncio.Queue

property user_data: UD | None

Optional. An object that can be used to keep any data in. For each update from the same user it will be the same ContextTypes.user_data. Defaults to dict.

See also

Storing Bot, User and Chat Related Data            <Storing-bot%2C-user-and-chat-related-data>

Changed in version 20.0: The user data is now also present in error handlers if the error is caused by a job.

Type:

ContextTypes.user_data

class spotted.debug.log_manager.Config[source]

Bases: object

Configurations

AUTOREPLIES_PATH = 'autoreplies.yaml'
DEFAULT_AUTOREPLIES_PATH = '/opt/hostedtoolcache/Python/3.14.3/x64/lib/python3.14/site-packages/spotted/config/yaml/autoreplies.yaml'
DEFAULT_SETTINGS_PATH = '/opt/hostedtoolcache/Python/3.14.3/x64/lib/python3.14/site-packages/spotted/config/yaml/settings.yaml'
SETTINGS_PATH = 'settings.yaml'
classmethod autoreplies_get(*keys, default=None)[source]

Get the value of the specified key in the autoreplies configuration dictionary. If the key is a tuple, it will return the value of the nested key. If the key is not present, it will return the default value.

Parameters:
  • key – key to get

  • default (Any, default: None) – default value to return if the key is not present

Returns:

dict – value of the key or default value

classmethod debug_get(key, default=None)[source]

Get the value of the specified key in the configuration under the ‘debug’ section. If the key is not present, it will return the default value.

Parameters:
  • key (Literal['local_log', 'reset_on_load', 'log_file', 'log_error_file', 'db_file', 'backup_chat_id', 'backup_keep_pending', 'crypto_key', 'zip_backup']) – key to get

  • default (Any, default: None) – default value to return if the key is not present

Returns:

Any – value of the key or default value

classmethod override_settings(config)[source]

Overrides the settings with the configuration provided in the config dict.

Parameters:

config (dict) – configuration dict used to override the current settings

classmethod post_get(key, default=None)[source]

Get the value of the specified key in the configuration under the ‘post’ section. If the key is not present, it will return the default value.

Parameters:
  • key (Literal['community_group_id', 'channel_id', 'channel_tag', 'comments', 'admin_group_id', 'n_votes', 'remove_after_h', 'report', 'report_wait_mins', 'replace_anonymous_comments', 'delete_anonymous_comments', 'blacklist_messages', 'max_n_warns', 'warn_expiration_days', 'mute_default_duration_days', 'autoreplies_per_page', 'reject_after_autoreply']) – key to get

  • default (Any, default: None) – default value to return if the key is not present

Returns:

Any – value of the key or default value

classmethod reload(force_reload=False)[source]

Reset the configuration. The next time a setting parameter is required, the whole configuration will be reloaded. If force_reload is True, the configuration will be reloaded immediately.

Parameters:

force_reload (bool, default: False) – if True, the configuration will be reloaded immediately

classmethod settings_get(*keys, default=None)[source]

Get the value of the specified key in the configuration. If the key is a tuple, it will return the value of the nested key. If the key is not present, it will return the default value.

Parameters:
  • key – key to get

  • default (Any, default: None) – default value to return if the key is not present

Returns:

Any – value of the key or default value

class spotted.debug.log_manager.ParseMode(*values)[source]

Bases: StringEnum

This enum contains the available parse modes. The enum members of this enumeration are instances of str and can be treated as such.

Added in version 20.0.

HTML = 'HTML'

HTML parse mode.

Type:

str

MARKDOWN = 'Markdown'

Markdown parse mode.

Note

MARKDOWN is a legacy mode, retained by Telegram for backward compatibility. You should use MARKDOWN_V2 instead.

Type:

str

MARKDOWN_V2 = 'MarkdownV2'

Markdown parse mode version 2.

Type:

str

class spotted.debug.log_manager.Path(*args, **kwargs)[source]

Bases: PurePath

PurePath subclass that can make system calls.

Path represents a filesystem path but unlike PurePath, also offers methods to do system calls on path objects. Depending on your system, instantiating a Path will return either a PosixPath or a WindowsPath object. You can also instantiate a PosixPath or WindowsPath directly, but cannot instantiate a WindowsPath on a POSIX system or vice versa.

absolute()[source]

Return an absolute version of this path No normalization or symlink resolution is performed.

Use resolve() to resolve symlinks and remove ‘..’ segments.

as_uri()[source]

Return the path as a URI.

chmod(mode, *, follow_symlinks=True)[source]

Change the permissions of the path, like os.chmod().

copy(target, **kwargs)[source]

Recursively copy this file or directory tree to the given destination.

copy_into(target_dir, **kwargs)[source]

Copy this file or directory tree into the given existing directory.

classmethod cwd()[source]

Return a new path pointing to the current working directory.

exists(*, follow_symlinks=True)[source]

Whether this path exists.

This method normally follows symlinks; to check whether a symlink exists, add the argument follow_symlinks=False.

expanduser()[source]

Return a new path with expanded ~ and ~user constructs (as returned by os.path.expanduser)

classmethod from_uri(uri)[source]

Return a new path from the given ‘file’ URI.

glob(pattern, *, case_sensitive=None, recurse_symlinks=False)[source]

Iterate over this subtree and yield all existing files (of any kind, including directories) matching the given relative pattern.

group(*, follow_symlinks=True)[source]

Return the group name of the file gid.

Make this path a hard link pointing to the same file as target.

Note the order of arguments (self, target) is the reverse of os.link’s.

classmethod home()[source]

Return a new path pointing to expanduser(‘~’).

property info

A PathInfo object that exposes the file type and other file attributes of this path.

is_block_device()[source]

Whether this path is a block device.

is_char_device()[source]

Whether this path is a character device.

is_dir(*, follow_symlinks=True)[source]

Whether this path is a directory.

is_fifo()[source]

Whether this path is a FIFO.

is_file(*, follow_symlinks=True)[source]

Whether this path is a regular file (also True for symlinks pointing to regular files).

is_junction()[source]

Whether this path is a junction.

is_mount()[source]

Check if this path is a mount point

is_socket()[source]

Whether this path is a socket.

Whether this path is a symbolic link.

iterdir()[source]

Yield path objects of the directory contents.

The children are yielded in arbitrary order, and the special entries ‘.’ and ‘..’ are not included.

lchmod(mode)[source]

Like chmod(), except if the path points to a symlink, the symlink’s permissions are changed, rather than its target’s.

lstat()[source]

Like stat(), except if the path points to a symlink, the symlink’s status information is returned, rather than its target’s.

mkdir(mode=511, parents=False, exist_ok=False)[source]

Create a new directory at this given path.

move(target)[source]

Recursively move this file or directory tree to the given destination.

move_into(target_dir)[source]

Move this file or directory tree into the given existing directory.

open(mode='r', buffering=-1, encoding=None, errors=None, newline=None)[source]

Open the file pointed to by this path and return a file object, as the built-in open() function does.

owner(*, follow_symlinks=True)[source]

Return the login name of the file owner.

read_bytes()[source]

Open the file in bytes mode, read it, and close the file.

read_text(encoding=None, errors=None, newline=None)[source]

Open the file in text mode, read it, and close the file.

Return the path to which the symbolic link points.

rename(target)[source]

Rename this path to the target path.

The target path may be absolute or relative. Relative paths are interpreted relative to the current working directory, not the directory of the Path object.

Returns the new Path instance pointing to the target path.

replace(target)[source]

Rename this path to the target path, overwriting if that path exists.

The target path may be absolute or relative. Relative paths are interpreted relative to the current working directory, not the directory of the Path object.

Returns the new Path instance pointing to the target path.

resolve(strict=False)[source]

Make the path absolute, resolving all symlinks on the way and also normalizing it.

rglob(pattern, *, case_sensitive=None, recurse_symlinks=False)[source]

Recursively yield all existing files (of any kind, including directories) matching the given relative pattern, anywhere in this subtree.

rmdir()[source]

Remove this directory. The directory must be empty.

samefile(other_path)[source]

Return whether other_path is the same or not as this file (as returned by os.path.samefile()).

stat(*, follow_symlinks=True)[source]

Return the result of the stat() system call on this path, like os.stat() does.

Make this path a symlink pointing to the target path. Note the order of arguments (link, target) is the reverse of os.symlink.

touch(mode=438, exist_ok=True)[source]

Create this file with the given access mode, if it doesn’t exist.

Remove this file or link. If the path is a directory, use rmdir() instead.

walk(top_down=True, on_error=None, follow_symlinks=False)[source]

Walk the directory tree from this directory, similar to os.walk().

write_bytes(data)[source]

Open the file in bytes mode, write to it, and close the file.

write_text(data, encoding=None, errors=None, newline=None)[source]

Open the file in text mode, write to it, and close the file.

class spotted.debug.log_manager.Update(update_id, message=None, edited_message=None, channel_post=None, edited_channel_post=None, inline_query=None, chosen_inline_result=None, callback_query=None, shipping_query=None, pre_checkout_query=None, poll=None, poll_answer=None, my_chat_member=None, chat_member=None, chat_join_request=None, chat_boost=None, removed_chat_boost=None, message_reaction=None, message_reaction_count=None, business_connection=None, business_message=None, edited_business_message=None, deleted_business_messages=None, purchased_paid_media=None, *, api_kwargs=None)[source]

Bases: TelegramObject

This object represents an incoming update.

Objects of this class are comparable in terms of equality. Two objects of this class are considered equal, if their update_id is equal.

Note

At most one of the optional parameters can be present in any given update.

See also

Your First Bot <Extensions---Your-first-Bot>

Parameters:
  • update_id (int) – The update’s unique identifier. Update identifiers start from a certain positive number and increase sequentially. This ID becomes especially handy if you’re using Webhooks, since it allows you to ignore repeated updates or to restore the correct update sequence, should they get out of order. If there are no new updates for at least a week, then identifier of the next update will be chosen randomly instead of sequentially.

  • message (Message | None, default: None) – New incoming message of any kind - text, photo, sticker, etc.

  • edited_message (Message | None, default: None) – New version of a message that is known to the bot and was edited. This update may at times be triggered by changes to message fields that are either unavailable or not actively used by your bot.

  • channel_post (Message | None, default: None) – New incoming channel post of any kind - text, photo, sticker, etc.

  • edited_channel_post (Message | None, default: None) – New version of a channel post that is known to the bot and was edited. This update may at times be triggered by changes to message fields that are either unavailable or not actively used by your bot.

  • inline_query (InlineQuery | None, default: None) – New incoming inline query.

  • chosen_inline_result (ChosenInlineResult | None, default: None) – The result of an inline query that was chosen by a user and sent to their chat partner.

  • callback_query (CallbackQuery | None, default: None) – New incoming callback query.

  • shipping_query (ShippingQuery | None, default: None) – New incoming shipping query. Only for invoices with flexible price.

  • pre_checkout_query (PreCheckoutQuery | None, default: None) – New incoming pre-checkout query. Contains full information about checkout.

  • poll (Poll | None, default: None) – New poll state. Bots receive only updates about manually stopped polls and polls, which are sent by the bot.

  • poll_answer (PollAnswer | None, default: None) – A user changed their answer in a non-anonymous poll. Bots receive new votes only in polls that were sent by the bot itself.

  • my_chat_member (ChatMemberUpdated | None, default: None) –

    The bot’s chat member status was updated in a chat. For private chats, this update is received only when the bot is blocked or unblocked by the user.

    Added in version 13.4.

  • chat_member (ChatMemberUpdated | None, default: None) –

    A chat member’s status was updated in a chat. The bot must be an administrator in the chat and must explicitly specify CHAT_MEMBER in the list of telegram.ext.Application.run_polling.allowed_updates to receive these updates (see telegram.Bot.get_updates(), telegram.Bot.set_webhook(), telegram.ext.Application.run_polling() and telegram.ext.Application.run_webhook()).

    Added in version 13.4.

  • chat_join_request (ChatJoinRequest | None, default: None) –

    A request to join the chat has been sent. The bot must have the telegram.ChatPermissions.can_invite_users administrator right in the chat to receive these updates.

    Added in version 13.8.

  • chat_boost (ChatBoostUpdated | None, default: None) –

    A chat boost was added or changed. The bot must be an administrator in the chat to receive these updates.

    Added in version 20.8.

  • removed_chat_boost (ChatBoostRemoved | None, default: None) –

    A boost was removed from a chat. The bot must be an administrator in the chat to receive these updates.

    Added in version 20.8.

  • message_reaction (MessageReactionUpdated | None, default: None) –

    A reaction to a message was changed by a user. The bot must be an administrator in the chat and must explicitly specify MESSAGE_REACTION in the list of telegram.ext.Application.run_polling.allowed_updates to receive these updates (see telegram.Bot.get_updates(), telegram.Bot.set_webhook(), telegram.ext.Application.run_polling() and telegram.ext.Application.run_webhook()). The update isn’t received for reactions set by bots.

    Added in version 20.8.

  • message_reaction_count (MessageReactionCountUpdated | None, default: None) –

    Reactions to a message with anonymous reactions were changed. The bot must be an administrator in the chat and must explicitly specify MESSAGE_REACTION_COUNT in the list of telegram.ext.Application.run_polling.allowed_updates to receive these updates (see telegram.Bot.get_updates(), telegram.Bot.set_webhook(), telegram.ext.Application.run_polling() and telegram.ext.Application.run_webhook()). The updates are grouped and can be sent with delay up to a few minutes.

    Added in version 20.8.

  • business_connection (BusinessConnection | None, default: None) –

    The bot was connected to or disconnected from a business account, or a user edited an existing connection with the bot.

    Added in version 21.1.

  • business_message (Message | None, default: None) –

    New message from a connected business account.

    Added in version 21.1.

  • edited_business_message (Message | None, default: None) –

    New version of a message from a connected business account.

    Added in version 21.1.

  • deleted_business_messages (BusinessMessagesDeleted | None, default: None) –

    Messages were deleted from a connected business account.

    Added in version 21.1.

  • purchased_paid_media (PaidMediaPurchased | None, default: None) –

    A user purchased paid media with a non-empty payload sent by the bot in a non-channel chat.

    Added in version 21.6.

update_id

The update’s unique identifier. Update identifiers start from a certain positive number and increase sequentially. This ID becomes especially handy if you’re using Webhooks, since it allows you to ignore repeated updates or to restore the correct update sequence, should they get out of order. If there are no new updates for at least a week, then identifier of the next update will be chosen randomly instead of sequentially.

Type:

int

message

Optional. New incoming message of any kind - text, photo, sticker, etc.

Type:

telegram.Message

edited_message

Optional. New version of a message that is known to the bot and was edited. This update may at times be triggered by changes to message fields that are either unavailable or not actively used by your bot.

Type:

telegram.Message

channel_post

Optional. New incoming channel post of any kind - text, photo, sticker, etc.

Type:

telegram.Message

edited_channel_post

Optional. New version of a channel post that is known to the bot and was edited. This update may at times be triggered by changes to message fields that are either unavailable or not actively used by your bot.

Type:

telegram.Message

inline_query

Optional. New incoming inline query.

Type:

telegram.InlineQuery

chosen_inline_result

Optional. The result of an inline query that was chosen by a user and sent to their chat partner.

Type:

telegram.ChosenInlineResult

callback_query

Optional. New incoming callback query.

Examples

Arbitrary Callback Data Bot

Type:

telegram.CallbackQuery

shipping_query

Optional. New incoming shipping query. Only for invoices with flexible price.

Type:

telegram.ShippingQuery

pre_checkout_query

Optional. New incoming pre-checkout query. Contains full information about checkout.

Type:

telegram.PreCheckoutQuery

poll

Optional. New poll state. Bots receive only updates about manually stopped polls and polls, which are sent by the bot.

Type:

telegram.Poll

poll_answer

Optional. A user changed their answer in a non-anonymous poll. Bots receive new votes only in polls that were sent by the bot itself.

Type:

telegram.PollAnswer

my_chat_member

Optional. The bot’s chat member status was updated in a chat. For private chats, this update is received only when the bot is blocked or unblocked by the user.

Added in version 13.4.

Type:

telegram.ChatMemberUpdated

chat_member

Optional. A chat member’s status was updated in a chat. The bot must be an administrator in the chat and must explicitly specify CHAT_MEMBER in the list of telegram.ext.Application.run_polling.allowed_updates to receive these updates (see telegram.Bot.get_updates(), telegram.Bot.set_webhook(), telegram.ext.Application.run_polling() and telegram.ext.Application.run_webhook()).

Added in version 13.4.

Type:

telegram.ChatMemberUpdated

chat_join_request

Optional. A request to join the chat has been sent. The bot must have the telegram.ChatPermissions.can_invite_users administrator right in the chat to receive these updates.

Added in version 13.8.

Type:

telegram.ChatJoinRequest

chat_boost

Optional. A chat boost was added or changed. The bot must be an administrator in the chat to receive these updates.

Added in version 20.8.

Type:

telegram.ChatBoostUpdated

removed_chat_boost

Optional. A boost was removed from a chat. The bot must be an administrator in the chat to receive these updates.

Added in version 20.8.

Type:

telegram.ChatBoostRemoved

message_reaction

Optional. A reaction to a message was changed by a user. The bot must be an administrator in the chat and must explicitly specify MESSAGE_REACTION in the list of telegram.ext.Application.run_polling.allowed_updates to receive these updates (see telegram.Bot.get_updates(), telegram.Bot.set_webhook(), telegram.ext.Application.run_polling() and telegram.ext.Application.run_webhook()). The update isn’t received for reactions set by bots.

Added in version 20.8.

Type:

telegram.MessageReactionUpdated

message_reaction_count

Optional. Reactions to a message with anonymous reactions were changed. The bot must be an administrator in the chat and must explicitly specify MESSAGE_REACTION_COUNT in the list of telegram.ext.Application.run_polling.allowed_updates to receive these updates (see telegram.Bot.get_updates(), telegram.Bot.set_webhook(), telegram.ext.Application.run_polling() and telegram.ext.Application.run_webhook()). The updates are grouped and can be sent with delay up to a few minutes.

Added in version 20.8.

Type:

telegram.MessageReactionCountUpdated

business_connection

Optional. The bot was connected to or disconnected from a business account, or a user edited an existing connection with the bot.

Added in version 21.1.

Type:

telegram.BusinessConnection

business_message

Optional. New message from a connected business account.

Added in version 21.1.

Type:

telegram.Message

edited_business_message

Optional. New version of a message from a connected business account.

Added in version 21.1.

Type:

telegram.Message

deleted_business_messages

Optional. Messages were deleted from a connected business account.

Added in version 21.1.

Type:

telegram.BusinessMessagesDeleted

purchased_paid_media

Optional. A user purchased paid media with a non-empty payload sent by the bot in a non-channel chat.

Added in version 21.6.

Type:

telegram.PaidMediaPurchased

ALL_TYPES: Final[list[str]] = [<UpdateType.MESSAGE>, <UpdateType.EDITED_MESSAGE>, <UpdateType.CHANNEL_POST>, <UpdateType.EDITED_CHANNEL_POST>, <UpdateType.INLINE_QUERY>, <UpdateType.CHOSEN_INLINE_RESULT>, <UpdateType.CALLBACK_QUERY>, <UpdateType.SHIPPING_QUERY>, <UpdateType.PRE_CHECKOUT_QUERY>, <UpdateType.POLL>, <UpdateType.POLL_ANSWER>, <UpdateType.MY_CHAT_MEMBER>, <UpdateType.CHAT_MEMBER>, <UpdateType.CHAT_JOIN_REQUEST>, <UpdateType.CHAT_BOOST>, <UpdateType.REMOVED_CHAT_BOOST>, <UpdateType.MESSAGE_REACTION>, <UpdateType.MESSAGE_REACTION_COUNT>, <UpdateType.BUSINESS_CONNECTION>, <UpdateType.BUSINESS_MESSAGE>, <UpdateType.EDITED_BUSINESS_MESSAGE>, <UpdateType.DELETED_BUSINESS_MESSAGES>, <UpdateType.PURCHASED_PAID_MEDIA>]

A list of all available update types.

Added in version 13.5.

Type:

list[str]

BUSINESS_CONNECTION: Final[str] = 'business_connection'

telegram.constants.UpdateType.BUSINESS_CONNECTION

Added in version 21.1.

BUSINESS_MESSAGE: Final[str] = 'business_message'

telegram.constants.UpdateType.BUSINESS_MESSAGE

Added in version 21.1.

CALLBACK_QUERY: Final[str] = 'callback_query'

telegram.constants.UpdateType.CALLBACK_QUERY

Added in version 13.5.

CHANNEL_POST: Final[str] = 'channel_post'

telegram.constants.UpdateType.CHANNEL_POST

Added in version 13.5.

CHAT_BOOST: Final[str] = 'chat_boost'

telegram.constants.UpdateType.CHAT_BOOST

Added in version 20.8.

CHAT_JOIN_REQUEST: Final[str] = 'chat_join_request'

telegram.constants.UpdateType.CHAT_JOIN_REQUEST

Added in version 13.8.

CHAT_MEMBER: Final[str] = 'chat_member'

telegram.constants.UpdateType.CHAT_MEMBER

Added in version 13.5.

CHOSEN_INLINE_RESULT: Final[str] = 'chosen_inline_result'

telegram.constants.UpdateType.CHOSEN_INLINE_RESULT

Added in version 13.5.

DELETED_BUSINESS_MESSAGES: Final[str] = 'deleted_business_messages'

telegram.constants.UpdateType.DELETED_BUSINESS_MESSAGES

Added in version 21.1.

EDITED_BUSINESS_MESSAGE: Final[str] = 'edited_business_message'

telegram.constants.UpdateType.EDITED_BUSINESS_MESSAGE

Added in version 21.1.

EDITED_CHANNEL_POST: Final[str] = 'edited_channel_post'

telegram.constants.UpdateType.EDITED_CHANNEL_POST

Added in version 13.5.

EDITED_MESSAGE: Final[str] = 'edited_message'

telegram.constants.UpdateType.EDITED_MESSAGE

Added in version 13.5.

INLINE_QUERY: Final[str] = 'inline_query'

telegram.constants.UpdateType.INLINE_QUERY

Added in version 13.5.

MESSAGE: Final[str] = 'message'

telegram.constants.UpdateType.MESSAGE

Added in version 13.5.

MESSAGE_REACTION: Final[str] = 'message_reaction'

telegram.constants.UpdateType.MESSAGE_REACTION

Added in version 20.8.

MESSAGE_REACTION_COUNT: Final[str] = 'message_reaction_count'

telegram.constants.UpdateType.MESSAGE_REACTION_COUNT

Added in version 20.8.

MY_CHAT_MEMBER: Final[str] = 'my_chat_member'

telegram.constants.UpdateType.MY_CHAT_MEMBER

Added in version 13.5.

POLL: Final[str] = 'poll'

telegram.constants.UpdateType.POLL

Added in version 13.5.

POLL_ANSWER: Final[str] = 'poll_answer'

telegram.constants.UpdateType.POLL_ANSWER

Added in version 13.5.

PRE_CHECKOUT_QUERY: Final[str] = 'pre_checkout_query'

telegram.constants.UpdateType.PRE_CHECKOUT_QUERY

Added in version 13.5.

PURCHASED_PAID_MEDIA: Final[str] = 'purchased_paid_media'

telegram.constants.UpdateType.PURCHASED_PAID_MEDIA

Added in version 21.6.

REMOVED_CHAT_BOOST: Final[str] = 'removed_chat_boost'

telegram.constants.UpdateType.REMOVED_CHAT_BOOST

Added in version 20.8.

SHIPPING_QUERY: Final[str] = 'shipping_query'

telegram.constants.UpdateType.SHIPPING_QUERY

Added in version 13.5.

business_connection: BusinessConnection | None
business_message: Message | None
callback_query: CallbackQuery | None
channel_post: Message | None
chat_boost: ChatBoostUpdated | None
chat_join_request: ChatJoinRequest | None
chat_member: ChatMemberUpdated | None
chosen_inline_result: ChosenInlineResult | None
classmethod de_json(data, bot=None)[source]

See telegram.TelegramObject.de_json().

Return type:

Update

deleted_business_messages: BusinessMessagesDeleted | None
edited_business_message: Message | None
edited_channel_post: Message | None
edited_message: Message | None
property effective_chat: Chat | None

The chat that this update was sent in, no matter what kind of update this is. If no chat is associated with this update, this gives None. This is the case, if inline_query, chosen_inline_result, callback_query from inline messages, shipping_query, pre_checkout_query, poll, poll_answer, business_connection, or purchased_paid_media is present.

Changed in version 21.1: This property now also considers business_message, edited_business_message, and deleted_business_messages.

Example

If message is present, this will give telegram.Message.chat.

Type:

telegram.Chat

property effective_message: Message | None
The message included in this update, no matter what kind of

update this is. More precisely, this will be the message contained in message, edited_message, channel_post, edited_channel_post or callback_query (i.e. telegram.CallbackQuery.message) or None, if none of those are present.

Changed in version 21.1: This property now also considers business_message, and edited_business_message.

Tip

This property will only ever return objects of type telegram.Message or None, never telegram.MaybeInaccessibleMessage or telegram.InaccessibleMessage. Currently, this is only relevant for callback_query, as telegram.CallbackQuery.message is the only attribute considered by this property that can be an object of these types.

Type:

telegram.Message

property effective_sender: User | Chat | None

The user or chat that sent this update, no matter what kind of update this is.

Note

If no user whatsoever is associated with this update, this gives None. This is the case if any of

is present.

Example

Added in version 21.1.

Type:

telegram.User or telegram.Chat

property effective_user: User | None

The user that sent this update, no matter what kind of update this is. If no user is associated with this update, this gives None. This is the case if any of

is present.

Changed in version 21.1: This property now also considers business_connection, business_message and edited_business_message.

Changed in version 21.6: This property now also considers purchased_paid_media.

Example

Type:

telegram.User

inline_query: InlineQuery | None
message: Message | None
message_reaction: MessageReactionUpdated | None
message_reaction_count: MessageReactionCountUpdated | None
my_chat_member: ChatMemberUpdated | None
poll: Poll | None
poll_answer: PollAnswer | None
pre_checkout_query: PreCheckoutQuery | None
purchased_paid_media: PaidMediaPurchased | None
removed_chat_boost: ChatBoostRemoved | None
shipping_query: ShippingQuery | None
update_id: int
class spotted.debug.log_manager.datetime(year, month, day[, hour[, minute[, second[, microsecond[, tzinfo]]]]])

Bases: date

The year, month and day arguments are required. tzinfo may be None, or an instance of a tzinfo subclass. The remaining arguments may be ints.

astimezone()

tz -> convert to local time in new timezone tz

classmethod combine()

date, time -> datetime with same date and time fields

ctime()

Return ctime() style string.

date()

Return date object with same year, month and day.

dst()

Return self.tzinfo.dst(self).

fold
classmethod fromisoformat(object, /)

string -> datetime from a string in most ISO 8601 formats

classmethod fromtimestamp()

timestamp[, tz] -> tz’s local time from POSIX timestamp.

hour
isoformat()

[sep] -> string in ISO 8601 format, YYYY-MM-DDT[HH[:MM[:SS[.mmm[uuu]]]]][+HH:MM]. sep is used to separate the year from the time, and defaults to ‘T’. The optional argument timespec specifies the number of additional terms of the time to include. Valid options are ‘auto’, ‘hours’, ‘minutes’, ‘seconds’, ‘milliseconds’ and ‘microseconds’.

max = datetime.datetime(9999, 12, 31, 23, 59, 59, 999999)
microsecond
min = datetime.datetime(1, 1, 1, 0, 0)
minute
classmethod now(tz=None)

Returns new datetime object representing current time local to tz.

tz

Timezone object.

If no tz is specified, uses local timezone.

replace()

Return datetime with new specified fields.

resolution = datetime.timedelta(microseconds=1)
second
classmethod strptime()

string, format -> new datetime parsed from a string (like time.strptime()).

time()

Return time object with same time but with tzinfo=None.

timestamp()

Return POSIX timestamp as float.

timetuple()

Return time tuple, compatible with time.localtime().

timetz()

Return time object with same time and tzinfo.

tzinfo
tzname()

Return self.tzinfo.tzname(self).

classmethod utcfromtimestamp()

Construct a naive UTC datetime from a POSIX timestamp.

classmethod utcnow()

Return a new datetime representing UTC day and time.

utcoffset()

Return self.tzinfo.utcoffset(self).

utctimetuple()

Return UTC time tuple, compatible with time.localtime().

async spotted.debug.log_manager.error_handler(update, context)[source]

Logs the error and notifies the admins.

Parameters:
async spotted.debug.log_manager.log_message(update, _)[source]

Log the message that caused the update

Parameters:
  • update (Update) – update event

  • context – context passed by the handler

async spotted.debug.log_manager.notify_error_admin(context, traceback_str)[source]

Sends a telegram message to notify the admins.

Parameters:
  • context (CallbackContext) – context passed by the handler

  • traceback_str (str) – the traceback text