You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
809 B
27 lines
809 B
# -*- coding: utf-8 -*-
|
|
"""通知服务"""
|
|
|
|
import httpx
|
|
from datetime import datetime
|
|
from config.settings import settings
|
|
|
|
|
|
class NotificationService:
|
|
"""通知服务类"""
|
|
|
|
@staticmethod
|
|
def send_to_gotify(success_count: int, fail_count: int) -> None:
|
|
"""发送结果到Gotify"""
|
|
now = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
|
text = f"总计: 成功 {success_count} 个, 失败 {fail_count} 个\n\n完成时间: {now}"
|
|
title = f"alpha模拟结果 时间: {now}"
|
|
|
|
try:
|
|
resp = httpx.post(
|
|
settings.GOTIFY_URL,
|
|
json={'title': title, 'message': text},
|
|
timeout=10
|
|
)
|
|
print("通知发送成功")
|
|
except Exception as e:
|
|
print(f"通知发送失败: {e}") |