新增企业微信、微博、WhatsApp、Workplace 四个渠道扩展。 企业微信渠道扩展主要模块:config, gateway, webhook, webhook_bot, outbound, streaming, pairing, security, crypto, dedupe, persistent_dedupe, card, directory, events, externalcontact, media, mentions, menu, message, oauth, status 微博渠道扩展主要模块:config, gateway, webhook, outbound, streaming, pairing, security, dedupe, passive_reply, broadcast, message, menu, media, subscription, template, status WhatsApp 渠道扩展主要模块:config, gateway, webhook, outbound, streaming, pairing, security, dedupe, actions, monitor, status Workplace 渠道扩展主要模块:config, gateway, webhook, outbound, streaming, pairing, security, dedupe, actions, challenge, groups, media, mentions, menu, monitor, persona, quick_reply, signature, subscriptions, template, threading, users, status
41 lines
1.3 KiB
Python
41 lines
1.3 KiB
Python
import logging
|
|
|
|
from yuxi.channel.protocols import ChannelAccountSnapshot
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
class WeComStatus:
|
|
def __init__(self, gateway=None):
|
|
self._gateway = gateway
|
|
|
|
async def probe(self, account: dict | None = None) -> bool:
|
|
if self._gateway is None:
|
|
return False
|
|
token = self._gateway.access_token
|
|
return token is not None and len(token) > 0
|
|
|
|
def build_summary(self, snapshot: object) -> dict:
|
|
return {
|
|
"channel": "wecom",
|
|
"running": self._gateway is not None and getattr(self._gateway, "_running", False),
|
|
"token_valid": self._gateway is not None and self._gateway.access_token is not None,
|
|
}
|
|
|
|
def build_account_snapshot(
|
|
self,
|
|
account: dict,
|
|
config: dict,
|
|
runtime: ChannelAccountSnapshot | None = None,
|
|
probe_result: object | None = None,
|
|
audit: object | None = None,
|
|
) -> ChannelAccountSnapshot:
|
|
return ChannelAccountSnapshot(
|
|
account_id=account.get("account_id", "default"),
|
|
name=account.get("name"),
|
|
configured=True,
|
|
running=True,
|
|
connected=bool(probe_result),
|
|
dm_policy=account.get("dm_policy"),
|
|
)
|