mirror of
https://github.com/EstrellaXD/Auto_Bangumi.git
synced 2026-04-08 21:20:32 +08:00
Add Wecom Notification
添加了企业微信推送通道
This commit is contained in:
@@ -17,6 +17,8 @@ def getClient(type=settings.notification.type):
|
||||
return ServerChanNotification
|
||||
elif type.lower() == "bark":
|
||||
return BarkNotification
|
||||
elif type.lower() == "wecom":
|
||||
return WecomNotification
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from .bark import BarkNotification
|
||||
from .server_chan import ServerChanNotification
|
||||
from .telegram import TelegramNotification
|
||||
from .telegram import TelegramNotification
|
||||
from .wecom import WecomNotification
|
||||
35
src/module/notification/plugin/wecom.py
Normal file
35
src/module/notification/plugin/wecom.py
Normal file
@@ -0,0 +1,35 @@
|
||||
import logging
|
||||
from module.network import RequestContent
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class WecomNotification(RequestContent):
|
||||
"""企业微信推送 基于图文消息"""
|
||||
|
||||
def __init__(self, token, chat_id, **kwargs):
|
||||
super().__init__()
|
||||
#Chat_id is used as noti_url in this push tunnel
|
||||
self.notification_url = f"{chat_id}"
|
||||
self.token = token
|
||||
|
||||
def post_msg(self, text: str) -> bool:
|
||||
##Change message format to match Wecom push better
|
||||
info = text.split(":")
|
||||
print(info)
|
||||
title = "【番剧更新】" + info[1].split("\n")[0].strip()
|
||||
msg = info[2].split("\n")[0].strip()+" "+info[3].split("\n")[0].strip()
|
||||
picurl = info[3].split("\n")[1].strip()
|
||||
#Default pic to avoid blank in message. Resolution:1068*455
|
||||
if picurl == "":
|
||||
picurl = "https://article.biliimg.com/bfs/article/d8bcd0408bf32594fd82f27de7d2c685829d1b2e.png"
|
||||
data = {
|
||||
"key":self.token,
|
||||
"type": "news",
|
||||
"title": title,
|
||||
"msg": msg,
|
||||
"picurl":picurl
|
||||
}
|
||||
resp = self.post_data(self.notification_url, data)
|
||||
logger.debug(f"Wecom notification: {resp.status_code}")
|
||||
return resp.status_code == 200
|
||||
Reference in New Issue
Block a user