新增 IRC 渠道的完整扩展实现,包括客户端连接管理、消息收发与流式处理、安全策略与配对验证、消息去重与规范化、状态监控与健康探测、配置模型与账户管理、错误处理等模块。
78 lines
2.0 KiB
Python
78 lines
2.0 KiB
Python
from enum import Enum
|
|
|
|
from pydantic import BaseModel
|
|
|
|
|
|
class DmPolicy(str, Enum):
|
|
PAIRING = "pairing"
|
|
OPEN = "open"
|
|
DISABLED = "disabled"
|
|
|
|
|
|
class GroupPolicy(str, Enum):
|
|
OPEN = "open"
|
|
ALLOWLIST = "allowlist"
|
|
DISABLED = "disabled"
|
|
|
|
|
|
class IrcNickServConfig(BaseModel):
|
|
enabled: bool = False
|
|
service: str = "NickServ"
|
|
password: str = ""
|
|
password_file: str | None = None
|
|
register_nick: bool = False
|
|
register_email: str = ""
|
|
|
|
|
|
class IrcChannelConfig(BaseModel):
|
|
require_mention: bool = True
|
|
enabled: bool = True
|
|
allow_from: list[str] = []
|
|
system_prompt: str | None = None
|
|
|
|
|
|
class IrcAccountConfig(BaseModel):
|
|
name: str | None = None
|
|
enabled: bool = True
|
|
dangerously_allow_name_matching: bool = False
|
|
host: str = ""
|
|
port: int = 6697
|
|
tls: bool = True
|
|
nick: str = ""
|
|
username: str = "openclaw"
|
|
realname: str = "OpenClaw"
|
|
password: str = ""
|
|
password_file: str | None = None
|
|
nickserv: IrcNickServConfig = IrcNickServConfig()
|
|
dm_policy: DmPolicy = DmPolicy.PAIRING
|
|
allow_from: list[str] = []
|
|
group_policy: GroupPolicy = GroupPolicy.ALLOWLIST
|
|
group_allow_from: list[str] = []
|
|
groups: dict[str, IrcChannelConfig] = {}
|
|
channels: list[str] = []
|
|
text_chunk_limit: int = 350
|
|
block_streaming: bool = True
|
|
sasl_enabled: bool = False
|
|
|
|
|
|
class IrcConfig(BaseModel):
|
|
enabled: bool = True
|
|
accounts: dict[str, IrcAccountConfig] = {}
|
|
default_account: str = "default"
|
|
host: str = ""
|
|
port: int = 6697
|
|
tls: bool = True
|
|
nick: str = ""
|
|
username: str = "openclaw"
|
|
realname: str = "OpenClaw"
|
|
password: str = ""
|
|
password_file: str | None = None
|
|
nickserv: IrcNickServConfig = IrcNickServConfig()
|
|
dm_policy: DmPolicy = DmPolicy.PAIRING
|
|
allow_from: list[str] = []
|
|
group_policy: GroupPolicy = GroupPolicy.ALLOWLIST
|
|
group_allow_from: list[str] = []
|
|
groups: dict[str, IrcChannelConfig] = {}
|
|
channels: list[str] = []
|
|
dangerously_allow_name_matching: bool = False
|
|
text_chunk_limit: int = 350 |