ForcePilot/backend/package/yuxi/channel/extensions/tencent_im/status.py

31 lines
973 B
Python
Raw Normal View History

import logging
from yuxi.channel.extensions.tencent_im.gateway import TencentIMError, TencentIMGateway
logger = logging.getLogger(__name__)
class TencentIMStatus:
def __init__(self, gateway: TencentIMGateway | None = None):
self._gateway = gateway
async def probe(self, account: dict | None = None) -> bool:
if not self._gateway or not self._gateway._running:
return False
try:
await self._gateway.call_api(
"im_open_login_svc/account_check", {"CheckItem": [{"UserID": self._gateway.account.admin_userid}]}
)
return True
except (TencentIMError, Exception):
logger.warning("TencentIM status probe failed")
return False
def build_summary(self, snapshot: object) -> dict:
return {
"channel": "tencent-im",
"mode": "webhook",
"output_format": "json",
"streaming": "block",
}