Skip to content

Commit 0c8ec0d

Browse files
committed
[wip] move to chatom
Signed-off-by: Tim Paine <3105306+timkpaine@users.noreply.github.com>
1 parent e18756e commit 0c8ec0d

23 files changed

Lines changed: 1889 additions & 2424 deletions

csp_bot/__init__.py

Lines changed: 83 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,86 @@
1-
__version__ = "1.1.0"
1+
"""CSP Bot - Multi-platform chat bot using chatom.
22
3+
This package provides a CSP-based bot framework that leverages
4+
chatom for unified cross-platform chat support.
5+
6+
Key features:
7+
- Unified Message, User, Channel models via chatom
8+
- Cross-platform mention generation
9+
- Backend-specific message formatting
10+
- Entity recognition and parsing
11+
- Support for Slack, Symphony, and Discord
12+
"""
13+
14+
__version__ = "2.0.0"
15+
16+
# Re-export chatom types for convenience
17+
from chatom import Channel, Message, User
318

4-
from .backends import *
519
from .bot import Bot
6-
from .bot_config import *
7-
from .commands import *
8-
from .config import *
9-
from .gateway import *
10-
from .structs import *
11-
from .utils import *
20+
from .bot_config import BotConfig, DiscordConfig, SlackConfig, SymphonyConfig
21+
from .commands import (
22+
BaseCommand,
23+
BaseCommandModel,
24+
EchoCommand,
25+
HelpCommand,
26+
NoResponseCommand,
27+
ReplyCommand,
28+
ReplyToAllCommand,
29+
ReplyToAuthorCommand,
30+
ReplyToOtherCommand,
31+
ScheduleCommand,
32+
StatusCommand,
33+
mention_user,
34+
)
35+
from .gateway import CspBotGateway, Gateway, GatewayChannels, GatewayModule, GatewaySettings
36+
from .structs import Backend, BotCommand, BotMessage, CommandVariant
37+
from .utils import format_message, get_backend_format, is_valid_url, mention_users
38+
39+
# Alias for backwards compatibility with tests
40+
Channels = GatewayChannels
41+
42+
__all__ = (
43+
# Version
44+
"__version__",
45+
# Chatom re-exports
46+
"Channel",
47+
"Message",
48+
"User",
49+
# Bot
50+
"Bot",
51+
# Config
52+
"BotConfig",
53+
"DiscordConfig",
54+
"SlackConfig",
55+
"SymphonyConfig",
56+
# Commands
57+
"BaseCommand",
58+
"BaseCommandModel",
59+
"EchoCommand",
60+
"HelpCommand",
61+
"NoResponseCommand",
62+
"ReplyCommand",
63+
"ReplyToAllCommand",
64+
"ReplyToAuthorCommand",
65+
"ReplyToOtherCommand",
66+
"ScheduleCommand",
67+
"StatusCommand",
68+
# Gateway
69+
"Channels",
70+
"CspBotGateway",
71+
"Gateway",
72+
"GatewayChannels",
73+
"GatewayModule",
74+
"GatewaySettings",
75+
# Structs
76+
"Backend",
77+
"BotCommand",
78+
"BotMessage",
79+
"CommandVariant",
80+
# Utils
81+
"format_message",
82+
"get_backend_format",
83+
"is_valid_url",
84+
"mention_user",
85+
"mention_users",
86+
)

csp_bot/backends/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
"""Backend adapters for csp-bot using chatom.
2+
3+
This module provides access to backend adapters through chatom's
4+
unified interface. Each backend exposes:
5+
- Config: Configuration class from chatom
6+
- Adapter: CSP adapter from csp-adapter-*
7+
- Message: Backend-specific message type from chatom
8+
"""
9+
110
from .discord import *
211
from .slack import *
312
from .symphony import *

csp_bot/backends/discord.py

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,31 @@
1-
from csp import Struct
2-
from pydantic import BaseModel
1+
"""Discord backend integration using chatom.
2+
3+
This module provides Discord-specific types and adapters through chatom.
4+
"""
35

46
__all__ = (
5-
"DiscordAdapterConfig",
6-
"DiscordAdapterManager",
7+
"DiscordConfig",
8+
"DiscordAdapter",
79
"DiscordMessage",
8-
"mention_user_discord",
10+
"DiscordUser",
911
)
1012

