Module contents
Modules used during debug
- async spotted.debug.error_handler(update, context)[source]
Logs the error and notifies the admins.
- Parameters:
update (
Update) – update eventcontext (
CallbackContext) – context passed by the handler
- async spotted.debug.log_message(update, _)[source]
Log the message that caused the update
- Parameters:
update (
Update) – update eventcontext – 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.BaseHandleror by thetelegram.ext.Applicationin an error handler added bytelegram.ext.Application.add_error_handleror to the callback of atelegram.ext.Job.Note
telegram.ext.Applicationwill 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 sameCallbackContextobject (of course with proper attributes likematchesdiffering). 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 onCallbackContextmight 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.blockset toFalseortelegram.ext.Application.concurrent_updatesset toTrue. 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
Genericclass and accepts four type variables:The type of
bot. Must betelegram.Botor a subclass of that class.
Examples
Context Types BotCustom 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 withblock=False.- Type:
- matches
Optional. If the associated update originated from a
filters.Regex, this will contain a list of match objects for every pattern wherere.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.PrefixHandlerortelegram.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:
- job
Optional. The job which originated this callback. Only present when passed to the callback of
telegram.ext.Jobor in error handlers if the error is caused by a job.Changed in version 20.0:
jobis now also present in error handlers if the error is caused by a job.- Type:
- property application: Application[BT, ST, UD, CD, BD, Any]
The application associated with this context.
- Type:
- property bot: BT
The bot associated with this context.
- Type:
- 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 todict.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 todict.Warning
When a group chat migrates to a supergroup, its chat id will change and the
chat_dataneeds to be transferred. For details see ourwiki 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
- 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
KeyErrorin 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 | RuntimeError –
KeyError, if the callback query can not be found in the cache andRuntimeError, if the bot doesn’t allow for arbitrary callback data.- Return type:
- classmethod from_error(update, error, application, job=None, coroutine=None)[source]
Constructs an instance of
telegram.ext.CallbackContextto be passed to the error handlers.Changed in version 20.0: Removed arguments
async_argsandasync_kwargs.- Parameters:
update (
object) – The update associated with the error. May beNone, 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 withblock=False.Added in version 20.0.
Changed in version 20.2: Accepts
asyncio.Futureand 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.CallbackContextto be passed to a job callback.See also
telegram.ext.JobQueue()- Parameters:
- Returns:
TypeVar(CCT, bound= CallbackContext[Any, Any, Any, Any]) –telegram.ext.CallbackContext
- classmethod from_update(update, application)[source]
Constructs an instance of
telegram.ext.CallbackContextto be passed to the handlers.- Parameters:
- Returns:
TypeVar(CCT, bound= CallbackContext[Any, Any, Any, Any]) –telegram.ext.CallbackContext
- property job_queue: JobQueue[ST] | None
The
JobQueueused by thetelegram.ext.Application.See also
Job Queue <Extensions---JobQueue>- Type:
- property match: Match[str] | None
The first match from
matches. Useful if you are only filtering using a single regex filter. ReturnsNoneifmatchesis empty.- Type:
- async refresh_data()[source]
If
applicationuses persistence, callstelegram.ext.BasePersistence.refresh_bot_data()onbot_data,telegram.ext.BasePersistence.refresh_chat_data()onchat_dataandtelegram.ext.BasePersistence.refresh_user_data()onuser_data, if appropriate.Will be called by
telegram.ext.Application.process_update()andtelegram.ext.Job.run().Added in version 13.6.
- Return type:
- property update_queue: Queue[object]
The
asyncio.Queueinstance used by thetelegram.ext.Applicationand (usually) thetelegram.ext.Updaterassociated with this context.- Type:
- 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 todict.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:
objectConfigurations
- 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.
- 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:
- 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 getdefault (
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
- class spotted.debug.log_manager.ParseMode(*values)[source]
Bases:
StringEnumThis enum contains the available parse modes. The enum members of this enumeration are instances of
strand can be treated as such.Added in version 20.0.
- MARKDOWN = 'Markdown'
Markdown parse mode.
Note
MARKDOWNis a legacy mode, retained by Telegram for backward compatibility. You should useMARKDOWN_V2instead.- Type:
- class spotted.debug.log_manager.Path(*args, **kwargs)[source]
Bases:
PurePathPurePath 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.
- 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.
- 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)
- 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.
- hardlink_to(target)[source]
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.
- property info
A PathInfo object that exposes the file type and other file attributes of this path.
- is_file(*, follow_symlinks=True)[source]
Whether this path is a regular file (also True for symlinks pointing to regular files).
- 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.
- 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.
- read_text(encoding=None, errors=None, newline=None)[source]
Open the file in text mode, read it, and close the file.
- 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.
- 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.
- symlink_to(target, target_is_directory=False)[source]
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.
- unlink(missing_ok=False)[source]
Remove this file or link. If the path is a directory, use rmdir() instead.
- 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:
TelegramObjectThis 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_idis 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_MEMBERin the list oftelegram.ext.Application.run_polling.allowed_updatesto receive these updates (seetelegram.Bot.get_updates(),telegram.Bot.set_webhook(),telegram.ext.Application.run_polling()andtelegram.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_usersadministrator 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_REACTIONin the list oftelegram.ext.Application.run_polling.allowed_updatesto receive these updates (seetelegram.Bot.get_updates(),telegram.Bot.set_webhook(),telegram.ext.Application.run_polling()andtelegram.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_COUNTin the list oftelegram.ext.Application.run_polling.allowed_updatesto receive these updates (seetelegram.Bot.get_updates(),telegram.Bot.set_webhook(),telegram.ext.Application.run_polling()andtelegram.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:
- message
Optional. New incoming message of any kind - text, photo, sticker, etc.
- Type:
- 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:
- channel_post
Optional. New incoming channel post of any kind - text, photo, sticker, etc.
- Type:
- 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:
- inline_query
Optional. New incoming inline query.
- Type:
- chosen_inline_result
Optional. The result of an inline query that was chosen by a user and sent to their chat partner.
- callback_query
Optional. New incoming callback query.
Examples
Arbitrary Callback Data Bot- Type:
- shipping_query
Optional. New incoming shipping query. Only for invoices with flexible price.
- Type:
- pre_checkout_query
Optional. New incoming pre-checkout query. Contains full information about checkout.
- poll
Optional. New poll state. Bots receive only updates about manually stopped polls and polls, which are sent by the bot.
- Type:
- 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:
- 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.
- 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_MEMBERin the list oftelegram.ext.Application.run_polling.allowed_updatesto receive these updates (seetelegram.Bot.get_updates(),telegram.Bot.set_webhook(),telegram.ext.Application.run_polling()andtelegram.ext.Application.run_webhook()).Added in version 13.4.
- chat_join_request
Optional. A request to join the chat has been sent. The bot must have the
telegram.ChatPermissions.can_invite_usersadministrator right in the chat to receive these updates.Added in version 13.8.
- Type:
- 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.
- 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.
- 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_REACTIONin the list oftelegram.ext.Application.run_polling.allowed_updatesto receive these updates (seetelegram.Bot.get_updates(),telegram.Bot.set_webhook(),telegram.ext.Application.run_polling()andtelegram.ext.Application.run_webhook()). The update isn’t received for reactions set by bots.Added in version 20.8.
- 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_COUNTin the list oftelegram.ext.Application.run_polling.allowed_updatesto receive these updates (seetelegram.Bot.get_updates(),telegram.Bot.set_webhook(),telegram.ext.Application.run_polling()andtelegram.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
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.
- business_message
Optional. New message from a connected business account.
Added in version 21.1.
- Type:
- edited_business_message
Optional. New version of a message from a connected business account.
Added in version 21.1.
- Type:
- deleted_business_messages
Optional. Messages were deleted from a connected business account.
Added in version 21.1.
- 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.
- 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_CONNECTIONAdded in version 21.1.
- BUSINESS_MESSAGE: Final[str] = 'business_message'
telegram.constants.UpdateType.BUSINESS_MESSAGEAdded in version 21.1.
- CALLBACK_QUERY: Final[str] = 'callback_query'
telegram.constants.UpdateType.CALLBACK_QUERYAdded in version 13.5.
- CHANNEL_POST: Final[str] = 'channel_post'
telegram.constants.UpdateType.CHANNEL_POSTAdded in version 13.5.
- CHAT_BOOST: Final[str] = 'chat_boost'
telegram.constants.UpdateType.CHAT_BOOSTAdded in version 20.8.
- CHAT_JOIN_REQUEST: Final[str] = 'chat_join_request'
telegram.constants.UpdateType.CHAT_JOIN_REQUESTAdded in version 13.8.
- CHAT_MEMBER: Final[str] = 'chat_member'
telegram.constants.UpdateType.CHAT_MEMBERAdded in version 13.5.
- CHOSEN_INLINE_RESULT: Final[str] = 'chosen_inline_result'
telegram.constants.UpdateType.CHOSEN_INLINE_RESULTAdded in version 13.5.
- DELETED_BUSINESS_MESSAGES: Final[str] = 'deleted_business_messages'
telegram.constants.UpdateType.DELETED_BUSINESS_MESSAGESAdded in version 21.1.
- EDITED_BUSINESS_MESSAGE: Final[str] = 'edited_business_message'
telegram.constants.UpdateType.EDITED_BUSINESS_MESSAGEAdded in version 21.1.
- EDITED_CHANNEL_POST: Final[str] = 'edited_channel_post'
telegram.constants.UpdateType.EDITED_CHANNEL_POSTAdded in version 13.5.
- EDITED_MESSAGE: Final[str] = 'edited_message'
telegram.constants.UpdateType.EDITED_MESSAGEAdded in version 13.5.
- INLINE_QUERY: Final[str] = 'inline_query'
telegram.constants.UpdateType.INLINE_QUERYAdded in version 13.5.
- MESSAGE_REACTION: Final[str] = 'message_reaction'
telegram.constants.UpdateType.MESSAGE_REACTIONAdded in version 20.8.
- MESSAGE_REACTION_COUNT: Final[str] = 'message_reaction_count'
telegram.constants.UpdateType.MESSAGE_REACTION_COUNTAdded in version 20.8.
- MY_CHAT_MEMBER: Final[str] = 'my_chat_member'
telegram.constants.UpdateType.MY_CHAT_MEMBERAdded in version 13.5.
- POLL_ANSWER: Final[str] = 'poll_answer'
telegram.constants.UpdateType.POLL_ANSWERAdded in version 13.5.
- PRE_CHECKOUT_QUERY: Final[str] = 'pre_checkout_query'
telegram.constants.UpdateType.PRE_CHECKOUT_QUERYAdded in version 13.5.
- PURCHASED_PAID_MEDIA: Final[str] = 'purchased_paid_media'
telegram.constants.UpdateType.PURCHASED_PAID_MEDIAAdded in version 21.6.
- REMOVED_CHAT_BOOST: Final[str] = 'removed_chat_boost'
telegram.constants.UpdateType.REMOVED_CHAT_BOOSTAdded in version 20.8.
- SHIPPING_QUERY: Final[str] = 'shipping_query'
telegram.constants.UpdateType.SHIPPING_QUERYAdded in version 13.5.
- callback_query: CallbackQuery | None
- classmethod de_json(data, bot=None)[source]
See
telegram.TelegramObject.de_json().- Return type:
- 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, ifinline_query,chosen_inline_result,callback_queryfrom inline messages,shipping_query,pre_checkout_query,poll,poll_answer,business_connection, orpurchased_paid_mediais present.Changed in version 21.1: This property now also considers
business_message,edited_business_message, anddeleted_business_messages.Example
If
messageis present, this will givetelegram.Message.chat.- Type:
- 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_postorcallback_query(i.e.telegram.CallbackQuery.message) orNone, if none of those are present.
Changed in version 21.1: This property now also considers
business_message, andedited_business_message.Tip
This property will only ever return objects of type
telegram.MessageorNone, nevertelegram.MaybeInaccessibleMessageortelegram.InaccessibleMessage. Currently, this is only relevant forcallback_query, astelegram.CallbackQuery.messageis the only attribute considered by this property that can be an object of these types.- Type:
- property effective_sender: User | Chat | None
The user or chat that sent this update, no matter what kind of update this is.
Note
Depending on the type of update and the user’s ‘Remain anonymous’ setting, this could either be
telegram.User,telegram.ChatorNone.
If no user whatsoever is associated with this update, this gives
None. This is the case if any ofis present.
Example
If
messageis present, this will give eithertelegram.Message.from_userortelegram.Message.sender_chat.If
poll_answeris present, this will give eithertelegram.PollAnswer.userortelegram.PollAnswer.voter_chat.If
channel_postis present, this will givetelegram.Message.sender_chat.
Added in version 21.1.
- Type:
- 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 ofis present.
Changed in version 21.1: This property now also considers
business_connection,business_messageandedited_business_message.Changed in version 21.6: This property now also considers
purchased_paid_media.Example
If
messageis present, this will givetelegram.Message.from_user.If
poll_answeris present, this will givetelegram.PollAnswer.user.
- Type:
- class spotted.debug.log_manager.datetime(year, month, day[, hour[, minute[, second[, microsecond[, tzinfo]]]]])
Bases:
dateThe 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:
update (
Update) – update eventcontext (
CallbackContext) – context passed by the handler
- async spotted.debug.log_manager.log_message(update, _)[source]
Log the message that caused the update
- Parameters:
update (
Update) – update eventcontext – 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 handlertraceback_str (
str) – the traceback text