1 Star 0 Fork 0

hujunwei/WeChatRobot

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
configuration.py 1.21 KB
一键复制 编辑 原始数据 按行查看 历史
yudong 提交于 2024-02-19 22:23 . 适配智谱
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import logging.config
import os
import shutil
import yaml
class Config(object):
def __init__(self) -> None:
self.reload()
def _load_config(self) -> dict:
pwd = os.path.dirname(os.path.abspath(__file__))
try:
with open(f"{pwd}/config.yaml", "rb") as fp:
yconfig = yaml.safe_load(fp)
except FileNotFoundError:
shutil.copyfile(f"{pwd}/config.yaml.template", f"{pwd}/config.yaml")
with open(f"{pwd}/config.yaml", "rb") as fp:
yconfig = yaml.safe_load(fp)
return yconfig
def reload(self) -> None:
yconfig = self._load_config()
logging.config.dictConfig(yconfig["logging"])
self.GROUPS = yconfig["groups"]["enable"]
self.NEWS = yconfig["news"]["receivers"]
self.REPORT_REMINDERS = yconfig["report_reminder"]["receivers"]
self.CHATGPT = yconfig.get("chatgpt", {})
self.TIGERBOT = yconfig.get("tigerbot", {})
self.XINGHUO_WEB = yconfig.get("xinghuo_web", {})
self.CHATGLM = yconfig.get("chatglm", {})
self.BardAssistant = yconfig.get("bard", {})
self.ZhiPu = yconfig.get("zhipu", {})
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/umeitime/WeChatRobot.git
git@gitee.com:umeitime/WeChatRobot.git
umeitime
WeChatRobot
WeChatRobot
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385