1113
try:
12-
from csp_adapter_discord import DiscordAdapterConfig, DiscordAdapterManager, DiscordMessage, mention_user as mention_user_discord
14+
from chatom.discord import (
15+
DiscordConfig,
16+
DiscordMessage,
17+
DiscordUser,
18+
)
19+
from csp_adapter_discord import DiscordAdapter
1320
except ImportError:
21+
from chatom import Message as ChatomMessage, User as ChatomUser
22+
from pydantic import BaseModel
1423

15-
class DiscordAdapterConfig(BaseModel):
16-
pass
17-
18-
DiscordAdapterManager = None
24+
class DiscordConfig(BaseModel):
25+
"""Placeholder when chatom.discord is not available."""
1926

20-
class DiscordMessage(Struct):
21-
_ignore: str = ""
27+
pass
2228

23-
mention_user_discord = None
29+
DiscordAdapter = None
30+
DiscordMessage = ChatomMessage
31+
DiscordUser = ChatomUser

csp_bot/backends/slack.py

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,34 @@
1-
from csp import Struct
2-
from pydantic import BaseModel
1+
"""Slack backend integration using chatom.
2+
3+
This module provides Slack-specific types and adapters through chatom.
4+
"""
35

46
__all__ = (
5-
"SlackAdapterConfig",
6-
"SlackAdapterManager",
7+
"SlackConfig",
8+
"SlackAdapter",
79
"SlackMessage",
8-
"mention_user_slack",
10+
"SlackUser",
11+
"SlackPresenceStatus",
912
)
1013

11-
# reexport
1214
try:
13-
from csp_adapter_slack import SlackAdapterConfig, SlackAdapterManager, SlackMessage, mention_user as mention_user_slack
15+
from chatom.slack import (
16+
SlackConfig,
17+
SlackMessage,
18+
SlackPresenceStatus,
19+
SlackUser,
20+
)
21+
from csp_adapter_slack import SlackAdapter
1422
except ImportError:
23+
from chatom import Message as ChatomMessage, User as ChatomUser
24+
from pydantic import BaseModel
1525

16-
class SlackAdapterConfig(BaseModel):
17-
pass
18-
19-
SlackAdapterManager = None
26+
class SlackConfig(BaseModel):
27+
"""Placeholder when chatom.slack is not available."""
2028

21-
class SlackMessage(Struct):
22-
_ignore: str = ""
29+
pass
2330

24-
mention_user_slack = None
31+
SlackAdapter = None
32+
SlackMessage = ChatomMessage
33+
SlackUser = ChatomUser
34+
SlackPresenceStatus = None

csp_bot/backends/symphony.py

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,34 @@
1-
from csp import Struct
2-
from pydantic import BaseModel
1+
"""Symphony backend integration using chatom.
2+
3+
This module provides Symphony-specific types and adapters through chatom.
4+
"""
35

46
__all__ = (
5-
"SymphonyAdapterConfig",
7+
"SymphonyConfig",
68
"SymphonyAdapter",
79
"SymphonyMessage",
8-
"Presence",
9-
"mention_user_symphony",
10+
"SymphonyUser",
11+
"SymphonyPresenceStatus",
1012
)
1113

12-
# reexport
1314
try:
14-
from csp_adapter_symphony import SymphonyAdapter, SymphonyAdapterConfig, SymphonyMessage, mention_user as mention_user_symphony
15-
from csp_adapter_symphony.adapter import Presence
15+
from chatom.symphony import (
16+
SymphonyConfig,
17+
SymphonyMessage,
18+
SymphonyPresenceStatus,
19+
SymphonyUser,
20+
)
21+
from csp_adapter_symphony import SymphonyAdapter
1622
except ImportError:
23+
from chatom import Message as ChatomMessage, User as ChatomUser
24+
from pydantic import BaseModel
25+
26+
class SymphonyConfig(BaseModel):
27+
"""Placeholder when chatom.symphony is not available."""
1728

18-
class SymphonyAdapterConfig(BaseModel):
1929
pass
2030

2131
SymphonyAdapter = None
22-
Presence = None
23-
24-
class SymphonyMessage(Struct):
25-
_ignore: str = ""
26-
27-
mention_user_symphony = None
32+
SymphonyMessage = ChatomMessage
33+
SymphonyUser = ChatomUser
34+
SymphonyPresenceStatus = None

0 commit comments

Comments
 (0)