使用 gotify 推送消息。
(title: str, content: str)
| 246 | |
| 247 | |
| 248 | def gotify(title: str, content: str) -> None: |
| 249 | """ |
| 250 | 使用 gotify 推送消息。 |
| 251 | """ |
| 252 | if not push_config.get("GOTIFY_URL") or not push_config.get("GOTIFY_TOKEN"): |
| 253 | print("gotify 服务的 GOTIFY_URL 或 GOTIFY_TOKEN 未设置!!\n取消推送") |
| 254 | return |
| 255 | print("gotify 服务启动") |
| 256 | |
| 257 | url = f'{push_config.get("GOTIFY_URL")}/message?token={push_config.get("GOTIFY_TOKEN")}' |
| 258 | data = { |
| 259 | "title": title, |
| 260 | "message": content, |
| 261 | "priority": push_config.get("GOTIFY_PRIORITY"), |
| 262 | } |
| 263 | response = requests.post(url, data=data).json() |
| 264 | |
| 265 | if response.get("id"): |
| 266 | print("gotify 推送成功!") |
| 267 | else: |
| 268 | print("gotify 推送失败!") |
| 269 | |
| 270 | |
| 271 | def iGot(title: str, content: str) -> None: |