fastadmin统一通知接口

from telert.messaging import Provider, configure_provider
from telert import send

# 固定的API前缀
API_PREFIX = "https://site.com/notice/api/"

class telertNotice:
    @staticmethod
    def sent(message, api_path="modulenotice"):
        """
        发送消息到指定API路径
        :param message: 要发送的消息内容
        :param api_path: API路径最后一段,如"modulenotice",会自动拼接到固定前缀后
        """
        payload = '{"msg": "%s"}' % message
        url = API_PREFIX + api_path
        print(f"即将发送到接口({url})的数据:", payload)

        configure_provider(
            Provider.ENDPOINT,
            url=url,
            method="POST",
            headers={"Authorization": "yourpassword"},
            payload_template='{"msg": "{message}"}',
            name="临时API",
            timeout=30
        )
        send(message, provider="endpoint")

 

调用方法

from telert_inc import telertNotice
    telertNotice.sent('videofiles,视频图片文字识别已完成,7','modulenotice')

 

posted @ 2025-07-10 14:32  meetrice  阅读(15)  评论(0)    收藏  举报