通过PushDeer 推送消息
(title: str, content: str)
| 311 | |
| 312 | |
| 313 | def pushdeer(title: str, content: str) -> None: |
| 314 | """ |
| 315 | 通过PushDeer 推送消息 |
| 316 | """ |
| 317 | if not push_config.get("DEER_KEY"): |
| 318 | print("PushDeer 服务的 DEER_KEY 未设置!!\n取消推送") |
| 319 | return |
| 320 | print("PushDeer 服务启动") |
| 321 | data = { |
| 322 | "text": title, |
| 323 | "desp": content, |
| 324 | "type": "markdown", |
| 325 | "pushkey": push_config.get("DEER_KEY"), |
| 326 | } |
| 327 | url = "https://api2.pushdeer.com/message/push" |
| 328 | if push_config.get("DEER_URL"): |
| 329 | url = push_config.get("DEER_URL") |
| 330 | |
| 331 | response = requests.post(url, data=data).json() |
| 332 | |
| 333 | if len(response.get("content").get("result")) > 0: |
| 334 | print("PushDeer 推送成功!") |
| 335 | else: |
| 336 | print("PushDeer 推送失败!错误信息:", response) |
| 337 | |
| 338 | |
| 339 | def chat(title: str, content: str) -> None: |