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

💿 安装

使用包管理器安装 在 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.2.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.2-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for nonebot_plugin_litestore-0.1.2.tar.gz
Algorithm Hash digest
SHA256 c542b7dfa35209645f82d2174efba345426d4e0c776ace339e15e718d5521ae4
MD5 055aa61d1ea14545bb3294915076fbf1
BLAKE2b-256 b09da9d9328cf8b2a7ff3bb7b54882dd63ab73e23f8dba6c373a3cac339cd037

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for nonebot_plugin_litestore-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a2b9eb4031dcce25439a69b283b1e955999f719c229ba014ff82bc9c61a2b5e2
MD5 1f90493b5b7a8bf23fffc67f0bb630ab
BLAKE2b-256 eefc43b4ba9be8630b4dd1493f316dc0cfd37b5f3ace2ca5c4577143ec7ec87b

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