Package top.mrxiaom.overflow
Class BotBuilder
-
- All Implemented Interfaces:
public final class BotBuilderOnebot 连接向导
-
-
Method Summary
Modifier and Type Method Description final BotBuildertoken(String token)设置用于连接时鉴权的 token将 token 设为空则不进行鉴权 final BotBuilderretryTimes(Integer retryTimes)设置尝试重连次数,设为 0 时禁用自动重连仅主动 WebSocket 可自动重连 final BotBuilderretryWaitMills(Long retryWaitMills)设置重连等待间隔时间仅主动 WebSocket 可自动重连 final BotBuilderretryRestMills(Long retryRestMills)设置重连休息时间仅主动 WebSocket 可自动重连重连次数耗尽后,会进入休息状态,休息结束后重置重连次数,再次尝试重连设为 -1 禁用此功能 final BotBuilderheartbeatCheckSeconds(Integer heartbeatCheckSeconds)设置 WebSocket 心跳检查时间设为 0 关闭心跳检查 final BotBuildernoPrintInfo()禁止打印连接时额外状态信息如 Overflow 版本、连接地址、Onebot 协议端版本等如果需要禁止打印连接成功与失败情况的日志,请使用 overrideLogger 覆写日志记录器 final BotBuildernoPlatform()禁止 Overflow 调用 Tencent 的网络接口调用这些网络接口需要通过 get_credentials获取凭证,再使用凭证访问接口。部分 Onebot 实现不支持获取账号凭证,甚至于并不从QQ实现(如 Discord、Kook 等),连接这些实例前,需要禁用网络接口调用final BotBuilderuseCQCode()发送消息时使用 CQ 码即使不开启该选项,也可使用 CQ 码接收消息 final BotBuilderuseGroupUploadEventForFileMessage()设置不接收群聊的 file 消息,使用 group_upload 事件作为群文件消息 final BotBuilderkeepEventsBeforeConnected()是否保留所有在Bot成功连接之前传入的事件。比如 go-cqhttp 会在连接之后,在 Overflow 获取到 Bot 信息之前,推送以前未收到的消息。如果不开启此项,则这些消息会被抛弃,反之会在瞬时接收到很多消息 final BotBuilderoverrideLogger(Logger logger)覆写用于 Onebot 的日志记录器 final BotBuilderparentJob(Job job)设置父工作,可选 final BotBuilderwithBotConfiguration(Supplier<BotConfiguration> supplier)覆盖原有 BotConfiguration final BotBuildermodifyBotConfiguration(Consumer<BotConfiguration> consumer)修改原有 BotConfiguration final BotBuilderworkingDir(Function1<Long, File> block)设置或取消设置工作目录 final Botconnect()连接到 Onebot final static BotBuilderpositive(String host)正向 WebSocket 连接 final static BotBuilderreversed(Integer port)反向 WebSocket 连接 -
-
Method Detail
-
token
final BotBuilder token(String token)
设置用于连接时鉴权的 token
将 token 设为空则不进行鉴权
-
retryTimes
final BotBuilder retryTimes(Integer retryTimes)
设置尝试重连次数,设为 0 时禁用自动重连
仅主动 WebSocket 可自动重连
-
retryWaitMills
final BotBuilder retryWaitMills(Long retryWaitMills)
设置重连等待间隔时间
仅主动 WebSocket 可自动重连
-
retryRestMills
final BotBuilder retryRestMills(Long retryRestMills)
设置重连休息时间
仅主动 WebSocket 可自动重连
重连次数耗尽后,会进入休息状态,休息结束后重置重连次数,再次尝试重连
设为 -1 禁用此功能
-
heartbeatCheckSeconds
final BotBuilder heartbeatCheckSeconds(Integer heartbeatCheckSeconds)
设置 WebSocket 心跳检查时间
设为 0 关闭心跳检查
-
noPrintInfo
final BotBuilder noPrintInfo()
-
noPlatform
final BotBuilder noPlatform()
禁止 Overflow 调用 Tencent 的网络接口
调用这些网络接口需要通过
get_credentials获取凭证,再使用凭证访问接口。部分 Onebot 实现不支持获取账号凭证,甚至于并不从QQ实现(如 Discord、Kook 等),连接这些实例前,需要禁用网络接口调用
-
useCQCode
final BotBuilder useCQCode()
发送消息时使用 CQ 码
即使不开启该选项,也可使用 CQ 码接收消息
-
useGroupUploadEventForFileMessage
final BotBuilder useGroupUploadEventForFileMessage()
设置不接收群聊的 file 消息,使用 group_upload 事件作为群文件消息
-
keepEventsBeforeConnected
final BotBuilder keepEventsBeforeConnected()
是否保留所有在Bot成功连接之前传入的事件。
比如 go-cqhttp 会在连接之后,在 Overflow 获取到 Bot 信息之前,推送以前未收到的消息。如果不开启此项,则这些消息会被抛弃,反之会在瞬时接收到很多消息
-
overrideLogger
final BotBuilder overrideLogger(Logger logger)
覆写用于 Onebot 的日志记录器
-
parentJob
final BotBuilder parentJob(Job job)
设置父工作,可选
-
withBotConfiguration
@JvmSuppressWildcards() final BotBuilder withBotConfiguration(Supplier<BotConfiguration> supplier)
覆盖原有 BotConfiguration
-
modifyBotConfiguration
@JvmSuppressWildcards() final BotBuilder modifyBotConfiguration(Consumer<BotConfiguration> consumer)
修改原有 BotConfiguration
-
workingDir
@JvmSuppressWildcards() final BotBuilder workingDir(Function1<Long, File> block)
设置或取消设置工作目录
- Parameters:
block- 传入QQ号,返回路径
-
connect
final Bot connect()
连接到 Onebot
-
positive
final static BotBuilder positive(String host)
正向 WebSocket 连接
-
reversed
final static BotBuilder reversed(Integer port)
反向 WebSocket 连接
-
-
-
-