QivunaDevelopers

Commands and scopes

Commands are what people type after a slash. Register them so the app can show them in the “/” menu — and so that a bare /command in a group reaches your bot.

Registering commands#

POST https://bots.qivuna.com/v1/setMyCommands
{"commands": [{"command": "poll", "description": "Start a poll"},
              {"command": "results", "description": "Show the results"}],
 "scope": {"type": "all_group_chats"},
 "language_code": "en"}

Apps learn about changes by themselves: each change bumps a revision that the bot's profile carries, and rooms the bot is in are told to refresh their menu.

Scopes#

scope.typeApplies to
defaultEverywhere, when nothing more specific exists.
all_private_chats1:1 chats with the bot.
all_group_chatsEvery group the bot is in.
all_chat_administratorsAdmins of groups and channels the bot is in.
chatOne chat, named by scope.chat_id: a group or channel the bot is in, or a person who started it.

Telegram's chat_administrators and chat_member scopes do not exist (400). chat_id is accepted only with type: "chat".

The “/” menu takes the person's app language (Hebrew if the app prefers Hebrew, otherwise English) and, for each scope in this order, looks for a list in that language, then a list without a language. The first list found wins:

In a room, the menu lists the commands of every bot active there.

Which bot a command in a group reaches#

With privacy mode on, a command reaches your bot when:

So: register every command your bot answers, and expect people to use /command@your_bot in rooms with several bots. A command advertised only for admins (all_chat_administrators) still counts for a member's bare command: the rule decides which bot a command means, not who may use it — your bot decides that.

The message carries command: {name, args, addressed_to_me}: name in lower case, args the rest of the text, and addressed_to_me: true when one of the two rules above matched. A message that reached your bot only because it mentions it or replies to it has addressed_to_me: false.

A command is /, 1–32 letters, digits or _, optionally @handle, at the very start of the message and followed by a space or the end.

Commands in encrypted groups#

In an end-to-end encrypted group, the server cannot read commands. The sender's app decides which attached bot a message is for — /cmd@handle, a bare command advertised by exactly one attached bot, an @mention, or a reply to a bot's answer — shows the person a “🔒 → 🤖 @bot” chip before sending, and sends that one message, encrypted, to that bot only. See Encrypted groups.