Skip to content

Telegram command menu for LHC bot commands in operator topics - #99

Open
mysubcult wants to merge 3 commits into
LiveHelperChat:masterfrom
mysubcult:feat/topic-command-menu
Open

mysubcult wants to merge 3 commits into
LiveHelperChat:masterfrom
mysubcult:feat/topic-command-menu

Conversation

@mysubcult

@mysubcult mysubcult commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Operators who answer from Telegram topics can use LHC bot commands (!name), but have to remember and type them. Telegram has a native command menu (the / button), so this PR connects the two.

How it works

  • In an operator topic /name (or /name@bot, with arguments) works exactly like !name for any LHC bot command. GenericCommand receives unknown commands; when the name matches an LHC bot command it rewrites the update text to !name … and hands it to GenericmessageCommand, so the existing ! flow (bot trigger, internal message, topic echo) is reused unchanged. Works for every LHC command, listed in the menu or not.
  • New bot option Commands in the "/" menu of the group (Telegram => Bots => Edit): a comma separated list of LHC bot command names. They are shown in that order as /name — description (description = info_msg of the LHC command, else its name), followed by /ban and /endchat. Registered with setMyCommands for the operators group only (scope: chat). Nothing in LHC core settings is used for this.
  • No manual sync needed: on a message in the operators group the menu is compared with the one sent last time (cache/telegram_topic_commands_<bot>.md5) and re-sent only when it changed. An empty option leaves the group menu untouched (or removes the menu the extension sent before). php cron.php -s site_admin -e lhctelegram -c cron/sync_commands forces it.
  • Unknown commands in a group are ignored instead of answering Command /x not found.. :( (e.g. when someone types a command in General).
  • New column lhc_telegram_bot.topic_commands in structure.json / install.sql.

🤖 Generated with Claude Code

@mysubcult
mysubcult force-pushed the feat/topic-command-menu branch 2 times, most recently from 8a605b1 to 4fb2b5b Compare October 24, 2026 06:40
In an operator topic "/name" now works as the LHC bot command "!name":
GenericCommand rewrites the update and hands it to GenericmessageCommand, so
the existing command flow is reused. Which commands the "/" menu of the
operators group shows is a new bot option (lhc_telegram_bot.topic_commands,
comma separated), descriptions come from the LHC commands, followed by /ban
and /endchat. The menu is re-sent (setMyCommands, chat scope) only when it
changed; cron/sync_commands forces it. Unknown commands in a group are ignored
instead of «Command not found».

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mysubcult
mysubcult force-pushed the feat/topic-command-menu branch from f13ed98 to 9237358 Compare October 24, 2026 07:15
Both PRs add a column to lhc_telegram_bot; this resolves the overlap so LiveHelperChat#99 merges cleanly after LiveHelperChat#97.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant