加入bot,自动注入内容,在项目启动完成之后,给每个插件注入bot
This commit is contained in:
20
robot.py
20
robot.py
@@ -214,7 +214,7 @@ class Robot:
|
||||
self.LOG.error(f"获取新消息失败 {e}")
|
||||
if "用户可能退出" in str(e):
|
||||
self.LOG.error(f"用户可能退出: {e}")
|
||||
self.login_twice_auto_auth()
|
||||
await self.login_twice_auto_auth()
|
||||
await asyncio.sleep(5)
|
||||
continue
|
||||
|
||||
@@ -296,7 +296,8 @@ class Robot:
|
||||
self.nickname = self.ipad_bot.nickname
|
||||
self.alias = self.ipad_bot.alias
|
||||
self.phone = self.ipad_bot.phone
|
||||
|
||||
# 注入加载完成的bot
|
||||
self.plugin_manager.inject_bot(self.ipad_bot)
|
||||
self.LOG.info(
|
||||
f"wechat_ipad登录账号信息: wxid: {self.wxid} 昵称: {self.nickname} 微信号: {self.alias} 手机号: {self.phone}")
|
||||
break
|
||||
@@ -315,7 +316,7 @@ class Robot:
|
||||
self.LOG.error(f"wechat_ipad heartbeat: {e}")
|
||||
if "用户可能退出" in str(e):
|
||||
self.LOG.error(f"用户可能退出: {e}")
|
||||
self.login_twice_auto_auth()
|
||||
await self.login_twice_auto_auth()
|
||||
await asyncio.sleep(60)
|
||||
|
||||
async def _heartbeat_task_long(self):
|
||||
@@ -332,7 +333,7 @@ class Robot:
|
||||
self.LOG.error(f"wechat_ipad heartbeat long: {e}")
|
||||
if "用户可能退出" in str(e):
|
||||
self.LOG.error(f"用户可能退出: {e}")
|
||||
self.login_twice_auto_auth()
|
||||
await self.login_twice_auto_auth()
|
||||
await asyncio.sleep(120)
|
||||
|
||||
async def _process_ipad_message(self, message: WxMessage):
|
||||
@@ -412,9 +413,9 @@ class Robot:
|
||||
self.gbm.load_local_cache()
|
||||
await self.ipad_bot.send_text_message("filehelper", "已更新")
|
||||
elif content.clean_content == "PDF":
|
||||
self.generate_sehuatang_pdf()
|
||||
await self.generate_sehuatang_pdf()
|
||||
elif content.clean_content == "排行榜":
|
||||
self.generate_and_send_ranking()
|
||||
await self.generate_and_send_ranking()
|
||||
|
||||
if is_group:
|
||||
self.LOG.debug(f"入库和记录群消息: {message}")
|
||||
@@ -614,10 +615,10 @@ class Robot:
|
||||
self.contacts_db.delete_chatroom_all_info(group_id)
|
||||
self.LOG.info("联系人信息刷新完成")
|
||||
|
||||
def login_twice_auto_auth(self) -> None:
|
||||
async def login_twice_auto_auth(self) -> None:
|
||||
try:
|
||||
self.LOG.info(f"定时进行二次登录动作")
|
||||
resp = self.ipad_bot.twice_auto_auth()
|
||||
resp = await self.ipad_bot.twice_auto_auth()
|
||||
if resp:
|
||||
self.LOG.info(f"定时二次登录成功!")
|
||||
if self.ipad_running:
|
||||
@@ -632,7 +633,6 @@ class Robot:
|
||||
|
||||
# ============================================== 业务内容==========================================================
|
||||
|
||||
|
||||
async def news_baidu_report_auto(self) -> None:
|
||||
try:
|
||||
news = News().get_baidu_news()
|
||||
@@ -648,6 +648,7 @@ class Robot:
|
||||
self.LOG.error(f"newsEnReport error:{e}")
|
||||
|
||||
# 使用装饰器标记定时任务 星期五 10:30 执行
|
||||
|
||||
async def send_epic_free_games(self):
|
||||
try:
|
||||
if is_friday():
|
||||
@@ -657,6 +658,7 @@ class Robot:
|
||||
self.LOG.error(f"sendEpicFreeGames error:{e}")
|
||||
|
||||
# 使用装饰器标记定时任务
|
||||
|
||||
async def message_count_to_db(self):
|
||||
try:
|
||||
self.message_storage.write_to_db()
|
||||
|
||||
Reference in New Issue
Block a user