855 协议版本-调整完毕内容
This commit is contained in:
70
main.py
70
main.py
@@ -1,58 +1,46 @@
|
||||
#! /usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
import logging
|
||||
import threading
|
||||
from argparse import ArgumentParser
|
||||
from configuration import Config
|
||||
from constants import ChatType
|
||||
from gewechat.api.start_server import start_fastapi_server
|
||||
from gewechat.client import gewe_client
|
||||
from robot import Robot
|
||||
|
||||
# 配置日志
|
||||
logger = logging.getLogger(__name__)
|
||||
from loguru import logger
|
||||
|
||||
# INFO 日志(包含 INFO、DEBUG,但不包含 WARNING、ERROR)
|
||||
logger.add(
|
||||
f"wx_info.log",
|
||||
level="INFO",
|
||||
filter=lambda record: record["level"].name in ["INFO", "DEBUG"],
|
||||
rotation="10 MB",
|
||||
retention="7 days",
|
||||
encoding="utf-8"
|
||||
)
|
||||
|
||||
# ERROR 日志(仅 ERROR 及以上)
|
||||
logger.add(
|
||||
f"wx_error.log",
|
||||
level="ERROR",
|
||||
rotation="10 MB",
|
||||
retention="7 days",
|
||||
encoding="utf-8"
|
||||
)
|
||||
|
||||
|
||||
def main(chat_type: int):
|
||||
config = Config()
|
||||
|
||||
send_msg_wxid = "filehelper" # 要发送消息的好友昵称
|
||||
|
||||
start_fastapi_server(host="0.0.0.0", port=8999)
|
||||
# 创建机器人实例
|
||||
robot = Robot(config)
|
||||
robot.LOG.info(f"WeChatRobot gewechat 成功启动···")
|
||||
robot.LOG.info(f"WeChatRobot 正在启动...")
|
||||
|
||||
# # 注册Robot实例到callback模块
|
||||
from gewechat.api.callback import register_robot
|
||||
register_robot(gewe_client.app_id, robot)
|
||||
|
||||
# 机器人启动发送测试消息
|
||||
gewe_client.client.post_text(gewe_client.app_id, send_msg_wxid, "client 启动成功!")
|
||||
#
|
||||
# # 每天 8:30 发送新闻
|
||||
# robot.onEveryTime("08:30", robot.news_baidu_report_auto)
|
||||
#
|
||||
# # epic
|
||||
# robot.onEveryTime("10:30", robot.send_epic_free_games)
|
||||
#
|
||||
# # message report 1:数据自动从redis 转到sqllite
|
||||
# robot.onEveryTime("02:30", robot.message_count_to_db)
|
||||
# # 从db中提取并发送给相关群
|
||||
# robot.onEveryTime("09:30", robot.generate_and_send_ranking)
|
||||
#
|
||||
# # sehuatang
|
||||
# robot.onEveryTime("15:30", robot.generate_sehuatang_pdf)
|
||||
#
|
||||
# # 秀人网每天自动下载帖子
|
||||
# robot.onEveryTime("01:30", robot.xiu_ren_download_task)
|
||||
#
|
||||
# # 秀人网每天自动发pdf
|
||||
# robot.onEveryTime("17:30", robot.xiu_ren_pdf_send)
|
||||
# time.sleep(5)
|
||||
# # 启动之后,填入callback
|
||||
# gewe_client.client_set_callback()
|
||||
# # 返回启动的端口,以便调用者知道实际使用的端口
|
||||
# 初始化并启动wechat_ipad客户端
|
||||
if robot.init_wechat_ipad():
|
||||
robot.LOG.info("wechat_ipad客户端启动成功")
|
||||
else:
|
||||
robot.LOG.error("wechat_ipad客户端启动失败")
|
||||
|
||||
# 启动Dashboard服务器
|
||||
dashboard_server = None
|
||||
try:
|
||||
@@ -74,5 +62,5 @@ def main(chat_type: int):
|
||||
if __name__ == "__main__":
|
||||
parser = ArgumentParser()
|
||||
parser.add_argument('-c', type=int, default=0, help=f'选择模型参数序号: {ChatType.help_hint()}')
|
||||
args = parser.parse_args().c
|
||||
main(args)
|
||||
args = parser.parse_args()
|
||||
main(args.c)
|
||||
|
||||
Reference in New Issue
Block a user