Class BotBuilder

  • All Implemented Interfaces:

    
    public final class BotBuilder
    
                        

    Onebot 连接向导

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

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

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • token

         final BotBuilder token(String token)

        设置用于连接时鉴权的 token

        将 token 设为空则不进行鉴权

      • retryTimes

         final BotBuilder retryTimes(Integer retryTimes)

        设置尝试重连次数,设为 0 时禁用自动重连

        仅主动 WebSocket 可自动重连

      • retryRestMills

         final BotBuilder retryRestMills(Long retryRestMills)

        设置重连休息时间

        仅主动 WebSocket 可自动重连

        重连次数耗尽后,会进入休息状态,休息结束后重置重连次数,再次尝试重连

        设为 -1 禁用此功能

      • noPrintInfo

         final BotBuilder noPrintInfo()

        禁止打印连接时额外状态信息

        如 Overflow 版本、连接地址、Onebot 协议端版本等

        如果需要禁止打印连接成功与失败情况的日志,请使用 overrideLogger 覆写日志记录器

      • noPlatform

         final BotBuilder noPlatform()

        禁止 Overflow 调用 Tencent 的网络接口

        调用这些网络接口需要通过 get_credentials 获取凭证,再使用凭证访问接口。

        部分 Onebot 实现不支持获取账号凭证,甚至于并不从QQ实现(如 Discord、Kook 等),连接这些实例前,需要禁用网络接口调用

      • useCQCode

         final BotBuilder useCQCode()

        发送消息时使用 CQ 码

        即使不开启该选项,也可使用 CQ 码接收消息

      • keepEventsBeforeConnected

         final BotBuilder keepEventsBeforeConnected()

        是否保留所有在Bot成功连接之前传入的事件。

        比如 go-cqhttp 会在连接之后,在 Overflow 获取到 Bot 信息之前,推送以前未收到的消息。如果不开启此项,则这些消息会被抛弃,反之会在瞬时接收到很多消息

      • connect

         final Bot connect()

        连接到 Onebot