Skip to main content
NoneBotPluginLogo

NoneBotPluginText

nonebot-plugin-humanaticstore

✨ NoneBot 更易于管理的插件配置工具 ✨

license pypi python

一个更加用户友好的配置插件(工具集),目前只适合开发者使用,后续我会开发一个自动读取所有插件可配置项并自动导出 (通过官方读取的实现方式序列化导出)
该项目改装自 localstore

📖 行为介绍

此插件会根据你的 nb_cli 位置获得工作目录 WORKSPACE,随后使用WORKSPACE该字段 拼接出 config data cache 目录到工作目录下。

💿 安装

使用 nb-cli 安装 在 nonebot2 项目的根目录下打开命令行, 输入以下指令即可安装
nb plugin install nonebot-plugin-humanaticstore
使用包管理器安装 在 nonebot2 项目的插件目录下, 打开命令行, 根据你使用的包管理器, 输入相应的安装命令
pip
pip install nonebot-plugin-humanaticstore
pdm
pdm add nonebot-plugin-humanaticstore
poetry
poetry add nonebot-plugin-humanaticstore
conda
conda install nonebot-plugin-humanaticstore

打开 nonebot2 项目根目录下的 pyproject.toml 文件, 在 [tool.nonebot] 部分追加写入

plugins = ["nonebot_plugin_humanaticstore"]

⚙️ 这么做的目的

更易于多个nonebot在同一个计算机或设备下,使用多种不同的配置,甚至你可以使用localstore 插件和本插件同时工作,由于本插件遵循面对对象的工作原则,只有实例化对象并使用对象和其他数据交互才有可能出现bug。

🎉 使开发者如何使用

首先,导入本包 import nonebot_plugin_humanaticstore 运行中导入时会自动获取nb_cli运行目录, 然后你就可以使用 BASE_CACHE_DIR BASE_DATA_DIR BASE_CONFIG_DIR 字段直接获取数据目录的 绝对路径

编写配置可以直接使用python对象-字典; 通过导入 from nonebot_plugin_humanaticstore import ConfigManger 先获取配置管理对象, 对象内也拥有基础路径字段可提供使用,

对象内常用方法

  1. get_config/data/cache _ file/dir file 方法中需要 文件名参数 需要后缀

  2. model_dump 导出这个类中设置的所有字段,以python字典的形式导出

  3. save_config 参数: 文件名 不需要后缀,强制为yaml格式; data 形如 model_dump 的字典格式
    将 data 存入 文件中

  4. load_config_yaml 参数 文件名 不需要后缀 强制为 yaml ;
    读取文件中的配置 返回 python字典对象

  5. parse_obj 参数 字典
    用于更新对象中的字段
    标准用法放入解包的原始对象字典,再放入解包的新对象 ->
    {**config_manger.dict(), **new_data} 建议先处理重复字段

# 自定义更新逻辑的示例
for key, value in new_data.items():
    if hasattr(config, key):
        # 如果需要特殊处理重复字段,可以在这里实现
        # 例如,合并列表,选择保留原始值等
        pass
    else:
        # 如果字段不在原始配置中,直接设置新值
        setattr(config, key, value)

后话

如果各位有需要想实现的功能,可以咨询我
邮箱: 1624910218@qq.com 只是做成了链接样式点不了的

效果图

如果有效果图的话

Release files for nonebot-plugin-humanaticstore 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nonebot-plugin-humanaticstore 0.1.2
File Size Uploaded
nonebot_plugin_humanaticstore-0.1.2.tar.gz 18.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nonebot-plugin-humanaticstore 0.1.2
File Interpreter ABI Platform
nonebot_plugin_humanaticstore-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 39.4 kB

Release files / nonebot_plugin_humanaticstore-0.1.2.tar.gz

Download URL nonebot_plugin_humanaticstore-0.1.2.tar.gz
Size 18.8 kB
Tags Source
SHA-256 checksum
How to use checksums
b80b1d107bb83290eebe825d357c712cb767471ed0b85fb9d0f759af46201a1d
BLAKE2b-256 checksum
How to use checksums
bfbf9b04bd7178aa6ec1eaaf85e3b5ac2a7cb077edb837dbf3d512e49e8ffaff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.9.19

Release files / nonebot_plugin_humanaticstore-0.1.2-py3-none-any.whl

Download URL nonebot_plugin_humanaticstore-0.1.2-py3-none-any.whl
Size 20.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0a72ef57dac4f5d8d8964a5b3f075d5b61f097b14946b582f1f484eef9612528
BLAKE2b-256 checksum
How to use checksums
e323b2208a5ffcdbb5b13ae68a39ed15e630411ef06133bf2aa6dad634bcbc81
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.9.19

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page