Files
simplex-chat/apps/simplex-support-bot-light/src/support_bot_light/commands.py
T
sh 68916aa90a feat: add simplex-support-bot-light (#7378)
* feat: add simplex-support-bot-light

* feat: package simplex-support-bot-light for docker

* docs: document simplex-support-bot-light

* fix: make a missing config actionable and bounded

* docs: note the attached compose Ctrl+C behaviour

* refactor: use the library for startup and custom data

* refactor: drop the display-name workaround

* style: shorten the startup comment

* build: build the core and the library into the image

* docs: correct where the image type rule comes from

* fix: log what the core said a command got wrong

* build: run the container as the operator's uid

* docs: keep the container uid in .env

* docs: tighten the README
2026-08-17 09:12:47 +01:00

38 lines
1.1 KiB
Python

"""The bot's command menu: declarations plus conversion to group-preference wire dicts."""
from __future__ import annotations
from collections.abc import Sequence
from simplex_chat import BotCommand
from simplex_chat.types import T
DM = "dm"
LIST = "list"
LEAVE = "leave"
HELP = "help"
COMMANDS: tuple[BotCommand, ...] = (
BotCommand(keyword=DM, label="Add me to incoming chats"),
BotCommand(keyword=LIST, label="Who gets invited"),
BotCommand(keyword=LEAVE, label="Stop adding me"),
BotCommand(keyword=HELP, label="How this works"),
)
def to_wire(commands: Sequence[BotCommand]) -> list[T.ChatBotCommand]:
"""Convert declarations to `groupPreferences.commands` entries."""
wire: list[T.ChatBotCommand] = []
for c in commands:
entry: T.ChatBotCommand_command = {
"type": "command",
"keyword": c.keyword,
"label": c.label,
}
# Omitted rather than empty: the client sends on tap for Nothing, but
# pastes for Just "".
if c.params is not None:
entry["params"] = c.params
wire.append(entry)
return wire