ForcePilot/backend/package/yuxi/channel/extensions/aliyun_sms/status.py
Kris b8864ac12f feat(aliyun-sms): 新增阿里云短信渠道插件
实现完整的阿里云短信服务接入能力,包含短信发送、状态回执处理、上行消息接收、安全策略校验、会话管理等功能
2026-05-21 10:39:43 +08:00

37 lines
1.1 KiB
Python

from __future__ import annotations
import logging
from datetime import datetime
logger = logging.getLogger(__name__)
class AliyunSmsStatus:
def __init__(self, gateway):
self._gateway = gateway
async def probe(self) -> bool:
try:
today = datetime.now().strftime("%Y%m%d")
await self._gateway.client.query_send_statistics(
start_date=today,
end_date=today,
page_size=1,
)
return True
except Exception as e:
logger.warning("阿里云短信探活失败: account=%s error=%s", self._gateway.account.account_id, e)
return False
def build_summary(self, snapshot: dict | None = None) -> dict:
account = self._gateway.account
return {
"status": "running" if self._gateway.running else "stopped",
"account_id": account.account_id,
"sign_name": account.sign_name,
"region": account.region,
"configured": account.is_configured(),
"dm_policy": account.dm_policy,
"phone_mask_enabled": account.phone_mask_enabled,
}