nonebot / aiocqhttp

A Python SDK with async I/O for CQHTTP (OneBot).
https://aiocqhttp.nonebot.dev
MIT License
280 stars 39 forks source link

请问如何主动发送消息? #42

Closed jiangjiangflies closed 4 years ago

jiangjiangflies commented 4 years ago

以前的老项目cqhttp可以这样用:

bot = CQHttp(api_root='http://127.0.0.1:5700') 然后直接 bot.send_group_msg(group_id=xxx,message="hi") 就可以发送消息了。

但现在提示 RuntimeWarning: coroutine 'CQHttp.call_action' was never awaited 小白一个,请大老指教!

yanyongyu commented 4 years ago

使用

await bot.send_group_msg(group_id=xxx,message="hi")

异步方法需要在async函数内执行,或者使用同步方法

bot.sync.send_group_msg(group_id=xxx,message="hi")