Plugin system based on khl.py
Project description
KHLDaemon
安装
使用命令 pip install khldaemon
来安装
使用
使用命令 python -m khldaemon init
来初始化机器人
将会生成 plugin
config
文件夹,以及 config.yml
配置文件
修改配置文件,填上你的开黑啦机器人的 token
然后使用命令 python -m khldaemon start
启动机器人
样例插件
from khl import Message
from khl.plugin.plugin_interface import PluginInterface
# plugin meta
PLUGIN_METADATA = {
'id': 'test_plugin',
'version': '1.0.0',
'name': 'Test Plugin',
'description': 'A test plugin',
'author': 'DancingSnow',
'link': 'https://github.com/DancingSnow0517/khl.py/tree/plugin'
}
# run when bot start
def on_load(interface: PluginInterface):
interface.logger.info('plugin loaded')
bot = interface.bot
@bot.command(name='test')
async def test(msg: Message):
await msg.reply('test')
# run when bot stop
def on_unload(interface: PluginInterface):
interface.logger.info('plugin unloaded')
# run when a message is received
async def on_message(msg: Message):
print(msg.content)
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
khldaemon-0.0.6.tar.gz
(11.6 kB
view hashes)
Built Distribution
khldaemon-0.0.6-py3-none-any.whl
(13.9 kB
view hashes)
Close
Hashes for khldaemon-0.0.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fe4cc8c8c8e6a25d2fff9e9860e5327f29d99365034a82665b3aed2b1f0e12a0 |
|
MD5 | 24e828361ce0a6a14a1f161aa38b3ceb |
|
BLAKE2b-256 | 90fbdfff6191989d3ec68ae3ebb593deab2fccb6ed16fe443fb4f2d5f6e9eed1 |