Skip to main content

watch and (re)load/remove nonebot plugins from a directory

Project description

nonebot-plugins-watch

Python3.7 package codecov PyPI version

hot plug and remove nonebot plugins

Installation

pip install nbplugins-watch

To validate installation

python -c "import nbplugins_watch; print(nbplugins_watch.__version__)"
0.0.6

Usage

Make a directory somewhere and place an empty __init__.py and a plugin file in it.

Monitor the directory in your nonebot runner file, e.g. in my_nonebot.py:

import nonebot
from nbplugins_watch import nbplugins_watch

nonebot.load_builtin_plugins()  # optional
nonebot.load_builtin_plugins("mature-plugin-dir")

plugin_dir_path = r"path_to_plugin_dir"  # absolute or relative path

nbplugins_watch(plugin_dir_path)
# turn debug on to see what's going on
# nbplugins_watch(plugin_dir_path, debug=True)

nonebot.run()

Create a file, say fancy_plugin.py if not already there, in the directory above. Edit and test and/or remove the file fancy_plugin.py to your heart's content.

Note: if a plugin file contains syntax errors (as opposed to logic errors), you'll have to restart nonebot, in other words, nbplugins_watch will cease to work after an uncaught error. nbplugins_watch can recover from syntax errors, in other words, even when a plugin file contains syntax errors (as opposed to logic errors), it just still works.

Acknowledgments

  • Thanks to everyone whose code was used

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

nbplugins-watch-0.0.6.tar.gz (4.7 kB view hashes)

Uploaded Source

Built Distribution

nbplugins_watch-0.0.6-py3-none-any.whl (4.9 kB view hashes)

Uploaded Python 3

Supported by

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