Types⚓︎
You can import all types at once:
trueconf.types.AddedChatParticipant dataclass
⚓︎
Bases: BoundToBot
, DataClassDictMixin
Event type: a new participant was added to a chat.
This object is received in the handler when a user is added to a personal chat, group chat, channel, or conference chat.
Notes
This class is used as the event type in handler functions decorated with @<router>.added_chat_participant()
.
Attributes:
Name | Type | Description |
---|---|---|
timestamp | int | Unix timestamp (milliseconds) of when the event occurred. |
chat_id | str | Unique identifier of the chat where the participant was added. |
user_id | str | TrueConf ID of the participant who was added. |
added_by | EnvelopeAuthor | Information about the user who added the participant. |
Examples:
from trueconf.types import AddedChatParticipant
@<router>.added_chat_participant()
async def on_added(event: AddedChatParticipant):
print(event.user_id)
trueconf.types.CreatedChannel dataclass
⚓︎
Bases: BoundToBot
, DataClassDictMixin
Event type: a new channel chat was created.
This object is received in the handler when a channel is created in TrueConf.
Notes
This class is used as the event type in handler functions decorated with @<router>.created_channel()
.
Attributes:
Name | Type | Description |
---|---|---|
chat_id | str | Unique identifier of the created channel. |
title | str | Title of the channel. |
chat_type | ChatType | Type of the chat (should be |
last_message | LastMessage | None | The last message in the channel, if available. |
unread_messages | int | Number of unread messages in the channel. |
Examples:
from trueconf.types import CreatedChannel
@<router>.created_channel()
async def on_created(event: CreatedChannel):
print(f"Channel {event.title} created with id {event.chat_id}")
trueconf.types.CreatedGroupChat dataclass
⚓︎
Bases: BoundToBot
, DataClassDictMixin
Event type: a new group chat was created.
This object is received in the handler when a group chat is created in TrueConf.
Notes
This class is used as the event type in handler functions decorated with @<router>.created_group_chat()
.
Attributes:
Name | Type | Description |
---|---|---|
chat_id | str | Unique identifier of the group chat. |
title | str | Title of the group chat. |
chat_type | ChatType | Type of the chat (should be |
last_message | LastMessage | None | The last message in the chat, if available. |
unread_messages | int | Number of unread messages in the group chat. |
Examples:
from trueconf.types import CreatedGroupChat
@<router>.created_group_chat()
async def on_created(event: CreatedGroupChat):
print(f"Group chat {event.title} created with id {event.chat_id}")
trueconf.types.CreatedPersonalChat dataclass
⚓︎
Bases: BoundToBot
, DataClassDictMixin
Event type: a new personal chat was created.
This object is received in the handler when a personal chat is created in TrueConf.
Notes
This class is used as the event type in handler functions decorated with @<router>.created_personal_chat()
.
Attributes:
Name | Type | Description |
---|---|---|
chat_id | str | Unique identifier of the personal chat. |
title | str | Title of the chat (usually the participant’s name). |
chat_type | ChatType | Type of the chat (should be |
last_message | LastMessage | None | The last message in the chat, if available. |
unread_messages | int | Number of unread messages in the personal chat. |
Examples:
from trueconf.types import CreatedPersonalChat
@<router>.created_personal_chat()
async def on_created(event: CreatedPersonalChat):
print(f"Personal chat created with id {event.chat_id}")
trueconf.types.EditedMessage dataclass
⚓︎
Bases: BoundToBot
, DataClassDictMixin
Event type: a message was edited.
This object is received in the handler when a previously sent message is edited in a chat.
Notes
This class is used as the event type in handler functions decorated with @<router>.edited_message()
.
Attributes:
Name | Type | Description |
---|---|---|
timestamp | int | Unix timestamp (milliseconds) of when the edit occurred. |
content | TextContent | The updated content of the edited message. |
chat_id | str | Unique identifier of the chat where the message was edited. |
Examples:
trueconf.types.Message dataclass
⚓︎
Message(timestamp, type, author, box, content, message_id, chat_id, is_edited, reply_message_id=None)
Bases: BoundToBot
, DataClassDictMixin
Represents a single chat message within TrueConf Chatbot Connector.
The Message
object is automatically created for each incoming update and contains metadata (author, chat, timestamp, type) along with the actual message content. It also provides helper properties and shortcut methods to interact with the message (e.g., replying, forwarding, deleting, sending media files).
Attributes:
Name | Type | Description |
---|---|---|
timestamp | int | Unix timestamp of the message. |
type | MessageType | Type of the message (e.g., TEXT, ATTACHMENT). |
author | EnvelopeAuthor | Information about the user who sent the message. |
box | EnvelopeBox | Information about the chat (box) where the message was sent. |
message_id | str | Unique identifier of the message. |
chat_id | str | Unique identifier of the chat where the message was sent. |
is_edited | bool | Indicates whether the message was edited. |
reply_message_id | Optional[str] | Identifier of the message this one replies to. |
from_user | EnvelopeAuthor | Shortcut for accessing the message author. |
content_type | MessageType | Returns the type of the message. |
text | Optional[str] | Returns the message text if it contains text, else None. |
document | Optional[Document] | Returns a document attachment if the message contains a non-media file (not photo, video, sticker). |
photo | Optional[Photo] | Returns a photo attachment if available. |
video | Optional[Video] | Returns a video attachment if available. |
sticker | Optional[Sticker] | Returns a sticker attachment if available. |
Methods:
Name | Description |
---|---|
answer | Sends a text message in the same chat. |
reply | Sends a reply message referencing the current one. |
forward | Forwards the current message to another chat. |
copy_to | Sends a copy of the current message (text-only). |
answer_photo | Sends a photo to the current chat. |
answer_document | Sends a document to the current chat. |
answer_sticker | Sends a sticker to the current chat. |
delete | Deletes the current message from the chat. |
content_type property
⚓︎
Returns the type of the current message content.
Returns:
Name | Type | Description |
---|---|---|
MessageType | MessageType | Message content type (e.g., TEXT, ATTACHMENT). |
document property
⚓︎
Returns the attached document if the message contains a non-media file.
Use this property only for documents that are not photos, videos, or stickers. For media attachments, use the corresponding properties: photo
, video
, or sticker
. If you need to handle any attached file (including media), use message.content
directly.
Returns:
Type | Description |
---|---|
Optional['Document'] | Optional[Document]: Document attachment bound to the bot, or None if not applicable. |
from_user property
⚓︎
Returns the author of the current message.
Returns:
Name | Type | Description |
---|---|---|
EnvelopeAuthor | EnvelopeAuthor | Shortcut for accessing the message author. |
message_id class-attribute
instance-attribute
⚓︎
photo property
⚓︎
Returns the attached photo object if the current message contains an image.
This is a shortcut for accessing photo metadata from image attachments.
Returns:
Type | Description |
---|---|
Optional['Photo'] | Optional[Photo]: A |
reply_message_id class-attribute
instance-attribute
⚓︎
sticker property
⚓︎
Returns the attached sticker object if the current message contains a sticker.
Returns:
Type | Description |
---|---|
Optional['Sticker'] | Optional[Sticker]: A |
text property
⚓︎
Returns the text of the current message if present.
Returns:
Type | Description |
---|---|
str | None | Optional[str]: Message text, or None if the message has no text content. |
video property
⚓︎
Returns the attached video object if the current message contains a video.
This is a shortcut for accessing video metadata from video attachments.
Returns:
Type | Description |
---|---|
Optional['Video'] | Optional[Video]: A |
answer async
⚓︎
answer(text, parse_mode=HTML)
Shortcut for the send_message
method of the bot instance. Use this method to send a text message to the current chat.
Automatically fills the following attributes
chat_id
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text | str | Text of the message to be sent. | required |
parse_mode | ParseMode | str | Text formatting mode. Defaults to HTML. | HTML |
Returns:
Name | Type | Description |
---|---|---|
SendMessageResponse | object | Object containing the result of the message delivery. |
Examples:
answer_document async
⚓︎
Shortcut for the send_document
method of the bot instance. Use this method to send a document in response to the current message.
Automatically fills the following attributes
chat_id
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_path | str | Path to the document file. | required |
Returns:
Name | Type | Description |
---|---|---|
SendFileResponse | object | Object containing the result of the document upload. |
Examples:
answer_photo async
⚓︎
Shortcut for the send_photo
method of the bot instance. Use this method to send a photo in response to the current message.
Automatically fills the following attributes
chat_id
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_path | str | Path to the image file (supported formats: | required |
preview_path | str | None | Path to the preview image. | required |
Returns:
Name | Type | Description |
---|---|---|
SendFileResponse | object | Object containing the result of the photo upload. |
Examples:
answer_sticker async
⚓︎
Shortcut for the send_sticker
method of the bot instance. Use this method to send a sticker in response to the current message.
Automatically fills the following attributes
chat_id
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_path | str | Path to the sticker file (must be in WebP format). | required |
Returns:
Name | Type | Description |
---|---|---|
SendFileResponse | object | Object containing the result of the sticker delivery. |
Examples:
copy_to async
⚓︎
Shortcut for the send_message
method of the bot instance. Use this method to send a copy of the current message (without metadata or reply context) to another chat.
Automatically fills the following attributes
text
parse_mode
Parameters:
Name | Type | Description | Default |
---|---|---|---|
chat_id | str | Identifier of the target chat to send the copied message to. | required |
Returns:
Name | Type | Description |
---|---|---|
SendMessageResponse | object | Object containing the result of the message delivery. |
delete async
⚓︎
Shortcut for the remove_message
method of the bot instance. Use this method to delete the current message from the chat.
Automatically fills the following attributes
message_id
Parameters:
Name | Type | Description | Default |
---|---|---|---|
for_all | bool | If True, delete the message for all participants. Defaults to False (deletes only for the bot). | False |
Returns:
Name | Type | Description |
---|---|---|
RemoveMessageResponse | object | Object containing the result of the message deletion. |
forward async
⚓︎
Shortcut for the forward_message
method of the bot instance. Use this method to forward the current message to another chat.
Automatically fills the following attributes
message_id
Parameters:
Name | Type | Description | Default |
---|---|---|---|
chat_id | str | Identifier of the target chat to forward the message to. | required |
Returns:
Name | Type | Description |
---|---|---|
ForwardMessageResponse | object | Object containing the result of the message forwarding. |
reply async
⚓︎
reply(text, parse_mode=HTML)
Shortcut for the reply_message
method of the bot instance. Use this method to send a reply message to the current chat.
Automatically fills the following attributes
chat_id
reply_message_id
Source: trueconf.com/docs/chatbot-connector/en/messages/#replyMessage
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text | str | Text of the reply message. | required |
parse_mode | ParseMode | str | Text formatting mode. Defaults to HTML. | HTML |
Returns:
Name | Type | Description |
---|---|---|
SendMessageResponse | object | Object containing the result of the message delivery. |
trueconf.types.RemovedChat dataclass
⚓︎
Bases: BoundToBot
, DataClassDictMixin
Event type: a chat was removed.
This object is received in the handler when a private, group, channel, or conference chat is deleted.
Notes
This class is used as the event type in handler functions decorated with @<router>.removed_chat()
.
Attributes:
Name | Type | Description |
---|---|---|
chat_id | str | Unique identifier of the chat that was removed. |
Examples:
from trueconf.types import RemovedChat
@<router>.removed_chat()
async def on_removed(event: RemovedChat):
print(f"Chat removed: {event.chat_id}")
trueconf.types.RemovedChatParticipant dataclass
⚓︎
Bases: BoundToBot
, DataClassDictMixin
Event type: a participant was removed from a chat.
This object is received in the handler when a user is removed from a group, channel, or conference chat.
Notes
This class is used as the event type in handler functions decorated with @<router>.removed_chat_participant()
.
Attributes:
Name | Type | Description |
---|---|---|
timestamp | int | Unix timestamp (milliseconds) of when the event occurred. |
chat_id | str | Unique identifier of the chat where the participant was removed. |
user_id | str | TrueConf ID of the participant who was removed. |
removed_by | EnvelopeAuthor | Information about the user who removed the participant. |
Examples:
from trueconf.types import RemovedChatParticipant
@<router>.removed_chat_participant()
async def on_removed(event: RemovedChatParticipant):
print(event.user_id)
removed_by class-attribute
instance-attribute
⚓︎
trueconf.types.RemovedMessage dataclass
⚓︎
Bases: BoundToBot
, DataClassDictMixin
Event type: a message was removed.
This object is received in the handler when a message is deleted from a chat.
Notes
This class is used as the event type in handler functions decorated with @<router>.removed_message()
.
Attributes:
Name | Type | Description |
---|---|---|
chat_id | str | Unique identifier of the chat from which the message was removed. |
message_id | str | Unique identifier of the removed message. |
removed_by | EnvelopeAuthor | Information about the user who removed the message. |
Examples:
trueconf.types.Update dataclass
⚓︎
trueconf.types.UploadingProgress dataclass
⚓︎
Bases: BoundToBot
, DataClassDictMixin
Event type: file upload progress.
This object is received in the handler when a file is being uploaded and the upload progress is updated.
Notes
This class is used as the event type in handler functions decorated with @<router>.uploading_progress()
.
Attributes:
Name | Type | Description |
---|---|---|
file_id | str | Unique identifier of the file being uploaded. |
progress | int | Number of bytes uploaded to the server. |
Examples: