Objects
How profiles, chats and messages look in the Bot API.
Every ID in Comon is an opaque string: do not parse it or turn it into a number. Times are Unix seconds.
User
A person's or a bot's profile.
| Field | Type | |
|---|---|---|
id | string | The profile ID. |
is_bot | boolean | Whether it is a bot. |
first_name | string | First name. |
last_name | string | Last name, if any. |
username | string | The @username without @, if any. |
{ "id": "…", "is_bot": false, "first_name": "Anna", "last_name": "Kim", "username": "anna" }Chat
| Field | Type | |
|---|---|---|
id | string | The chat ID. |
type | string | private (direct), group, channel, community, room (a community room). |
user | User | For private: the bot's peer. |
title | string | For the others: the title. |
username | string | The public chat's @username, if any. |
community_id | string | For room: the community the room belongs to. |
{ "id": "…", "type": "room", "title": "releases", "community_id": "…" }Message
| Field | Type | |
|---|---|---|
message_id | string | The message's ID in the chat. |
chat | Chat | The chat. |
from | User | The author, if there is one. |
date | integer | When it was sent. |
edited | true | Present when the message was edited. |
order | integer | Its position in the chat; needed for readPersonalMessages. |
text | string | All the message's text: paragraphs, headings, code, captions and table cells, one line per block. |
entities | array | Formatting and mentions in text. |
reply_to_message_id | string | The message this one replies to. |
document | object | The message's full document with every block and attachment. |
command | object | Only in the message update: {"name", "options"} of an ordinary command run from the app (commands). |
text is enough for simple bots. document matters when structure does: media, lists, tables,
quotes. Its shape is in protocol/comon/federation/document.proto; in JSON the fields are
camelCase.
Entity
A range of text with formatting. offset and length count UTF-16 units, as in JavaScript and
Telegram: an emoji outside the basic plane takes two units.
type | Extra | Meaning |
|---|---|---|
bold, italic, underline, strikethrough, code, spoiler | Formatting. | |
text_link | url | A link under the text. |
mention | user_id | A mention of a person. Incoming messages only. |
mention_all | A mention of every member. Incoming messages only. |
{ "type": "text_link", "offset": 0, "length": 7, "url": "https://comon.chat" }BotCommand
| Field | Type | |
|---|---|---|
command | string | The name without /: lowercase Latin letters, digits and _. |
description | string | Up to 256 characters. |
ephemeral | boolean | An ephemeral command. |
options | array | Options (commands). |