Skip to content

Commit

Permalink
Merge pull request #726 from RockChinQ/feat/qq-botpy-cache
Browse files Browse the repository at this point in the history
Feat: qq-botpy 适配器对 member 和 group 的 openid 进行静态缓存
  • Loading branch information
RockChinQ authored Mar 14, 2024
2 parents be06150 + ed3c0d9 commit 2028d85
Show file tree
Hide file tree
Showing 8 changed files with 256 additions and 116 deletions.
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ async def main_entry():
sys.exit(0)

# 检查配置文件

from pkg.core.bootutils import files

generated_files = await files.generate_files()
Expand Down
4 changes: 4 additions & 0 deletions pkg/config/impls/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,9 @@ async def load(self) -> dict:
return cfg

async def save(self, cfg: dict):
with open(self.config_file_name, 'w', encoding='utf-8') as f:
json.dump(cfg, f, indent=4, ensure_ascii=False)

def save_sync(self, cfg: dict):
with open(self.config_file_name, 'w', encoding='utf-8') as f:
json.dump(cfg, f, indent=4, ensure_ascii=False)
3 changes: 3 additions & 0 deletions pkg/config/impls/pymodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,6 @@ async def load(self) -> dict:

async def save(self, data: dict):
logging.warning('Python模块配置文件不支持保存')

def save_sync(self, data: dict):
logging.warning('Python模块配置文件不支持保存')
3 changes: 3 additions & 0 deletions pkg/config/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ async def load_config(self):
async def dump_config(self):
await self.file.save(self.data)

def dump_config_sync(self):
self.file.save_sync(self.data)


async def load_python_module_config(config_name: str, template_name: str) -> ConfigManager:
"""加载Python模块配置文件"""
Expand Down
4 changes: 4 additions & 0 deletions pkg/config/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@ async def load(self) -> dict:
@abc.abstractmethod
async def save(self, data: dict):
pass

@abc.abstractmethod
def save_sync(self, data: dict):
pass
1 change: 1 addition & 0 deletions pkg/core/bootutils/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
required_paths = [
"temp",
"data",
"data/metadata",
"data/prompts",
"data/scenario",
"data/logs",
Expand Down
Loading

0 comments on commit 2028d85

Please sign in to comment.