A Lighter LocalStore For NoneBot2
Project description
[!IMPORTANT] 感谢 NoneBot Plugin LocalStore(Worked by yanyongyu)!
本项目在其原有代码的基础上、基于个人的需求,对插件进行更改。
📖 介绍
为了更加方便管理插件数据,开箱即用,
本插件提供了与 NoneBot Plugin LocalStore 不同的功能:
- 无需配置,开箱即用
- 自动在NoneBot2规范机器人项目内创建插件数据主文件夹
- 更加清晰的插件数据路径创建
🔧 使用方式
加载插件后使用 require 声明插件依赖,直接使用 nonebot_plugin_litestore 插件提供的类即可。
from pathlib import Path
from nonebot import require
require("nonebot_plugin_litestore")
from nonebot_plugin_localstore import PluginStore as Store
plugin_cache_dir: Path = Store.Cache.get_dir()
plugin_cache_file: Path = Store.Cache.get_file("filename")
plugin_config_dir: Path = Store.Config.get_dir()
plugin_config_file: Path = Store.Config.get_file("filename")
plugin_data_dir: Path = Store.Data.get_dir()
plugin_data_file: Path = Store.Data.get_file("filename")
💡 存储路径
对于一个规范的NoneBot2项目,本插件会在您的插件调用函数时,自动在项目目录中创建插件数据路径。
比如:
项目目录:YourBot(包含.env文件)
则对应的路径为:./YourBot/__plugin_data__
假设你有一个叫 example_plugin 的插件调用了 Store.Data.get_dir(),则对应创建路径为:./YourBot/__plugin_data__/example_plugin/data
同理,本插件一共会创建以下路径:
./YourBot/__plugin_data__/example_plugin/data
./YourBot/__plugin_data__/example_plugin/cache
./YourBot/__plugin_data__/example_plugin/config
💿 安装
使用 nb-cli 安装
在 nonebot2 项目的根目录下打开命令行, 输入以下指令即可安装nb plugin install nonebit-plugin-litestore
使用包管理器安装
在 nonebot2 项目的插件目录下, 打开命令行, 根据你使用的包管理器, 输入相应的安装命令pip
pip install nonebit-plugin-litestore
pdm
pdm add nonebit-plugin-litestore
poetry
poetry add nonebit-plugin-litestore
conda
conda install nonebit-plugin-litestore
打开 nonebot2 项目根目录下的 pyproject.toml 文件, 在 [tool.nonebot] 部分追加写入
plugins = ["nonebit_plugin_litestore"]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nonebot_plugin_litestore-0.1.0.tar.gz.
File metadata
- Download URL: nonebot_plugin_litestore-0.1.0.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a004175a395078740fe3e54ca7ccb12b819efa548c73125d3dd233fe2d48ffb1
|
|
| MD5 |
f37830ed448c9b3179315e222d5692e8
|
|
| BLAKE2b-256 |
fce452693f6fb4a4221e8a2737cee1dbcfcef32cbf2b9b840cdc2e8fe6e08229
|
File details
Details for the file nonebot_plugin_litestore-0.1.0-py3-none-any.whl.
File metadata
- Download URL: nonebot_plugin_litestore-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f0cf6401b4af866c8383985704be27e54eec574d2f4207e6dfa29d2b96f8327e
|
|
| MD5 |
962f110ef3fb37a776a7ab73e4da92f0
|
|
| BLAKE2b-256 |
bb1333a15a117f1618e4e6246d122a81bf31bc544bf1e1f84518a9ca1936220e
|