Impl news report
This commit is contained in:
@@ -41,6 +41,9 @@ logging:
|
|||||||
groups:
|
groups:
|
||||||
enable: [] # 允许响应的群 roomId,大概长这样:2xxxxxxxxx3@chatroom
|
enable: [] # 允许响应的群 roomId,大概长这样:2xxxxxxxxx3@chatroom
|
||||||
|
|
||||||
|
news:
|
||||||
|
receivers: [] # 定时新闻接收人(roomid 或者 wxid)
|
||||||
|
|
||||||
# 如果要使用 ChatGPT,取消下面的注释并填写相关内容
|
# 如果要使用 ChatGPT,取消下面的注释并填写相关内容
|
||||||
# chatgpt:
|
# chatgpt:
|
||||||
# key: 填写你 ChatGPT 的 key
|
# key: 填写你 ChatGPT 的 key
|
||||||
|
|||||||
@@ -30,3 +30,4 @@ class Config(object):
|
|||||||
self.GROUPS = yconfig["groups"]["enable"]
|
self.GROUPS = yconfig["groups"]["enable"]
|
||||||
self.CHATGPT = yconfig.get("chatgpt")
|
self.CHATGPT = yconfig.get("chatgpt")
|
||||||
self.HTTP = yconfig.get("http")
|
self.HTTP = yconfig.get("http")
|
||||||
|
self.NEWS = yconfig["news"]["receivers"]
|
||||||
|
|||||||
5
main.py
5
main.py
@@ -50,9 +50,12 @@ def main():
|
|||||||
# 接收消息
|
# 接收消息
|
||||||
robot.enableRecvMsg()
|
robot.enableRecvMsg()
|
||||||
|
|
||||||
# 每天7点发送天气预报
|
# 每天 7 点发送天气预报
|
||||||
robot.onEveryTime("07:00", weather_report, robot=robot)
|
robot.onEveryTime("07:00", weather_report, robot=robot)
|
||||||
|
|
||||||
|
# 每天 7:30 发送新闻
|
||||||
|
robot.onEveryTime("07:30", robot.newsReport)
|
||||||
|
|
||||||
# 让机器人一直跑
|
# 让机器人一直跑
|
||||||
robot.keepRunningAndBlockProcess()
|
robot.keepRunningAndBlockProcess()
|
||||||
|
|
||||||
|
|||||||
10
robot.py
10
robot.py
@@ -11,6 +11,7 @@ from configuration import Config
|
|||||||
from func_chatgpt import ChatGPT
|
from func_chatgpt import ChatGPT
|
||||||
from func_chengyu import cy
|
from func_chengyu import cy
|
||||||
from func_http import Http
|
from func_http import Http
|
||||||
|
from func_news import News
|
||||||
from job_mgmt import Job
|
from job_mgmt import Job
|
||||||
|
|
||||||
|
|
||||||
@@ -200,3 +201,12 @@ class Robot(Job):
|
|||||||
description=f"Github: <a href='{home}'>WeChatFerry</a>",)
|
description=f"Github: <a href='{home}'>WeChatFerry</a>",)
|
||||||
Http.start(http, c["host"], c["port"])
|
Http.start(http, c["host"], c["port"])
|
||||||
self.LOG.info(f"HTTP listening on http://{c['host']}:{c['port']}")
|
self.LOG.info(f"HTTP listening on http://{c['host']}:{c['port']}")
|
||||||
|
|
||||||
|
def newsReport(self) -> None:
|
||||||
|
receivers = self.config.NEWS
|
||||||
|
if not receivers:
|
||||||
|
return
|
||||||
|
|
||||||
|
news = News().get_important_news()
|
||||||
|
for r in receivers:
|
||||||
|
self.sendTextMsg(news, r)
|
||||||
|
|||||||
Reference in New Issue
Block a user