通过 微加机器人 推送消息。
(title: str, content: str)
| 427 | |
| 428 | |
| 429 | def weplus_bot(title: str, content: str) -> None: |
| 430 | """ |
| 431 | 通过 微加机器人 推送消息。 |
| 432 | """ |
| 433 | if not push_config.get("WE_PLUS_BOT_TOKEN"): |
| 434 | return |
| 435 | print("微加机器人 服务启动") |
| 436 | |
| 437 | template = "txt" |
| 438 | if len(content) > 800: |
| 439 | template = "html" |
| 440 | |
| 441 | url = "https://www.weplusbot.com/send" |
| 442 | data = { |
| 443 | "token": push_config.get("WE_PLUS_BOT_TOKEN"), |
| 444 | "title": title, |
| 445 | "content": content, |
| 446 | "template": template, |
| 447 | "receiver": push_config.get("WE_PLUS_BOT_RECEIVER"), |
| 448 | "version": push_config.get("WE_PLUS_BOT_VERSION"), |
| 449 | } |
| 450 | body = json.dumps(data).encode(encoding="utf-8") |
| 451 | headers = {"Content-Type": "application/json"} |
| 452 | response = requests.post(url=url, data=body, headers=headers).json() |
| 453 | |
| 454 | if response["code"] == 200: |
| 455 | print("微加机器人 推送成功!") |
| 456 | else: |
| 457 | print("微加机器人 推送失败!") |
| 458 | |
| 459 | |
| 460 | def qmsg_bot(title: str, content: str) -> None: |