Interface OneBot

All Known Implementing Classes:
Bot

public interface OneBot
  • Method Details

    • sendMsg

      ActionData<MsgId> sendMsg(AnyMessageEvent event, String msg, boolean autoEscape)
      发送消息
      Parameters:
      event - AnyMessageEvent
      msg - 要发送的内容
      autoEscape - 消息内容是否作为纯文本发送 ( 即不解析 CQ 码 ) , 只在 message 字段是字符串时有效
      Returns:
      result ActionData of MsgId
    • sendMsg

      ActionData<MsgId> sendMsg(AnyMessageEvent event, List<ArrayMsg> msg, boolean autoEscape)
      发送消息
      Parameters:
      event - AnyMessageEvent
      msg - 消息链
      autoEscape - 消息内容是否作为纯文本发送 ( 即不解析 CQ 码 ) , 只在 message 字段是字符串时有效
      Returns:
      result ActionData of MsgId
    • sendPrivateMsg

      ActionData<MsgId> sendPrivateMsg(long userId, String msg, boolean autoEscape)
      发送私聊消息
      Parameters:
      userId - 对方 QQ 号
      msg - 要发送的内容
      autoEscape - 消息内容是否作为纯文本发送 ( 即不解析 CQ 码 ) , 只在 message 字段是字符串时有效
      Returns:
      result ActionData of MsgId
    • sendPrivateMsg

      ActionData<MsgId> sendPrivateMsg(long userId, List<ArrayMsg> msg, boolean autoEscape)
      发送私聊消息
      Parameters:
      userId - 对方 QQ 号
      msg - 消息链
      autoEscape - 消息内容是否作为纯文本发送 ( 即不解析 CQ 码 ) , 只在 message 字段是字符串时有效
      Returns:
      result ActionData of MsgId
    • sendPrivateMsg

      ActionData<MsgId> sendPrivateMsg(long groupId, long userId, String msg, boolean autoEscape)
      临时会话
      Parameters:
      groupId - 主动发起临时会话群号(机器人本身必须是管理员/群主)
      userId - 对方 QQ 号
      msg - 要发送的内容
      autoEscape - 消息内容是否作为纯文本发送 ( 即不解析 CQ 码 ) , 只在 message 字段是字符串时有效
      Returns:
      result ActionData of MsgId
    • sendPrivateMsg

      ActionData<MsgId> sendPrivateMsg(long groupId, long userId, List<ArrayMsg> msg, boolean autoEscape)
      临时会话
      Parameters:
      groupId - 主动发起临时会话群号(机器人本身必须是管理员/群主)
      userId - 对方 QQ 号
      msg - 消息链
      autoEscape - 消息内容是否作为纯文本发送 ( 即不解析 CQ 码 ) , 只在 message 字段是字符串时有效
      Returns:
      result ActionData of MsgId
    • sendGroupMsg

      ActionData<MsgId> sendGroupMsg(long groupId, String msg, boolean autoEscape)
      发送群消息
      Parameters:
      groupId - 群号
      msg - 要发送的内容
      autoEscape - 消息内容是否作为纯文本发送 ( 即不解析 CQ 码 ) , 只在 message 字段是字符串时有效
      Returns:
      result ActionData of MsgId
    • sendGroupMsg

      ActionData<MsgId> sendGroupMsg(long groupId, List<ArrayMsg> msg, boolean autoEscape)
      发送群消息
      Parameters:
      groupId - 群号
      msg - 消息链
      autoEscape - 消息内容是否作为纯文本发送 ( 即不解析 CQ 码 ) , 只在 message 字段是字符串时有效
      Returns:
      result ActionData of MsgId
    • sendGroupMsg

      ActionData<MsgId> sendGroupMsg(long groupId, long userId, String msg, boolean autoEscape)
      发送群消息
      Parameters:
      groupId - 群号
      userId - 调用者的QQ号 , 在QQ开放平台中用于设定@对象,如果不设置此参数会导致: 在bot返回前如果被不同用户多次调用,只会@最后一次调用的用户
      msg - 要发送的内容
      autoEscape - 消息内容是否作为纯文本发送 ( 即不解析 CQ 码 ) , 只在 message 字段是字符串时有效
      Returns:
      result ActionData of MsgId
    • getMsg

      ActionData<MsgResp> getMsg(int msgId)
      获取消息
      Parameters:
      msgId - 消息 ID
      Returns:
      result ActionData of MsgResp
    • deleteMsg

      ActionRaw deleteMsg(int msgId)
      撤回消息
      Parameters:
      msgId - 消息 ID
      Returns:
      result ActionRaw
    • setGroupKick

      ActionRaw setGroupKick(long groupId, long userId, boolean rejectAddRequest)
      群组踢人
      Parameters:
      groupId - 群号
      userId - 要踢的 QQ 号
      rejectAddRequest - 拒绝此人的加群请求 (默认false)
      Returns:
      result ActionRaw
    • setGroupBan

      ActionRaw setGroupBan(long groupId, long userId, int duration)
      群组单人禁言
      Parameters:
      groupId - 群号
      userId - 要禁言的 QQ 号
      duration - 禁言时长, 单位秒, 0 表示取消禁言 (默认30 * 60)
      Returns:
      result ActionRaw
    • setGroupAdmin

      ActionRaw setGroupAdmin(long groupId, long userId, boolean enable)
      群组设置管理员
      Parameters:
      groupId - 群号
      userId - 要设置管理员的 QQ 号
      enable - true 为设置,false 为取消
      Returns:
      result ActionRaw
    • setGroupAnonymous

      ActionRaw setGroupAnonymous(long groupId, boolean enable)
      群组匿名
      Parameters:
      groupId - 群号
      enable - 是否允许匿名聊天
      Returns:
      result ActionRaw
    • setGroupCard

      ActionRaw setGroupCard(long groupId, long userId, String card)
      设置群名片(群备注)
      Parameters:
      groupId - 群号
      userId - 要设置的 QQ 号
      card - 群名片内容,不填或空字符串表示删除群名片
      Returns:
      result ActionRaw
    • setGroupName

      ActionRaw setGroupName(long groupId, String groupName)
      设置群名
      Parameters:
      groupId - 群号
      groupName - 新群名
      Returns:
      result ActionRaw
    • setGroupLeave

      ActionRaw setGroupLeave(long groupId, boolean isDismiss)
      退出群组
      Parameters:
      groupId - 群号
      isDismiss - 是否解散, 如果登录号是群主, 则仅在此项为 true 时能够解散
      Returns:
      result ActionRaw
    • setFriendAddRequest

      ActionRaw setFriendAddRequest(String flag, boolean approve, String remark)
      处理加好友请求
      Parameters:
      flag - 加好友请求的 flag(需从上报的数据中获得)
      approve - 是否同意请求(默认为true)
      remark - 添加后的好友备注(仅在同意时有效)
      Returns:
      result ActionRaw
    • setGroupAddRequest

      ActionRaw setGroupAddRequest(String flag, String subType, boolean approve, String reason)
      处理加群请求/邀请
      Parameters:
      flag - 加群请求的 flag(需从上报的数据中获得)
      subType - add 或 invite,请求类型(需要和上报消息中的 sub_type 字段相符)
      approve - 是否同意请求/邀请
      reason - 拒绝理由(仅在拒绝时有效)
      Returns:
      result ActionRaw
    • getStrangerInfo

      ActionData<StrangerInfoResp> getStrangerInfo(long userId, boolean noCache)
      获取陌生人信息
      Parameters:
      userId - QQ 号
      noCache - 是否不使用缓存(使用缓存可能更新不及时,但响应更快)
      Returns:
      result ActionData of StrangerInfoResp
    • getFriendList

      ActionList<FriendInfoResp> getFriendList()
      获取好友列表
      Returns:
      result ActionList of FriendInfoResp
    • getGroupInfo

      ActionData<GroupInfoResp> getGroupInfo(long groupId, boolean noCache)
      获取群信息
      Parameters:
      groupId - 群号
      noCache - 是否不使用缓存(使用缓存可能更新不及时,但响应更快)
      Returns:
      result ActionData of GroupInfoResp
    • getGroupList

      ActionList<GroupInfoResp> getGroupList()
      获取群列表
      Returns:
      result ActionList of GroupInfoResp
    • getGroupMemberInfo

      ActionData<GroupMemberInfoResp> getGroupMemberInfo(long groupId, long userId, boolean noCache)
      获取群成员信息
      Parameters:
      groupId - 群号
      userId - QQ 号
      noCache - 是否不使用缓存(使用缓存可能更新不及时,但响应更快)
      Returns:
      result ActionData of GroupMemberInfoResp
    • getGroupMemberList

      ActionList<GroupMemberInfoResp> getGroupMemberList(long groupId)
      获取群成员列表
      Parameters:
      groupId - 群号
      Returns:
      result ActionList of GroupMemberInfoResp
    • getGroupHonorInfo

      ActionData<GroupHonorInfoResp> getGroupHonorInfo(long groupId, String type)
      获取群荣誉信息
      Parameters:
      groupId - 群号
      type - 要获取的群荣誉类型, 可传入 talkative performer legend strong_newbie emotion 以分别获取单个类型的群荣誉数据, 或传入 all 获取所有数据
      Returns:
      result ActionData of GroupHonorInfoResp
    • canSendImage

      ActionData<BooleanResp> canSendImage()
      检查是否可以发送图片
      Returns:
      result ActionData of BooleanResp
    • canSendRecord

      ActionData<BooleanResp> canSendRecord()
      检查是否可以发送语音
      Returns:
      result ActionData of BooleanResp
    • sendLike

      ActionRaw sendLike(long userId, int times)
      好友点赞
      Parameters:
      userId - 目标用户
      times - 点赞次数(每个好友每天最多 10 次,机器人为 Super VIP 则提高到 20次)
      Returns:
      result ActionRaw
    • getStatus

      获取状态
      Returns:
      result GetStatusResp
    • setGroupAnonymousBan

      ActionRaw setGroupAnonymousBan(long groupId, Anonymous anonymous, int duration)
      群组匿名用户禁言
      Parameters:
      groupId - 群号
      anonymous - 要禁言的匿名用户对象(群消息上报的 anonymous 字段)
      duration - 禁言时长,单位秒,无法取消匿名用户禁言
      Returns:
      result ActionRaw
    • setGroupAnonymousBan

      ActionRaw setGroupAnonymousBan(long groupId, String flag, int duration)
      群组匿名用户禁言
      Parameters:
      groupId - 群号
      flag - 要禁言的匿名用户的 flag(需从群消息上报的数据中获得)
      duration - 禁言时长,单位秒,无法取消匿名用户禁言
      Returns:
      result ActionRaw
    • setGroupWholeBan

      ActionRaw setGroupWholeBan(long groupId, boolean enable)
      全体禁言
      Parameters:
      groupId - 群号
      enable - 是否禁言(默认True,False为取消禁言)
      Returns:
      result ActionRaw
    • getLoginInfo

      ActionData<LoginInfoResp> getLoginInfo()
      获取登录号信息
      Returns:
      result ActionData of @LoginInfoResp