- Python 3.8+
pip install -r requirements.txt # 安装依赖的pip包
根目录下的config.yaml
为基础插件配置文件,可在此配置频道机器人的基础信息
默认插件目录为plugins
,可在plugins
目录下创建一个插件文件或者插件文件夹,例如hello_plugin.py
,在hello_plugin.py
中编写插件代码,例如:
# plugins/hello_plugin.py
from botpy.ext.command_util import Commands
from botpy.message import Message
from botpy import BotAPI
@Commands("你好", "hello")
async def hello(api: BotAPI, message: Message, params=None):
await api.post_message(channel_id=message.channel_id, content='Hello,World!', msg_id=message.id)
return True
@Commands("晚安")
async def good_night(api: BotAPI, message: Message, params=None):
await message.reply(content=params)
return True
请根据官方QQ频道机器人SDK文档编写插件代码
python main.py