cmdmenu

package
v1.24.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 25, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package cmdmenu owns BotFather's own command menu — the /newbot, /help, ... entries written to robot.bot_commands and rendered by clients as the chat command picker (#335).

The menu is server-owned copy (unlike user bots' commands, which are creator content set via POST /v1/bot/setCommands and are never localized), so its descriptions render through the shared msgtmpl catalog. The stored blob can only carry ONE language, therefore localization happens in two layers:

  • startup (botfather.registerBotFatherCommands) writes the blob in the deployment default language — the floor served by paths that genuinely have no request context (admin robot detail, future context-less reads);
  • every request-bearing read of the blob overrides it per request via JSON(i18n.OutboundLanguage(ctx)), for the BotFather UID only: channel info extra.bot_commands, /v1/robot/commands, /v1/users/:uid, and the batch user-detail fill (user.Service.GetUserDetails) behind friend sync / friend search / search / conversation enrichment.

This package is deliberately a LEAF (msgtmpl + pkg/i18n only): botfather imports user, so the read-side modules (user, channel, robot) can only share this catalog through a package that imports neither.

Index

Constants

View Source
const BotFatherUID = "botfather"

BotFatherUID is the BotFather system bot's UID. The canonical constant lives here (not in the botfather package, which aliases it) so the read-side override call sites can match it without an import cycle.

Variables

This section is empty.

Functions

func JSON

func JSON(lang string) string

JSON returns the menu serialized in the robot.bot_commands storage/wire shape, rendered in lang.

Types

type Command

type Command struct {
	Command     string `json:"command"`
	Description string `json:"description"`
}

Command is one menu entry in the robot.bot_commands storage/wire shape.

func Commands

func Commands(lang string) []Command

Commands returns the menu with descriptions rendered in lang.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址