Skip to content

nonebot/plugin-localstore

Repository files navigation

nonebot

NoneBot Plugin LocalStore

✨ NoneBot 本地数据存储插件 ✨

license pypi python

使用方式

加载插件后使用 require 声明插件依赖,直接使用 localstore 插件提供的函数即可。

from pathlib import Path
from nonebot import require

require("nonebot_plugin_localstore")

import nonebot_plugin_localstore as store

plugin_cache_dir: Path = store.get_plugin_cache_dir()
plugin_cache_file: Path = store.get_plugin_cache_file("filename")
plugin_config_dir: Path = store.get_plugin_config_dir()
plugin_config_file: Path = store.get_plugin_config_file("filename")
plugin_data_dir: Path = store.get_plugin_data_dir()
plugin_data_file: Path = store.get_plugin_data_file("filename")

存储路径

在项目安装插件后,可以使用 nb-cli 查看具体的存储路径:

nb localstore

参考路径如下:

cache path

  • macOS: ~/Library/Caches/<AppName>
  • Unix: ~/.cache/<AppName> (XDG default)
  • Windows: C:\Users\<username>\AppData\Local\<AppName>\Cache

data path

  • macOS: ~/Library/Application Support/<AppName>
  • Unix: ~/.local/share/<AppName> or in $XDG_DATA_HOME, if defined
  • Win XP (not roaming): C:\Documents and Settings\<username>\Application Data\<AppName>
  • Win 7 (not roaming): C:\Users\<username>\AppData\Local\<AppName>

config path

  • macOS: same as user_data_dir
  • Unix: ~/.config/<AppName>
  • Win XP (roaming): C:\Documents and Settings\<username>\Local Settings\Application Data\<AppName>
  • Win 7 (roaming): C:\Users\<username>\AppData\Roaming\<AppName>