mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-10-30 04:15:45 +08:00
1.5 KiB
1.5 KiB
head, title, icon, order, author, date, category, index
| head | title | icon | order | author | date | category | index | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
API 参考 | code | 5 | RockChinQ | 2024-03-22 |
|
false |
暂时未设计独立 API 层,本页面讲解了一些常用的功能的调用方法。 以下提到的对象及访问方式均在前文有所提及,请先阅读插件开发教程。
消息处理
回复消息
切入方法:pkg.platform.adapter.MessageSourceAdapter.reply_message
由于程序中可能同时运行多个 消息平台适配器(MessageSourceAdapter),故在query: pkg.core.entities.Query 对象中包含了 adapter 对象,保存了此次请求对应的适配器,通过这个对象可以调用适配器的回复消息方法。
需要传入:
message_source本次消息的来源事件,可以从query对象中获取。message回复的消息内容,YiriMirai 的 MessageChain对象quote_origin: bool是否引用原消息
发送主动消息
不推荐。
切入方法:pkg.platform.adapter.MessageSourceAdapter.send_message
需要自己找到一个适配器对象,然后调用此方法。
ap: pkg.core.app.Application的platform_mgr: pkg.platform.manager.PlatformManager对象中保存了所有适配器对象:adapters,从中取出一个即可调用send_message方法。
需要传入:
target_type目标类型,可以是group或persontarget_id目标idmessage消息内容,YiriMirai 的 MessageChain对象