server启动之后,填入callback
This commit is contained in:
@@ -5,7 +5,7 @@ import uvicorn
|
|||||||
from fastapi import FastAPI
|
from fastapi import FastAPI
|
||||||
|
|
||||||
from gewechat.api.callback import router as callback_router
|
from gewechat.api.callback import router as callback_router
|
||||||
from gewechat.client import gewe_client
|
from gewechat.client import gewe_client, Client
|
||||||
|
|
||||||
# 配置日志
|
# 配置日志
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|||||||
@@ -54,4 +54,4 @@ class Client:
|
|||||||
logger.error("set_callback 多次重试后仍失败,请检查server状态。")
|
logger.error("set_callback 多次重试后仍失败,请检查server状态。")
|
||||||
|
|
||||||
# 项目全局唯一 client 实例
|
# 项目全局唯一 client 实例
|
||||||
gewe_client = Client().client
|
gewe_client = Client()
|
||||||
2
main.py
2
main.py
@@ -31,7 +31,7 @@ def main(chat_type: int):
|
|||||||
register_robot(gewe_client.app_id, robot)
|
register_robot(gewe_client.app_id, robot)
|
||||||
|
|
||||||
# 机器人启动发送测试消息
|
# 机器人启动发送测试消息
|
||||||
gewe_client.post_text(gewe_client.app_id, send_msg_wxid, "client 启动成功!")
|
gewe_client.client.post_text(gewe_client.app_id, send_msg_wxid, "client 启动成功!")
|
||||||
#
|
#
|
||||||
# # 每天 8:30 发送新闻
|
# # 每天 8:30 发送新闻
|
||||||
# robot.onEveryTime("08:30", robot.news_baidu_report_auto)
|
# robot.onEveryTime("08:30", robot.news_baidu_report_auto)
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class MessageUtil:
|
|||||||
# 修改 MessageUtil 类的初始化方法,接受联系人管理器而不是联系人字典
|
# 修改 MessageUtil 类的初始化方法,接受联系人管理器而不是联系人字典
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.app_id = gewe_client.app_id
|
self.app_id = gewe_client.app_id
|
||||||
self.client = gewe_client
|
self.client = gewe_client.client
|
||||||
self.contact_manager = ContactManager.get_instance()
|
self.contact_manager = ContactManager.get_instance()
|
||||||
self.LOG = logging.getLogger("MessageUtil")
|
self.LOG = logging.getLogger("MessageUtil")
|
||||||
|
|
||||||
|
|||||||
2
robot.py
2
robot.py
@@ -39,7 +39,7 @@ class Robot(Job):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, config: Config) -> None:
|
def __init__(self, config: Config) -> None:
|
||||||
self.client = gewe_client
|
self.client = gewe_client.client
|
||||||
self.config = config
|
self.config = config
|
||||||
self.LOG = logging.getLogger("Robot")
|
self.LOG = logging.getLogger("Robot")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user