fix 插件无法发送消息
This commit is contained in:
parent
3a07543322
commit
95df7b0797
@ -18,6 +18,7 @@ from app.helper.module import ModuleHelper
|
|||||||
from app.helper.sites import SitesHelper
|
from app.helper.sites import SitesHelper
|
||||||
from app.log import logger
|
from app.log import logger
|
||||||
from app.plugins import _PluginBase
|
from app.plugins import _PluginBase
|
||||||
|
from app.schemas import Notification
|
||||||
from app.utils.http import RequestUtils
|
from app.utils.http import RequestUtils
|
||||||
from app.utils.site import SiteUtils
|
from app.utils.site import SiteUtils
|
||||||
from app.utils.string import StringUtils
|
from app.utils.string import StringUtils
|
||||||
@ -142,8 +143,8 @@ class AutoSignIn(_PluginBase):
|
|||||||
"status": s[1]
|
"status": s[1]
|
||||||
} for s in status])
|
} for s in status])
|
||||||
# 发送通知
|
# 发送通知
|
||||||
self.chain.post_message(title="站点自动签到",
|
self.chain.post_message(Notification(title="站点自动签到",
|
||||||
text="\n".join([f'【{s[0]}】{s[1]}' for s in status if s]))
|
text="\n".join([f'【{s[0]}】{s[1]}' for s in status if s])))
|
||||||
else:
|
else:
|
||||||
logger.error("站点签到任务失败!")
|
logger.error("站点签到任务失败!")
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ from app.helper.sites import SitesHelper
|
|||||||
from app.log import logger
|
from app.log import logger
|
||||||
from app.plugins import _PluginBase
|
from app.plugins import _PluginBase
|
||||||
from app.plugins.sitestatistic.siteuserinfo import ISiteUserInfo
|
from app.plugins.sitestatistic.siteuserinfo import ISiteUserInfo
|
||||||
|
from app.schemas import Notification
|
||||||
from app.utils.http import RequestUtils
|
from app.utils.http import RequestUtils
|
||||||
from app.utils.string import StringUtils
|
from app.utils.string import StringUtils
|
||||||
from app.utils.timer import TimerUtils
|
from app.utils.timer import TimerUtils
|
||||||
@ -31,7 +32,6 @@ lock = Lock()
|
|||||||
|
|
||||||
|
|
||||||
class SiteStatistic(_PluginBase):
|
class SiteStatistic(_PluginBase):
|
||||||
|
|
||||||
# 插件名称
|
# 插件名称
|
||||||
plugin_name = "站点数据统计"
|
plugin_name = "站点数据统计"
|
||||||
# 插件描述
|
# 插件描述
|
||||||
@ -309,10 +309,10 @@ class SiteStatistic(_PluginBase):
|
|||||||
for head, date, content in site_user_info.message_unread_contents:
|
for head, date, content in site_user_info.message_unread_contents:
|
||||||
msg_title = f"【站点 {site_user_info.site_name} 消息】"
|
msg_title = f"【站点 {site_user_info.site_name} 消息】"
|
||||||
msg_text = f"时间:{date}\n标题:{head}\n内容:\n{content}"
|
msg_text = f"时间:{date}\n标题:{head}\n内容:\n{content}"
|
||||||
self.chain.post_message(title=msg_title, text=msg_text)
|
self.chain.post_message(Notification(title=msg_title, text=msg_text))
|
||||||
else:
|
else:
|
||||||
self.chain.post_message(title=f"站点 {site_user_info.site_name} 收到 "
|
self.chain.post_message(Notification(title=f"站点 {site_user_info.site_name} 收到 "
|
||||||
f"{site_user_info.message_unread} 条新消息,请登陆查看")
|
f"{site_user_info.message_unread} 条新消息,请登陆查看"))
|
||||||
|
|
||||||
@eventmanager.register(EventType.SiteStatistic)
|
@eventmanager.register(EventType.SiteStatistic)
|
||||||
def refresh(self, event: Event):
|
def refresh(self, event: Event):
|
||||||
@ -394,6 +394,6 @@ class SiteStatistic(_PluginBase):
|
|||||||
f"总上传:{StringUtils.str_filesize(incUploads)}\n"
|
f"总上传:{StringUtils.str_filesize(incUploads)}\n"
|
||||||
f"总下载:{StringUtils.str_filesize(incDownloads)}\n"
|
f"总下载:{StringUtils.str_filesize(incDownloads)}\n"
|
||||||
f"————————————")
|
f"————————————")
|
||||||
self.chain.post_message(title="站点数据统计", text="\n".join(messages))
|
self.chain.post_message(Notification(title="站点数据统计", text="\n".join(messages)))
|
||||||
|
|
||||||
logger.info("站点数据刷新完成")
|
logger.info("站点数据刷新完成")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user