新增Slack适配器全套核心模块,包括消息处理流水线、会话管理、配置适配、权限控制等完整功能: 1. 新增语音、视觉相关的TTS和图像分析导出接口 2. 实现消息预处理、路由、线程上下文处理的完整流水线 3. 新增账号管理、缓存机制、房间上下文提取功能 4. 支持Webhook和Socket Mode两种事件接收方式 5. 实现权限白名单、审批配对、自动状态管理功能 6. 新增配置迁移、作用域校验、重连策略等辅助模块
52 lines
1.3 KiB
Python
52 lines
1.3 KiB
Python
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass
|
|
from typing import Any
|
|
|
|
|
|
@dataclass
|
|
class ActionThreadBehavior:
|
|
reply_in_thread: bool = True
|
|
broadcast_to_channel: bool = False
|
|
use_thread_ts: str = ""
|
|
|
|
@property
|
|
def should_broadcast(self) -> bool:
|
|
return self.broadcast_to_channel
|
|
|
|
def resolve_ts(self, parent_ts: str = "", fallback_ts: str = "") -> str:
|
|
return self.use_thread_ts or parent_ts or fallback_ts
|
|
|
|
|
|
def resolve_action_thread_behavior(
|
|
event: dict[str, Any],
|
|
*,
|
|
channel: str = "",
|
|
thread_ts: str = "",
|
|
) -> ActionThreadBehavior:
|
|
is_in_thread = bool(thread_ts)
|
|
|
|
broadcast = False
|
|
if event.get("broadcast_reply"):
|
|
broadcast = True
|
|
|
|
return ActionThreadBehavior(
|
|
reply_in_thread=is_in_thread,
|
|
broadcast_to_channel=broadcast,
|
|
use_thread_ts=thread_ts if is_in_thread else "",
|
|
)
|
|
|
|
|
|
def resolve_button_action_threading(
|
|
action_payload: dict[str, Any],
|
|
channel: str,
|
|
message: dict[str, Any],
|
|
) -> ActionThreadBehavior:
|
|
thread_ts = message.get("thread_ts", "")
|
|
|
|
return ActionThreadBehavior(
|
|
reply_in_thread=bool(thread_ts),
|
|
broadcast_to_channel=action_payload.get("broadcast_reply", False),
|
|
use_thread_ts=thread_ts,
|
|
)
|