Skip to content

Commit 60b1971

Browse files
committed
Rework command framework
Replace the per-backend, string-formatted command system with a typed, backend-agnostic command framework built on chatom's FormattedMessage rendering. - New command framework: declarative `Command`/`CommandModel`, a `CommandContext`, a command executor, and a `LegacyCommandAdapter` so existing `BaseCommand` subclasses keep working. - Load commands via entrypoints and enforce per-backend compatibility. - Migrate commands to concrete chatom types and render built-in command output through `FormattedMessage`/`convert_format` instead of hand-crafted per-backend strings. - Add agent commands, a persistence layer for scheduled/deferred commands, and supporting tests. - Require `chatom>=0.1.3`, which provides the format APIs (`convert_format`, `FormattedMessage`, tables) this framework uses. Signed-off-by: Tim Paine <3105306+timkpaine@users.noreply.github.com>
1 parent 62d72c1 commit 60b1971

23 files changed

Lines changed: 3979 additions & 165 deletions

csp_bot/__init__.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,25 @@
2121
from .commands import (
2222
BaseCommand,
2323
BaseCommandModel,
24+
BotInfo,
25+
Command,
26+
CommandContext,
27+
CommandModel,
2428
EchoCommand,
2529
HelpCommand,
30+
LegacyCommandAdapter,
2631
NoResponseCommand,
2732
ReplyCommand,
2833
ReplyToAllCommand,
2934
ReplyToAuthorCommand,
3035
ReplyToOtherCommand,
3136
ScheduleCommand,
3237
StatusCommand,
38+
command,
3339
mention_user,
3440
)
3541
from .gateway import CspBotGateway, Gateway, GatewayChannels, GatewayModule, GatewaySettings
42+
from .persistence import FsspecStateStore, InMemoryStateStore, ScheduledCommandRecord, ScheduleStore, StateStore, StoredRecord
3643
from .structs import Backend, BotCommand, BotMessage, CommandVariant
3744
from .utils import format_message, get_backend_format, is_valid_url, mention_users
3845

@@ -54,7 +61,14 @@
5461
"SlackConfig",
5562
"SymphonyConfig",
5663
"TelegramConfig",
57-
# Commands
64+
# Commands — new framework
65+
"Command",
66+
"CommandContext",
67+
"CommandModel",
68+
"BotInfo",
69+
"LegacyCommandAdapter",
70+
"command",
71+
# Commands — legacy
5872
"BaseCommand",
5973
"BaseCommandModel",
6074
"EchoCommand",
@@ -73,6 +87,13 @@
7387
"GatewayChannels",
7488
"GatewayModule",
7589
"GatewaySettings",
90+
# Persistence
91+
"FsspecStateStore",
92+
"InMemoryStateStore",
93+
"ScheduleStore",
94+
"ScheduledCommandRecord",
95+
"StateStore",
96+
"StoredRecord",
7697
# Structs
7798
"Backend",
7899
"BotCommand",

0 commit comments

Comments
 (0)