Skip to main content

A Lighter LocalStore For NoneBot2

Project description

NoneBotPluginLogo

NoneBotPluginText

nonebit-plugin-litestore

✨ 轻量化 NoneBot 本地数据存储插件 ✨

license pypi python

[!CAUTION]
警告,本插件不是NoneBot2规范,商店插件请统一使用 LocalStore

[!IMPORTANT] 感谢项目 NoneBot Plugin LocalStore

本项目在其基础上对插件进行更改。

📖 介绍

为了更加方便管理插件数据,开箱即用

本插件提供了与 NoneBot Plugin LocalStore 不同的功能:

  • 无需配置,开箱即用
  • 自动创建插件数据存储路径
  • 创建更加清晰的插件数据路径

🔧 使用方式

加载插件后使用 require 声明插件依赖,直接使用本插件提供的PluginStore包装类即可。

from pathlib import Path
from nonebot import require

require("nonebot_plugin_litestore")

from nonebot_plugin_litestore 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项目,在NoneBot完成初始化后,调用本插件相关函数时,会自动在.env文件所处目录中创建路径。

比如:

项目目录:Awesome(包含.env文件

则对应的路径为:./Awesome/__plugin_data__


假设你有一个叫 setu 的插件调用了 Store.data.get_dir()
则对应创建路径为: ./Awesome/__plugin_data__/setu/data


同理,当你分别调用本插件的不同函数时,会分别创建以下路径:

./Awesome/__plugin_data__/setu/data
./Awesome/__plugin_data__/setu/cache
./Awesome/__plugin_data__/setu/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.1.tar.gz (5.0 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.1-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for nonebot_plugin_litestore-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b47859c706b424a3618ae1c52df648d8b859c14e9219ca4c6dae1e87e41e6076
MD5 d40e4615658d2c068a9aa2c9a3a900c8
BLAKE2b-256 7ab4bb8f35d4413d027a7d5964a0d0f2879f117400bc9a9e9009ce8ea837e287

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for nonebot_plugin_litestore-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 defe5a4f741ad2197a3609f9504b9afad9224f710551a26eae1c09bd4c806549
MD5 1a77ae867567cafbb65595370ac7955d
BLAKE2b-256 645230a59d5a8d1a55eb45fa162e6690ad070f5c9618a5a3bc7969e6fb2a0a0c

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