7
main.py
7
main.py
@@ -19,7 +19,7 @@ def weather_report(robot: Robot) -> None:
|
|||||||
|
|
||||||
for r in receivers:
|
for r in receivers:
|
||||||
robot.sendTextMsg(report, r)
|
robot.sendTextMsg(report, r)
|
||||||
#robot.sendTextMsg(report, r, "nofity@all") # 发送消息并@所有人
|
# robot.sendTextMsg(report, r, "nofity@all") # 发送消息并@所有人
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
@@ -39,15 +39,12 @@ def main():
|
|||||||
# 接收消息
|
# 接收消息
|
||||||
robot.enableRecvMsg()
|
robot.enableRecvMsg()
|
||||||
|
|
||||||
|
|
||||||
# 每天7点发送天气预报
|
# 每天7点发送天气预报
|
||||||
robot.onEveryTime("22:30", weather_report, robot=robot)
|
robot.onEveryTime("00:30", weather_report, robot=robot)
|
||||||
|
|
||||||
# 让机器人一直跑
|
# 让机器人一直跑
|
||||||
robot.keepRunningAndBlockProcess()
|
robot.keepRunningAndBlockProcess()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|||||||
9
robot.py
9
robot.py
@@ -12,7 +12,6 @@ from func_chengyu import cy
|
|||||||
from job_mgmt import Job
|
from job_mgmt import Job
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Robot(Job):
|
class Robot(Job):
|
||||||
"""个性化自己的机器人
|
"""个性化自己的机器人
|
||||||
"""
|
"""
|
||||||
@@ -24,7 +23,6 @@ class Robot(Job):
|
|||||||
self.wxid = self.wcf.get_self_wxid()
|
self.wxid = self.wcf.get_self_wxid()
|
||||||
#self.allContacts = self.getAllContacts()
|
#self.allContacts = self.getAllContacts()
|
||||||
|
|
||||||
|
|
||||||
def toAt(self, msg: Wcf.WxMsg) -> bool:
|
def toAt(self, msg: Wcf.WxMsg) -> bool:
|
||||||
"""
|
"""
|
||||||
处理被 @ 消息,现在只固定回复: "你@我干嘛?"
|
处理被 @ 消息,现在只固定回复: "你@我干嘛?"
|
||||||
@@ -80,7 +78,6 @@ class Robot(Job):
|
|||||||
self.sendTextMsg(content, receivers, msg.sender)
|
self.sendTextMsg(content, receivers, msg.sender)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
# 群聊消息
|
# 群聊消息
|
||||||
if msg.from_group():
|
if msg.from_group():
|
||||||
# 如果在群里被 @,回复发信人:“收到你的消息了!” 并 @他
|
# 如果在群里被 @,回复发信人:“收到你的消息了!” 并 @他
|
||||||
@@ -147,8 +144,10 @@ class Robot(Job):
|
|||||||
获取联系人(包括好友、公众号、服务号、群成员……)
|
获取联系人(包括好友、公众号、服务号、群成员……)
|
||||||
格式: {"wxid": "NickName"}
|
格式: {"wxid": "NickName"}
|
||||||
"""
|
"""
|
||||||
contacts = self.wcf.query_sql("MicroMsg.db", "SELECT UserName, NickName FROM Contact;")
|
contacts = self.wcf.query_sql(
|
||||||
return {contact["UserName"]: contact["NickName"] for contact in contacts}
|
"MicroMsg.db", "SELECT UserName, NickName FROM Contact;")
|
||||||
|
return {contact["UserName"]: contact["NickName"]
|
||||||
|
for contact in contacts}
|
||||||
|
|
||||||
def keepRunningAndBlockProcess(self) -> None:
|
def keepRunningAndBlockProcess(self) -> None:
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user