Impl reload config
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
logging:
|
logging:
|
||||||
version: 1
|
version: 1
|
||||||
disable_existing_loggers: True
|
disable_existing_loggers: False
|
||||||
|
|
||||||
formatters:
|
formatters:
|
||||||
simple:
|
simple:
|
||||||
|
|||||||
20
main.py
20
main.py
@@ -2,7 +2,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import re
|
import re
|
||||||
from xmlrpc.client import Boolean
|
|
||||||
|
|
||||||
from func_chengyu import cy
|
from func_chengyu import cy
|
||||||
import robot.sdk.wcferry as WxSDK
|
import robot.sdk.wcferry as WxSDK
|
||||||
@@ -18,7 +17,7 @@ class Robot(BaseRobot):
|
|||||||
super().__init__(sdk)
|
super().__init__(sdk)
|
||||||
self.config = config
|
self.config = config
|
||||||
|
|
||||||
def toAt(self, msg) -> Boolean:
|
def toAt(self, msg) -> bool:
|
||||||
"""
|
"""
|
||||||
处理被 @ 消息,现在只固定回复: "你@我干嘛?"
|
处理被 @ 消息,现在只固定回复: "你@我干嘛?"
|
||||||
:param msg: 微信消息结构
|
:param msg: 微信消息结构
|
||||||
@@ -30,7 +29,7 @@ class Robot(BaseRobot):
|
|||||||
|
|
||||||
return status
|
return status
|
||||||
|
|
||||||
def toChengyu(self, msg) -> Boolean:
|
def toChengyu(self, msg) -> bool:
|
||||||
"""
|
"""
|
||||||
处理成语查询/接龙消息
|
处理成语查询/接龙消息
|
||||||
:param msg: 微信消息结构
|
:param msg: 微信消息结构
|
||||||
@@ -57,6 +56,11 @@ class Robot(BaseRobot):
|
|||||||
|
|
||||||
return status
|
return status
|
||||||
|
|
||||||
|
def toChitchat(self, msg):
|
||||||
|
"""闲聊,目前未实现
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
def processMsg(self, msg) -> None:
|
def processMsg(self, msg) -> None:
|
||||||
"""当接收到消息的时候,会调用本方法。如果不实现本方法,则打印原始消息。
|
"""当接收到消息的时候,会调用本方法。如果不实现本方法,则打印原始消息。
|
||||||
"""
|
"""
|
||||||
@@ -85,6 +89,16 @@ class Robot(BaseRobot):
|
|||||||
# 添加了好友,更新好友列表
|
# 添加了好友,更新好友列表
|
||||||
self.allContacts[msg.wxId] = nickName
|
self.allContacts[msg.wxId] = nickName
|
||||||
|
|
||||||
|
elif msg.type == 0x01: # 文本消息
|
||||||
|
# 让配置加载更灵活,自己可以更新配置。也可以利用定时任务更新。
|
||||||
|
if msg.self and msg.content == "^更新$":
|
||||||
|
self.config.reload()
|
||||||
|
self.LOG.info("已更新")
|
||||||
|
return
|
||||||
|
|
||||||
|
# 闲聊
|
||||||
|
self.toChitchat(msg)
|
||||||
|
|
||||||
|
|
||||||
def weather_report(robot: Robot):
|
def weather_report(robot: Robot):
|
||||||
"""模拟发送天气预报
|
"""模拟发送天气预报
|
||||||
|
|||||||
Reference in New Issue
Block a user