ForcePilot/backend/package/yuxi/channels/policy/directory.py

35 lines
1.1 KiB
Python
Raw Normal View History

from __future__ import annotations
from abc import ABC, abstractmethod
class BaseDirectoryAdapter(ABC):
"""目录服务接口
定义三个标准查询方法跨渠道统一
- list_peers(config, account_id) 列出可联系的人/用户
- list_groups(config, account_id) 列出可交互的群组
- search_peers(query) 搜索联系人可选
"""
@abstractmethod
async def list_peers(self, config: dict, account_id: str = "default") -> list[dict]:
"""列出所有可联系的人/用户
各渠道实现
- 微信: WeCom 通讯录 API / Bridge /contacts
- 飞书: 飞书通讯录 API
- WhatsApp: Bridge /contacts
- QQBot: 频道成员 API
"""
...
@abstractmethod
async def list_groups(self, config: dict, account_id: str = "default") -> list[dict]:
"""列出所有可交互的群组"""
...
async def search_peers(self, query: str) -> list[dict]:
"""搜索联系人(可选实现,默认返回空)"""
return []