Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

添加Wxpusher推送 #231

Merged
merged 6 commits into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion config/push.ini.example
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,12 @@ key=你的qmsg酱key

# Discord Channel Webhook
[discord]
webhook=https://discord.com/api/webhooks/your_channel_id_xxxxxx/your_webhook_token_xxxxxx
webhook=https://discord.com/api/webhooks/your_channel_id_xxxxxx/your_webhook_token_xxxxxx

# wxpusher
# https://wxpusher.zjiecode.com/ 获取所需参数
[wxpusher]
app_token =
uids =
topic_ids =
# UID 与 Topic_Id 选填,多个 UID 使用逗号分隔
29 changes: 29 additions & 0 deletions push.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,35 @@ def wintoast(self, status_id, push_message):
except:
log.error(f"请先pip install win11toast再使用win通知")

def wxpusher(self, status_id, push_message):
"""
WxPusher
"""
try:
from wxpusher import WxPusher
except:
log.error("WxPusher 模块未安装,请先执行pip install wxpusher")
return 1
app_token = self.cfg.get('wxpusher', 'app_token', fallback=None)
uids = self.cfg.get('wxpusher', 'uids', fallback="").split(',')
topic_ids = self.cfg.get('wxpusher', 'topic_ids', fallback="").split(',')
if not app_token or not topic_ids:
log.error("WxPusher 推送失败!请检查 app_token, topic_ids 是否正确配置")
return 1
response = WxPusher.send_message(
content=get_push_title(status_id) + "\r\n" + push_message,
uids=[uid for uid in uids if uid], # 过滤空值
topic_ids=[int(tid) for tid in topic_ids if tid.isdigit()],
token=app_token
)
if "data" in response:
status_list = [item.get("status", "未知状态") for item in response["data"]]
log.info(f"WxPusher 推送状态:{status_list}")
return 0
else:
log.error(f"WxPusher 推送失败:{response}")
return 1

# 其他推送方法,例如 ftqq, pushplus 等, 和 telegram 方法相似
# 在类内部直接使用 self.cfg 读取配置

Expand Down