OneBotBot
一个 OneBot 协议的 Bot。
Bot 的终止
Bot的运行状态 (isActive) 可能会因为一些原因被更改:
手动终止 (使用 cancel)。
父级Job或被关联的Job被终止 (可能来自 BotManager、Application等)。
会话连接失败且重试次数到达上限。比如 ws 的连接会话意外被中断, 且在重新连接的过程中始终失败并达到了重试次数上限,此时会话中的任务会被视为因异常结束, 并连带 OneBotBot 的任务一同终结。
日志
OneBotBot 的内部会输出三种日志:
love.forte.simbot.component.onebot.v11.core.bot.OneBotBot.$uniqueId
bot的基本日志,例如连接信息、接收到的原始事件等debug日志。
Author
ForteScarlet
Properties
OneBotBot 用于请求API的 HttpClient。
当前Bot的配置类。
联系人相关操作,即好友相关的关系操作。
与群聊相关的操作
始终为 null
。 OB11协议主要为普通群聊设计。
Bot的名称,来自 GetLoginInfoApi API. name 是一个缓存值,不会实时查询或实时刷新。
由 OneBotBot 衍生出的 actor 使用的 CoroutineContext。 源自 coroutineContext, 但是不包含 Job。
Bot自身的 ID,来自事件或 GetLoginInfoApi API.
Inherited properties
Functions
获取 Cookies
获取 QQ 相关接口凭证
获取 CSRF Token
根据 messageId 使用 GetMsgApi 查询消息内容, 并得到对应的 OneBotMessageContent。
根据 id 使用 GetMsgApi 查询消息内容, 并得到对应的 OneBotMessageContent。
根据消息引用的id使用 GetMsgApi 查询消息内容, 并得到对应的 OneBotMessageContent。
直接推送一个外部的原始事件字符串,并在异步任务中处理事件。
通过 GetLoginInfoApi 查询当前Bot的信息, 并刷新 userId 和 name 的缓存值。
启动Bot。 启动过程中会通过 GetLoginInfoApi 初始化当前账户信息, 并同时初始化 userId。
Inherited functions
使用当前 OneBotApiExecutable 执行 api 并得到原始的 HttpResponse 结果。
使用当前 OneBotApiExecutable 执行 api 并得到 T 结果。
使用当前 OneBotApiExecutable 执行 api 并得到原始的 String 结果。
使用当前 OneBotApiExecutable 执行 api 并得到 OneBotApiResult 结果。
在 OneBotApiExecutableScope 的作用域下执行 action。