mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-09-22 22:25:48 +00:00
* 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
38 lines
1.1 KiB
Python
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
|