Skip to main content

A Lighter LocalStore For NoneBot2

Project description

NoneBotPluginLogo

NoneBotPluginText

nonebit-plugin-litestore

✨ 新一代的轻量化 NoneBot 本地数据存储插件 ✨

license pypi python

[!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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nonebot_plugin_litestore-0.1.0.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nonebot_plugin_litestore-0.1.0-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file nonebot_plugin_litestore-0.1.0.tar.gz.

File metadata

File hashes

Hashes for nonebot_plugin_litestore-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a004175a395078740fe3e54ca7ccb12b819efa548c73125d3dd233fe2d48ffb1
MD5 f37830ed448c9b3179315e222d5692e8
BLAKE2b-256 fce452693f6fb4a4221e8a2737cee1dbcfcef32cbf2b9b840cdc2e8fe6e08229

See more details on using hashes here.

File details

Details for the file nonebot_plugin_litestore-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for nonebot_plugin_litestore-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f0cf6401b4af866c8383985704be27e54eec574d2f4207e6dfa29d2b96f8327e
MD5 962f110ef3fb37a776a7ab73e4da92f0
BLAKE2b-256 bb1333a15a117f1618e4e6246d122a81bf31bc544bf1e1f84518a9ca1936220e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page