邮件系统配置放到yaml里面。
This commit is contained in:
@@ -141,3 +141,12 @@ redis_config:
|
|||||||
db: 0
|
db: 0
|
||||||
decode_responses: true
|
decode_responses: true
|
||||||
|
|
||||||
|
|
||||||
|
# 邮件发送配置
|
||||||
|
email_config:
|
||||||
|
smtp_server: "smtp.163.com"
|
||||||
|
smtp_port: 465
|
||||||
|
sender_email: "bovine_liu@163.com"
|
||||||
|
sender_password: "LTS9BhmX9XhS36QS"
|
||||||
|
alert_recipient: "bovine_liu@163.com" # 警报邮件接收者
|
||||||
|
|
||||||
|
|||||||
@@ -44,3 +44,6 @@ class Config(object):
|
|||||||
# DB config
|
# DB config
|
||||||
self.mariadb = yconfig.get("db_config", {})
|
self.mariadb = yconfig.get("db_config", {})
|
||||||
self.redis = yconfig.get("redis_config", {})
|
self.redis = yconfig.get("redis_config", {})
|
||||||
|
|
||||||
|
# Email config
|
||||||
|
self.email = yconfig.get("email_config", {})
|
||||||
|
|||||||
14
robot.py
14
robot.py
@@ -95,10 +95,10 @@ class Robot:
|
|||||||
# 加载插件
|
# 加载插件
|
||||||
self.LOG.info("插件系统初始化完成")
|
self.LOG.info("插件系统初始化完成")
|
||||||
self.email_sender = EmailSender(
|
self.email_sender = EmailSender(
|
||||||
smtp_server="smtp.163.com",
|
smtp_server=self.config.email.get("smtp_server", "smtp.163.com"),
|
||||||
smtp_port=465,
|
smtp_port=self.config.email.get("smtp_port", 465),
|
||||||
sender_email="bovine_liu@163.com",
|
sender_email=self.config.email.get("sender_email", "bovine_liu@163.com"),
|
||||||
sender_password="LTS9BhmX9XhS36QS"
|
sender_password=self.config.email.get("sender_password", "LTS9BhmX9XhS36QS")
|
||||||
)
|
)
|
||||||
|
|
||||||
def init_wechat_ipad(self):
|
def init_wechat_ipad(self):
|
||||||
@@ -222,7 +222,7 @@ class Robot:
|
|||||||
self.LOG.error(f"获取新消息失败 {e}")
|
self.LOG.error(f"获取新消息失败 {e}")
|
||||||
if "用户可能退出" in str(e):
|
if "用户可能退出" in str(e):
|
||||||
self.LOG.error(f"用户可能退出: {e}")
|
self.LOG.error(f"用户可能退出: {e}")
|
||||||
self.email_sender.send_wechat_alert("bovine_liu@163.com", f"用户可能退出: {e}", self.wxid,
|
self.email_sender.send_wechat_alert(self.config.email.get("alert_recipient"), f"用户可能退出: {e}", self.wxid,
|
||||||
self.nickname)
|
self.nickname)
|
||||||
await self.login_twice_auto_auth()
|
await self.login_twice_auto_auth()
|
||||||
await asyncio.sleep(5)
|
await asyncio.sleep(5)
|
||||||
@@ -324,7 +324,7 @@ class Robot:
|
|||||||
self.LOG.error(f"wechat_ipad heartbeat: {e}")
|
self.LOG.error(f"wechat_ipad heartbeat: {e}")
|
||||||
if "用户可能退出" in str(e):
|
if "用户可能退出" in str(e):
|
||||||
self.LOG.error(f"用户可能退出: {e}")
|
self.LOG.error(f"用户可能退出: {e}")
|
||||||
self.email_sender.send_wechat_alert("bovine_liu@163.com", f"用户可能退出: {e}", self.wxid,
|
self.email_sender.send_wechat_alert(self.config.email.get("alert_recipient"), f"用户可能退出: {e}", self.wxid,
|
||||||
self.nickname)
|
self.nickname)
|
||||||
await self.login_twice_auto_auth()
|
await self.login_twice_auto_auth()
|
||||||
await asyncio.sleep(60)
|
await asyncio.sleep(60)
|
||||||
@@ -343,7 +343,7 @@ class Robot:
|
|||||||
self.LOG.error(f"wechat_ipad heartbeat long: {e}")
|
self.LOG.error(f"wechat_ipad heartbeat long: {e}")
|
||||||
if "用户可能退出" in str(e):
|
if "用户可能退出" in str(e):
|
||||||
self.LOG.error(f"用户可能退出: {e}")
|
self.LOG.error(f"用户可能退出: {e}")
|
||||||
self.email_sender.send_wechat_alert("bovine_liu@163.com", f"用户可能退出: {e}", self.wxid,
|
self.email_sender.send_wechat_alert(self.config.email.get("alert_recipient"), f"用户可能退出: {e}", self.wxid,
|
||||||
self.nickname)
|
self.nickname)
|
||||||
await self.login_twice_auto_auth()
|
await self.login_twice_auto_auth()
|
||||||
await asyncio.sleep(120)
|
await asyncio.sleep(120)
|
||||||
|
|||||||
Reference in New Issue
Block a user