public interface OneBot
| 限定符和类型 | 方法和说明 |
|---|---|
ActionData<BooleanResp> |
canSendImage()
检查是否可以发送图片
|
ActionData<BooleanResp> |
canSendRecord()
检查是否可以发送语音
|
ActionRaw |
deleteMsg(int msgId)
撤回消息
|
ActionList<FriendInfoResp> |
getFriendList()
获取好友列表
|
ActionData<GroupHonorInfoResp> |
getGroupHonorInfo(long groupId,
java.lang.String type)
获取群荣誉信息
|
ActionData<GroupInfoResp> |
getGroupInfo(long groupId,
boolean noCache)
获取群信息
|
ActionList<GroupInfoResp> |
getGroupList()
获取群列表
|
ActionData<GroupMemberInfoResp> |
getGroupMemberInfo(long groupId,
long userId,
boolean noCache)
获取群成员信息
|
ActionList<GroupMemberInfoResp> |
getGroupMemberList(long groupId)
获取群成员列表
|
ActionData<LoginInfoResp> |
getLoginInfo()
获取登录号信息
|
ActionData<GetMsgResp> |
getMsg(int msgId)
获取消息
|
GetStatusResp |
getStatus()
获取状态
|
ActionData<StrangerInfoResp> |
getStrangerInfo(long userId,
boolean noCache)
获取陌生人信息
|
ActionData<MsgId> |
sendGroupMsg(long groupId,
java.util.List<ArrayMsg> msg,
boolean autoEscape)
发送群消息
|
ActionData<MsgId> |
sendGroupMsg(long groupId,
long userId,
java.lang.String msg,
boolean autoEscape)
发送群消息
|
ActionData<MsgId> |
sendGroupMsg(long groupId,
java.lang.String msg,
boolean autoEscape)
发送群消息
|
ActionRaw |
sendLike(long userId,
int times)
好友点赞
|
ActionData<MsgId> |
sendMsg(WholeMessageEvent event,
java.util.List<ArrayMsg> msg,
boolean autoEscape)
发送消息
|
ActionData<MsgId> |
sendMsg(WholeMessageEvent event,
java.lang.String msg,
boolean autoEscape)
发送消息
|
ActionData<MsgId> |
sendPrivateMsg(long userId,
java.util.List<ArrayMsg> msg,
boolean autoEscape)
发送私聊消息
|
ActionData<MsgId> |
sendPrivateMsg(long groupId,
long userId,
java.util.List<ArrayMsg> msg,
boolean autoEscape)
临时会话
|
ActionData<MsgId> |
sendPrivateMsg(long groupId,
long userId,
java.lang.String msg,
boolean autoEscape)
临时会话
|
ActionData<MsgId> |
sendPrivateMsg(long userId,
java.lang.String msg,
boolean autoEscape)
发送私聊消息
|
ActionRaw |
setFriendAddRequest(java.lang.String flag,
boolean approve,
java.lang.String remark)
处理加好友请求
|
ActionRaw |
setGroupAddRequest(java.lang.String flag,
java.lang.String subType,
boolean approve,
java.lang.String reason)
处理加群请求/邀请
|
ActionRaw |
setGroupAdmin(long groupId,
long userId,
boolean enable)
群组设置管理员
|
ActionRaw |
setGroupAnonymous(long groupId,
boolean enable)
群组匿名
|
ActionRaw |
setGroupAnonymousBan(long groupId,
Anonymous anonymous,
int duration)
群组匿名用户禁言
|
ActionRaw |
setGroupAnonymousBan(long groupId,
java.lang.String flag,
int duration)
群组匿名用户禁言
|
ActionRaw |
setGroupBan(long groupId,
long userId,
int duration)
群组单人禁言
|
ActionRaw |
setGroupCard(long groupId,
long userId,
java.lang.String card)
设置群名片(群备注)
|
ActionRaw |
setGroupKick(long groupId,
long userId,
boolean rejectAddRequest)
群组踢人
|
ActionRaw |
setGroupLeave(long groupId,
boolean isDismiss)
退出群组
|
ActionRaw |
setGroupName(long groupId,
java.lang.String groupName)
设置群名
|
ActionRaw |
setGroupWholeBan(long groupId,
boolean enable)
全体禁言
|
ActionData<MsgId> sendMsg(WholeMessageEvent event, java.lang.String msg, boolean autoEscape)
event - WholeMessageEventmsg - 要发送的内容autoEscape - 消息内容是否作为纯文本发送 ( 即不解析 CQ 码 ) , 只在 message 字段是字符串时有效ActionData of MsgIdActionData<MsgId> sendMsg(WholeMessageEvent event, java.util.List<ArrayMsg> msg, boolean autoEscape)
event - WholeMessageEventmsg - 消息链autoEscape - 消息内容是否作为纯文本发送 ( 即不解析 CQ 码 ) , 只在 message 字段是字符串时有效ActionData of MsgIdActionData<MsgId> sendPrivateMsg(long userId, java.lang.String msg, boolean autoEscape)
userId - 对方 QQ 号msg - 要发送的内容autoEscape - 消息内容是否作为纯文本发送 ( 即不解析 CQ 码 ) , 只在 message 字段是字符串时有效ActionData of MsgIdActionData<MsgId> sendPrivateMsg(long userId, java.util.List<ArrayMsg> msg, boolean autoEscape)
userId - 对方 QQ 号msg - 消息链autoEscape - 消息内容是否作为纯文本发送 ( 即不解析 CQ 码 ) , 只在 message 字段是字符串时有效ActionData of MsgIdActionData<MsgId> sendPrivateMsg(long groupId, long userId, java.lang.String msg, boolean autoEscape)
groupId - 主动发起临时会话群号(机器人本身必须是管理员/群主)userId - 对方 QQ 号msg - 要发送的内容autoEscape - 消息内容是否作为纯文本发送 ( 即不解析 CQ 码 ) , 只在 message 字段是字符串时有效ActionData of MsgIdActionData<MsgId> sendPrivateMsg(long groupId, long userId, java.util.List<ArrayMsg> msg, boolean autoEscape)
groupId - 主动发起临时会话群号(机器人本身必须是管理员/群主)userId - 对方 QQ 号msg - 消息链autoEscape - 消息内容是否作为纯文本发送 ( 即不解析 CQ 码 ) , 只在 message 字段是字符串时有效ActionData of MsgIdActionData<MsgId> sendGroupMsg(long groupId, java.lang.String msg, boolean autoEscape)
groupId - 群号msg - 要发送的内容autoEscape - 消息内容是否作为纯文本发送 ( 即不解析 CQ 码 ) , 只在 message 字段是字符串时有效ActionData of MsgIdActionData<MsgId> sendGroupMsg(long groupId, java.util.List<ArrayMsg> msg, boolean autoEscape)
groupId - 群号msg - 消息链autoEscape - 消息内容是否作为纯文本发送 ( 即不解析 CQ 码 ) , 只在 message 字段是字符串时有效ActionData of MsgIdActionData<MsgId> sendGroupMsg(long groupId, long userId, java.lang.String msg, boolean autoEscape)
groupId - 群号userId - 调用者的QQ号 , 在QQ开放平台中用于设定@对象,如果不设置此参数会导致: 在bot返回前如果被不同用户多次调用,只会@最后一次调用的用户msg - 要发送的内容autoEscape - 消息内容是否作为纯文本发送 ( 即不解析 CQ 码 ) , 只在 message 字段是字符串时有效ActionData of MsgIdActionData<GetMsgResp> getMsg(int msgId)
msgId - 消息 IDActionData of GetMsgRespActionRaw setGroupKick(long groupId, long userId, boolean rejectAddRequest)
groupId - 群号userId - 要踢的 QQ 号rejectAddRequest - 拒绝此人的加群请求 (默认false)ActionRawActionRaw setGroupBan(long groupId, long userId, int duration)
groupId - 群号userId - 要禁言的 QQ 号duration - 禁言时长, 单位秒, 0 表示取消禁言 (默认30 * 60)ActionRawActionRaw setGroupAdmin(long groupId, long userId, boolean enable)
groupId - 群号userId - 要设置管理员的 QQ 号enable - true 为设置,false 为取消ActionRawActionRaw setGroupAnonymous(long groupId, boolean enable)
groupId - 群号enable - 是否允许匿名聊天ActionRawActionRaw setGroupCard(long groupId, long userId, java.lang.String card)
groupId - 群号userId - 要设置的 QQ 号card - 群名片内容,不填或空字符串表示删除群名片ActionRawActionRaw setGroupName(long groupId, java.lang.String groupName)
groupId - 群号groupName - 新群名ActionRawActionRaw setGroupLeave(long groupId, boolean isDismiss)
groupId - 群号isDismiss - 是否解散, 如果登录号是群主, 则仅在此项为 true 时能够解散ActionRawActionRaw setFriendAddRequest(java.lang.String flag, boolean approve, java.lang.String remark)
flag - 加好友请求的 flag(需从上报的数据中获得)approve - 是否同意请求(默认为true)remark - 添加后的好友备注(仅在同意时有效)ActionRawActionRaw setGroupAddRequest(java.lang.String flag, java.lang.String subType, boolean approve, java.lang.String reason)
flag - 加群请求的 flag(需从上报的数据中获得)subType - add 或 invite,请求类型(需要和上报消息中的 sub_type 字段相符)approve - 是否同意请求/邀请reason - 拒绝理由(仅在拒绝时有效)ActionRawActionData<StrangerInfoResp> getStrangerInfo(long userId, boolean noCache)
userId - QQ 号noCache - 是否不使用缓存(使用缓存可能更新不及时,但响应更快)ActionData of StrangerInfoRespActionList<FriendInfoResp> getFriendList()
ActionList of FriendInfoRespActionData<GroupInfoResp> getGroupInfo(long groupId, boolean noCache)
groupId - 群号noCache - 是否不使用缓存(使用缓存可能更新不及时,但响应更快)ActionData of GroupInfoRespActionList<GroupInfoResp> getGroupList()
ActionList of GroupInfoRespActionData<GroupMemberInfoResp> getGroupMemberInfo(long groupId, long userId, boolean noCache)
groupId - 群号userId - QQ 号noCache - 是否不使用缓存(使用缓存可能更新不及时,但响应更快)ActionData of GroupMemberInfoRespActionList<GroupMemberInfoResp> getGroupMemberList(long groupId)
groupId - 群号ActionList of GroupMemberInfoRespActionData<GroupHonorInfoResp> getGroupHonorInfo(long groupId, java.lang.String type)
groupId - 群号type - 要获取的群荣誉类型, 可传入 talkative performer legend strong_newbie emotion 以分别获取单个类型的群荣誉数据, 或传入 all 获取所有数据ActionData of GroupHonorInfoRespActionData<BooleanResp> canSendImage()
ActionData of BooleanRespActionData<BooleanResp> canSendRecord()
ActionData of BooleanRespActionRaw sendLike(long userId, int times)
userId - 目标用户times - 点赞次数(每个好友每天最多 10 次,机器人为 Super VIP 则提高到 20次)ActionRawGetStatusResp getStatus()
GetStatusRespActionRaw setGroupAnonymousBan(long groupId, Anonymous anonymous, int duration)
groupId - 群号anonymous - 要禁言的匿名用户对象(群消息上报的 anonymous 字段)duration - 禁言时长,单位秒,无法取消匿名用户禁言ActionRawActionRaw setGroupAnonymousBan(long groupId, java.lang.String flag, int duration)
groupId - 群号flag - 要禁言的匿名用户的 flag(需从群消息上报的数据中获得)duration - 禁言时长,单位秒,无法取消匿名用户禁言ActionRawActionRaw setGroupWholeBan(long groupId, boolean enable)
groupId - 群号enable - 是否禁言(默认True,False为取消禁言)ActionRawActionData<LoginInfoResp> getLoginInfo()
ActionData of @LoginInfoResp