Documentation
¶
Index ¶
- Constants
- type Anonymous
- type AnonymousMember
- type At
- type Bot
- func (b *Bot) CanSendImage() (bool, error)
- func (b *Bot) CanSendRecord() (bool, error)
- func (b *Bot) CleanCache() error
- func (b *Bot) Close() error
- func (b *Bot) DeleteMessage(messageId int64) error
- func (b *Bot) GetCookies(domain string) (string, error)
- func (b *Bot) GetCredentials(domain string) (string, int32, error)
- func (b *Bot) GetCsrfToken() (int32, error)
- func (b *Bot) GetForwardMessage(id string) ([]any, error)
- func (b *Bot) GetFriendList() ([]*Friend, error)
- func (b *Bot) GetGroupInfo(group int64, noCache bool) (*GroupInfo, error)
- func (b *Bot) GetGroupList() ([]*GroupInfo, error)
- func (b *Bot) GetGroupMemberInfo(group, qq int64, noCache bool) (*GroupMemberInfo, error)
- func (b *Bot) GetGroupMemberList(group int64) ([]*GroupMemberInfo, error)
- func (b *Bot) GetImage(file string) (string, error)
- func (b *Bot) GetLoginInfo() (*LoginInfo, error)
- func (b *Bot) GetMessage(messageId int32) (*Message, error)
- func (b *Bot) GetRecord(file, outFormat string) (string, error)
- func (b *Bot) GetStatus() (*BotStatus, error)
- func (b *Bot) GetStrangerInfo(userId int64, noCache bool) (*Profile, error)
- func (b *Bot) GetVersionInfo() (*BotVersionInfo, error)
- func (b *Bot) ListenFriendAddNotice(l func(notice *FriendAddNotice) bool)
- func (b *Bot) ListenFriendRecallNotice(l func(notice *FriendRecallNotice) bool)
- func (b *Bot) ListenFriendRequest(l func(request *FriendRequest) bool)
- func (b *Bot) ListenGroupAdminNotice(l func(notice *GroupAdminNotice) bool)
- func (b *Bot) ListenGroupBanNotice(l func(notice *GroupBanNotice) bool)
- func (b *Bot) ListenGroupDecreaseNotice(l func(notice *GroupDecreaseNotice) bool)
- func (b *Bot) ListenGroupIncreaseNotice(l func(notice *GroupIncreaseNotice) bool)
- func (b *Bot) ListenGroupMessage(l func(message *GroupMessage) bool)
- func (b *Bot) ListenGroupRecallNotice(l func(notice *GroupRecallNotice) bool)
- func (b *Bot) ListenGroupRequest(l func(request *GroupRequest) bool)
- func (b *Bot) ListenGroupUploadNotice(l func(notice *GroupUploadNotice) bool)
- func (b *Bot) ListenHeartbeatMetaEvent(l func(notice *HeartbeatMetaEvent) bool)
- func (b *Bot) ListenLifecycleMetaEvent(l func(notice *LifecycleMetaEvent) bool)
- func (b *Bot) ListenNotifyNotice(l func(notice *NotifyNotice) bool)
- func (b *Bot) ListenPrivateMessage(l func(message *PrivateMessage) bool)
- func (b *Bot) Run(f func())
- func (b *Bot) SendGroupMessage(group int64, message MessageChain) (int64, error)
- func (b *Bot) SendLike(userId int64, times int32) error
- func (b *Bot) SendMessage(messageType MessageType, targetId int64, message MessageChain) (int64, error)
- func (b *Bot) SendPrivateMessage(userId int64, message MessageChain) (int64, error)
- func (b *Bot) SetFriendAddRequest(flag string, approve bool, remark string) error
- func (b *Bot) SetGroupAddRequest(flag string, subType GroupRequestSubType, approve bool, reason string) error
- func (b *Bot) SetGroupAdmin(groupId, userId int64, enable bool) error
- func (b *Bot) SetGroupAnonymous(groupId int64, enable bool) error
- func (b *Bot) SetGroupAnonymousBan(groupId int64, flag string, duration int32) error
- func (b *Bot) SetGroupBan(groupId, userId int64, duration int32) error
- func (b *Bot) SetGroupCard(groupId, userId int64, card string) error
- func (b *Bot) SetGroupKick(groupId, userId int64, rejectAddRequest bool) error
- func (b *Bot) SetGroupLeave(group int64, isDismiss bool) error
- func (b *Bot) SetGroupName(groupId int64, groupName string) error
- func (b *Bot) SetGroupSpecialTitle(groupId, userId int64, specialTitle string, duration int32) error
- func (b *Bot) SetGroupWholeBan(groupId int64, enable bool) error
- func (b *Bot) SetLimiter(limiterType string, l *rate.Limiter)
- func (b *Bot) SetRestart(delay int32) error
- type BotStatus
- type BotVersionInfo
- type Contact
- type ContactType
- type Dice
- type Face
- type File
- type Forward
- type Friend
- type FriendAddNotice
- type FriendRecallNotice
- type FriendRequest
- type Group
- type GroupAdminNotice
- type GroupAdminNoticeSubType
- type GroupBanNotice
- type GroupBanNoticeSubType
- type GroupDecreaseNotice
- type GroupDecreaseNoticeSubType
- type GroupIncreaseNotice
- type GroupIncreaseNoticeSubType
- type GroupInfo
- type GroupMemberInfo
- type GroupMessage
- type GroupMessageSubType
- type GroupRecallNotice
- type GroupRequest
- type GroupRequestSubType
- type GroupUploadNotice
- type HeartbeatMetaEvent
- type Image
- type Json
- type LifecycleMetaEvent
- type LifecycleMetaEventSubType
- type Location
- type LoginInfo
- type Member
- type Message
- type MessageChain
- type MessageType
- type Music
- type Node
- type NotifyNotice
- type NotifyNoticeHonorType
- type NotifyNoticeSubType
- type Poke
- type PrivateMessage
- type PrivateMessageSubType
- type Profile
- type RPS
- type Record
- type Reply
- type Role
- type Sex
- type Shake
- type Share
- type SingleMessage
- type Text
- type Video
- type WsChannel
- type Xml
Constants ¶
const ( // WsChannelApi 连接此接口后,向 OneBot 发送如下结构的 JSON 对象,即可调用相应的 API WsChannelApi = "api" // WsChannelEvent 连接此接口后,OneBot 会在收到事件后推送至客户端 WsChannelEvent = "event" // WsChannelAll 在一条连接上同时提供 api 和 event 的服务 WsChannelAll = "" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Anonymous ¶
type Anonymous struct {
Ignore string `json:"ignore,omitempty"` // 发消息时使用,1和0表示无法匿名时是否继续发送
}
Anonymous 匿名发消息
func (*Anonymous) GetMessageType ¶
type AnonymousMember ¶
type AnonymousMember struct {
Id int64 `json:"id"` // 匿名用户 ID
Name string `json:"name"` // 匿名用户名称
Flag string `json:"flag"` // 匿名用户 flag,在调用禁言 API 时需要传入
}
func (*AnonymousMember) String ¶
func (a *AnonymousMember) String() string
type At ¶
type At struct {
QQ string `json:"qq"` // 群员QQ号,或者"all"表示全体成员
}
At @某人
func (*At) GetMessageType ¶
type Bot ¶
type Bot struct {
QQ int64
// contains filtered or unexported fields
}
func Connect ¶
func Connect(host string, port int, channel WsChannel, accessToken string, qq int64, concurrentEvent bool) (*Bot, error)
Connect 连接onebot
concurrentEvent 参数如果是true,表示采用并发方式处理事件和消息,由调用者自行解决并发问题。 如果是false表示用单线程处理事件和消息,调用者无需关心并发问题。
func (*Bot) DeleteMessage ¶
DeleteMessage 撤回消息,messageId-需要撤回的消息的ID
func (*Bot) GetCookies ¶
GetCookies 获取Cookies,domain-需要获取cookies的域名
func (*Bot) GetCredentials ¶
GetCredentials 获取QQ相关接口凭证,即上面两个接口的合并
func (*Bot) GetForwardMessage ¶
GetForwardMessage 获取合并转发消息
func (*Bot) GetFriendList ¶
GetFriendList 获取陌生人信息,获取好友列表
func (*Bot) GetGroupInfo ¶
GetGroupInfo 获取群信息,group-群号,noCache-是否不使用缓存
func (*Bot) GetGroupMemberInfo ¶
func (b *Bot) GetGroupMemberInfo(group, qq int64, noCache bool) (*GroupMemberInfo, error)
GetGroupMemberInfo 获取群成员信息,group-群号,qq-QQ号,noCache-是否不使用缓存
func (*Bot) GetGroupMemberList ¶
func (b *Bot) GetGroupMemberList(group int64) ([]*GroupMemberInfo, error)
GetGroupMemberList 获取群成员列表,group-群号
注意:获取群成员列表时,不保证能获取到每个成员的所有信息,有些信息(例如area、title等)可能无法获得。 想要获取所有信息,请调用 Bot.GetGroupMemberInfo 方法获取单个成员信息。
func (*Bot) GetMessage ¶
GetMessage 获取消息
func (*Bot) GetRecord ¶
GetRecord 获取语音,file-收到的语音文件名(消息段的file参数),outFormat-要转换到的格式,返回转换后的语音文件路径
提示:要使用此接口,通常需要安装 ffmpeg,请参考 OneBot 实现的相关说明。 outFormat目前支持mp3、amr、wma、m4a、spx、ogg、wav、flac
func (*Bot) GetStrangerInfo ¶
GetStrangerInfo 获取陌生人信息,userId-QQ号,noCache-是否不使用缓存
func (*Bot) GetVersionInfo ¶
func (b *Bot) GetVersionInfo() (*BotVersionInfo, error)
GetVersionInfo 获取版本信息
func (*Bot) ListenFriendAddNotice ¶
func (b *Bot) ListenFriendAddNotice(l func(notice *FriendAddNotice) bool)
ListenFriendAddNotice 监听好友添加
func (*Bot) ListenFriendRecallNotice ¶
func (b *Bot) ListenFriendRecallNotice(l func(notice *FriendRecallNotice) bool)
ListenFriendRecallNotice 监听好友消息撤回
func (*Bot) ListenFriendRequest ¶
func (b *Bot) ListenFriendRequest(l func(request *FriendRequest) bool)
ListenFriendRequest 监听加好友请求
func (*Bot) ListenGroupAdminNotice ¶
func (b *Bot) ListenGroupAdminNotice(l func(notice *GroupAdminNotice) bool)
ListenGroupAdminNotice 监听群管理员变动
func (*Bot) ListenGroupBanNotice ¶
func (b *Bot) ListenGroupBanNotice(l func(notice *GroupBanNotice) bool)
ListenGroupBanNotice 监听群禁言
func (*Bot) ListenGroupDecreaseNotice ¶
func (b *Bot) ListenGroupDecreaseNotice(l func(notice *GroupDecreaseNotice) bool)
ListenGroupDecreaseNotice 监听群成员减少
func (*Bot) ListenGroupIncreaseNotice ¶
func (b *Bot) ListenGroupIncreaseNotice(l func(notice *GroupIncreaseNotice) bool)
ListenGroupIncreaseNotice 监听群成员增加
func (*Bot) ListenGroupMessage ¶
func (b *Bot) ListenGroupMessage(l func(message *GroupMessage) bool)
ListenGroupMessage 监听群消息
func (*Bot) ListenGroupRecallNotice ¶
func (b *Bot) ListenGroupRecallNotice(l func(notice *GroupRecallNotice) bool)
ListenGroupRecallNotice 监听群消息撤回
func (*Bot) ListenGroupRequest ¶
func (b *Bot) ListenGroupRequest(l func(request *GroupRequest) bool)
ListenGroupRequest 监听加群请求 / 邀请
func (*Bot) ListenGroupUploadNotice ¶
func (b *Bot) ListenGroupUploadNotice(l func(notice *GroupUploadNotice) bool)
ListenGroupUploadNotice 监听群文件上传
func (*Bot) ListenHeartbeatMetaEvent ¶
func (b *Bot) ListenHeartbeatMetaEvent(l func(notice *HeartbeatMetaEvent) bool)
ListenHeartbeatMetaEvent 监听心跳事件
func (*Bot) ListenLifecycleMetaEvent ¶
func (b *Bot) ListenLifecycleMetaEvent(l func(notice *LifecycleMetaEvent) bool)
ListenLifecycleMetaEvent 监听生命周期
func (*Bot) ListenNotifyNotice ¶
func (b *Bot) ListenNotifyNotice(l func(notice *NotifyNotice) bool)
ListenNotifyNotice 监听其它通知
func (*Bot) ListenPrivateMessage ¶
func (b *Bot) ListenPrivateMessage(l func(message *PrivateMessage) bool)
ListenPrivateMessage 监听私聊消息
func (*Bot) Run ¶
func (b *Bot) Run(f func())
Run 如果不是并发方式启动,则此方法会将函数放入事件队列。如果是并发方式启动,则此方法等同于go f()。
func (*Bot) SendGroupMessage ¶
func (b *Bot) SendGroupMessage(group int64, message MessageChain) (int64, error)
SendGroupMessage 发送群消息,group-群号,message-发送的内容,返回消息id
func (*Bot) SendMessage ¶
func (b *Bot) SendMessage(messageType MessageType, targetId int64, message MessageChain) (int64, error)
SendMessage 发送消息,返回消息id
func (*Bot) SendPrivateMessage ¶
func (b *Bot) SendPrivateMessage(userId int64, message MessageChain) (int64, error)
SendPrivateMessage 发送私聊消息,消息ID
func (*Bot) SetFriendAddRequest ¶
SetFriendAddRequest 处理加好友请求,flag-从请求中获取,approve-是否同意,remark-同意好友后的备注
func (*Bot) SetGroupAddRequest ¶
func (b *Bot) SetGroupAddRequest(flag string, subType GroupRequestSubType, approve bool, reason string) error
SetGroupAddRequest 处理加群请求/邀请,flag-从请求中获取,subType-从请求中获取,approve-是否同意,reason-拒绝理由
func (*Bot) SetGroupAdmin ¶
SetGroupAdmin 群组设置管理员
func (*Bot) SetGroupAnonymous ¶
SetGroupAnonymous 群组匿名
func (*Bot) SetGroupAnonymousBan ¶
SetGroupAnonymousBan 群组匿名用户禁言,flag-需从群消息上报的 AnonymousMember 中获得,duration-禁言时长,单位秒,无法取消匿名用户禁言
func (*Bot) SetGroupBan ¶
SetGroupBan 群组单人禁言,duration-禁言时长,单位秒,0表示取消禁言
func (*Bot) SetGroupCard ¶
SetGroupCard 设置群名片(群备注),card-群名片内容,不填或空字符串表示删除群名片
func (*Bot) SetGroupKick ¶
SetGroupKick 群组踢人,rejectAddRequest-拒绝此人的加群请求
func (*Bot) SetGroupLeave ¶
SetGroupLeave 退出群,group-群号,isDismiss-是否解散
func (*Bot) SetGroupName ¶
SetGroupName 设置群名
func (*Bot) SetGroupSpecialTitle ¶
func (b *Bot) SetGroupSpecialTitle(groupId, userId int64, specialTitle string, duration int32) error
SetGroupSpecialTitle 设置群组专属头衔,specialTitle-专属头衔,不填或空字符串表示删除专属头衔,duration-专属头衔有效期,单位秒,-1表示永久,不过此项似乎没有效果,可能是只有某些特殊的时间长度有效,有待测试
func (*Bot) SetGroupWholeBan ¶
SetGroupWholeBan 群组全员禁言
func (*Bot) SetLimiter ¶
SetLimiter 设置限流器,limiterType为"wait"表示等待,为"drop"表示丢弃
func (*Bot) SetRestart ¶
SetRestart 重启OneBot实现,delay-要延迟的毫秒数,如果默认情况下无法重启,可以尝试设置延迟为2000左右。
由于重启 OneBot 实现同时需要重启 API 服务,这意味着当前的 API 请求会被中断,因此需要异步地重启,接口返回的 status 是 async。
type BotVersionInfo ¶
type Contact ¶
type Contact struct {
Type ContactType `json:"type"` // 类型
Id string `json:"id"` // QQ号或群号
}
Contact 推荐好友、推荐群
func (*Contact) GetMessageType ¶
type ContactType ¶
type ContactType string
const ( ContactTypeQQ ContactType = "qq" // 推荐好友 ContactTypeGroup ContactType = "group" // 推荐群 )
type Face ¶
type Face struct {
Id string `json:"id"` // QQ 表情 ID
}
Face QQ表情
func (*Face) GetMessageType ¶
type Forward ¶
type Forward struct {
Id string `json:"id"` // 合并转发 ID,需调用 Bot.GetForwardMessage 方法获取具体内容
}
Forward 合并转发
func (*Forward) GetMessageType ¶
type Friend ¶
type Friend struct {
UserId int64 `json:"user_id"` // QQ号
Nickname string `json:"nickname"` // 昵称
Remark string `json:"remark"` // 备注
}
Friend 好友
func (*Friend) RemarkOrNickname ¶
type FriendAddNotice ¶
type FriendAddNotice struct {
Time int64 `json:"time"` // 事件发生的时间戳
SelfId int64 `json:"self_id"` // 收到事件的机器人 QQ 号
PostType string `json:"post_type"` // "notice"
NoticeType string `json:"notice_type"` // "friend_add"
UserId int64 `json:"user_id"` // 新添加好友 QQ 号
}
FriendAddNotice 好友添加
type FriendRecallNotice ¶
type FriendRecallNotice struct {
Time int64 `json:"time"` // 事件发生的时间戳
SelfId int64 `json:"self_id"` // 收到事件的机器人 QQ 号
PostType string `json:"post_type"` // "notice"
NoticeType string `json:"notice_type"` // "friend_recall"
UserId int64 `json:"user_id"` // 好友 QQ 号
MessageId int64 `json:"message_id"` // 被撤回的消息 ID
}
FriendRecallNotice 好友消息撤回
type FriendRequest ¶
type FriendRequest struct {
Time int64 `json:"time"` // 事件发生的时间戳
SelfId int64 `json:"self_id"` // 收到事件的机器人 QQ 号
PostType string `json:"post_type"` // "request"
RequestType string `json:"request_type"` // "friend"
UserId int64 `json:"user_id"` // 发送请求的 QQ 号
Comment string `json:"comment"` // 验证信息
Flag string `json:"flag"` // 请求 flag,在调用处理请求的 API 时需要传入
}
FriendRequest 加好友请求
type Group ¶
type Group struct {
Id int64 `json:"id"` // 群号
Name string `json:"name"` // 群名称
Permission Role `json:"permission"` // Bot在群中的权限
}
Group 群
type GroupAdminNotice ¶
type GroupAdminNotice struct {
Time int64 `json:"time"` // 事件发生的时间戳
SelfId int64 `json:"self_id"` // 收到事件的机器人 QQ 号
PostType string `json:"post_type"` // "notice"
NoticeType string `json:"notice_type"` // "group_admin"
SubType GroupAdminNoticeSubType `json:"sub_type"` // 事件子类型
GroupId int64 `json:"group_id"` // 群号
UserId int64 `json:"user_id"` // 管理员 QQ 号
}
GroupAdminNotice 群管理员变动
type GroupAdminNoticeSubType ¶
type GroupAdminNoticeSubType string
const ( GroupAdminNoticeSet GroupAdminNoticeSubType = "set" // 设置管理员 GroupAdminNoticeUnset GroupAdminNoticeSubType = "unset" // 取消管理员 )
type GroupBanNotice ¶
type GroupBanNotice struct {
Time int64 `json:"time"` // 事件发生的时间戳
SelfId int64 `json:"self_id"` // 收到事件的机器人 QQ 号
PostType string `json:"post_type"` // "notice"
NoticeType string `json:"notice_type"` // "group_ban"
SubType GroupBanNoticeSubType `json:"sub_type"` // 事件子类型
GroupId int64 `json:"group_id"` // 群号
OperatorId int64 `json:"operator_id"` // 操作者 QQ 号
UserId int64 `json:"user_id"` // 加入者 QQ 号
Duration int64 `json:"duration"` // 禁言时长,单位秒
}
GroupBanNotice 群禁言
type GroupBanNoticeSubType ¶
type GroupBanNoticeSubType string
const ( GroupBanNoticeBan GroupBanNoticeSubType = "ban" // 禁言 GroupBanNoticeLiftBan GroupBanNoticeSubType = "lift_ban" // 解除禁言 )
type GroupDecreaseNotice ¶
type GroupDecreaseNotice struct {
Time int64 `json:"time"` // 事件发生的时间戳
SelfId int64 `json:"self_id"` // 收到事件的机器人 QQ 号
PostType string `json:"post_type"` // "notice"
NoticeType string `json:"notice_type"` // "group_decrease"
SubType GroupDecreaseNoticeSubType `json:"sub_type"` // 事件子类型
GroupId int64 `json:"group_id"` // 群号
OperatorId int64 `json:"operator_id"` // 操作者 QQ 号(如果是主动退群,则和 user_id 相同)
UserId int64 `json:"user_id"` // 离开者 QQ 号
}
GroupDecreaseNotice 群成员减少
type GroupDecreaseNoticeSubType ¶
type GroupDecreaseNoticeSubType string
const ( GroupDecreaseNoticeLeave GroupDecreaseNoticeSubType = "leave" // 主动退群 GroupDecreaseNoticeKick GroupDecreaseNoticeSubType = "kick" // 成员被踢 GroupDecreaseNoticeKickMe GroupDecreaseNoticeSubType = "kick_me" // 机器人被踢 )
type GroupIncreaseNotice ¶
type GroupIncreaseNotice struct {
Time int64 `json:"time"` // 事件发生的时间戳
SelfId int64 `json:"self_id"` // 收到事件的机器人 QQ 号
PostType string `json:"post_type"` // "notice"
NoticeType string `json:"notice_type"` // "group_increase"
SubType GroupIncreaseNoticeSubType `json:"sub_type"` // 事件子类型
GroupId int64 `json:"group_id"` // 群号
OperatorId int64 `json:"operator_id"` // 操作者 QQ 号(即管理员 QQ 号)
UserId int64 `json:"user_id"` // 加入者 QQ 号
}
GroupIncreaseNotice 群成员增加
type GroupIncreaseNoticeSubType ¶
type GroupIncreaseNoticeSubType string
const ( GroupIncreaseNoticeApprove GroupIncreaseNoticeSubType = "approve" // 管理员已同意入群 GroupIncreaseNoticeInvite GroupIncreaseNoticeSubType = "invite" // 管理员已邀请入群 )
type GroupMemberInfo ¶
type GroupMemberInfo struct {
GroupId int64 `json:"group_id"` // 群号
UserId int64 `json:"user_id"` // QQ 号
Nickname string `json:"nickname"` // 昵称
Card string `json:"card"` // 群名片/备注
Sex Sex `json:"sex"` // 性别
Age int32 `json:"age"` // 年龄
Area string `json:"area"` // 地区
JoinTime int32 `json:"join_time"` // 加群时间戳
LastSentTime int32 `json:"last_sent_time"` // 最后发言时间戳
Level json.Number `json:"level"` // 成员等级
Role Role `json:"role"` // 角色
Unfriendly bool `json:"unfriendly"` // 是否不良记录成员
Title string `json:"title"` // 专属头衔
TitleExpireTime int32 `json:"title_expire_time"` // 专属头衔过期时间戳
CardChangeable bool `json:"card_changeable"` // 是否允许修改群名片
}
func (*GroupMemberInfo) CardOrNickname ¶
func (m *GroupMemberInfo) CardOrNickname() string
type GroupMessage ¶
type GroupMessage struct {
Time int64 `json:"time"` // 事件发生的时间戳
SelfId int64 `json:"self_id"` // 收到事件的机器人 QQ 号
PostType string `json:"post_type"` // "message"
MessageType string `json:"message_type"` // "group"
SubType GroupMessageSubType `json:"sub_type"` // 消息子类型
MessageId int32 `json:"message_id"` // 消息 ID
GroupId int64 `json:"group_id"` // 群号
UserId int64 `json:"user_id"` // 发送者 QQ 号
Anonymous *AnonymousMember `json:"anonymous"` // 匿名信息,如果不是匿名消息则为 nil
Message MessageChain `json:"message"` // 消息内容
RawMessage string `json:"raw_message"` // 原始消息内容
Font int32 `json:"font"` // 字体
Sender Member `json:"sender"` // 发送人信息
}
GroupMessage 群消息
func (*GroupMessage) Ban ¶
func (m *GroupMessage) Ban(b *Bot, duration int32) error
Ban 把发送者禁言,对匿名用户也有效
func (*GroupMessage) Delete ¶
func (m *GroupMessage) Delete(b *Bot) error
Delete 撤回(需要权限),发送者是匿名用户时无效
func (*GroupMessage) Kick ¶
func (m *GroupMessage) Kick(b *Bot) error
Kick 把发送者踢出群组(需要权限),不拒绝此人后续加群请求,发送者是匿名用户时无效
func (*GroupMessage) Reply ¶
func (m *GroupMessage) Reply(b *Bot, reply MessageChain, atSender bool) error
Reply 回复
type GroupMessageSubType ¶
type GroupMessageSubType string
const ( GroupMessageNormal GroupMessageSubType = "normal" // 正常消息 GroupMessageAnonymous GroupMessageSubType = "anonymous" // 匿名消息 GroupMessageNotice GroupMessageSubType = "notice" // 系统提示 )
type GroupRecallNotice ¶
type GroupRecallNotice struct {
Time int64 `json:"time"` // 事件发生的时间戳
SelfId int64 `json:"self_id"` // 收到事件的机器人 QQ 号
PostType string `json:"post_type"` // "notice"
NoticeType string `json:"notice_type"` // "group_recall"
GroupId int64 `json:"group_id"` // 群号
UserId int64 `json:"user_id"` // 消息发送者 QQ 号
OperatorId int64 `json:"operator_id"` // 操作者 QQ 号
MessageId int64 `json:"message_id"` // 被撤回的消息 ID
}
GroupRecallNotice 群消息撤回
type GroupRequest ¶
type GroupRequest struct {
Time int64 `json:"time"` // 事件发生的时间戳
SelfId int64 `json:"self_id"` // 收到事件的机器人 QQ 号
PostType string `json:"post_type"` // "request"
RequestType string `json:"request_type"` // "group"
SubType GroupRequestSubType `json:"sub_type"` // 请求子类型
GroupId int64 `json:"group_id"` // 群号
UserId int64 `json:"user_id"` // 发送请求的 QQ 号
Comment string `json:"comment"` // 验证信息
Flag string `json:"flag"` // 请求 flag,在调用处理请求的 API 时需要传入
}
GroupRequest 加群请求/邀请
type GroupRequestSubType ¶
type GroupRequestSubType string
const ( GroupRequestAdd GroupRequestSubType = "add" // 加群请求 GroupRequestInvite GroupRequestSubType = "invite" // 邀请入群 )
type GroupUploadNotice ¶
type GroupUploadNotice struct {
Time int64 `json:"time"` // 事件发生的时间戳
SelfId int64 `json:"self_id"` // 收到事件的机器人 QQ 号
PostType string `json:"post_type"` // "notice"
NoticeType string `json:"notice_type"` // "group_upload"
GroupId int64 `json:"group_id"` // 群号
UserId int64 `json:"user_id"` // 发送者 QQ 号
File File `json:"file"` // 文件信息
}
GroupUploadNotice 群文件上传
type HeartbeatMetaEvent ¶
type HeartbeatMetaEvent struct {
Time int64 `json:"time"` // 事件发生的时间戳
SelfId int64 `json:"self_id"` // 收到事件的机器人 QQ 号
PostType string `json:"post_type"` // "meta_event"
MetaEventType string `json:"meta_event_type"` // "heartbeat"
Status BotStatus `json:"status"` // 状态信息
Interval int64 `json:"interval"` // 到下次心跳的间隔,单位毫秒
}
HeartbeatMetaEvent 心跳事件
type Image ¶
type Image struct {
// 图片文件名
//
// 当发送图片时,除了可以直接使用收到的文件名直接发送以外,还支持:
//
// 绝对路径,格式使用file URI;
// 网络URL,格式为http://xxx;
// Base64编码,格式为base64://<base64编码>。
File string `json:"file"`
// 图片类型,"flash"表示闪照,无此参数表示普通图片
Type string `json:"type,omitempty"`
// 图片的URL,只有在收图片时才有这个字段
Url string `json:"url,omitempty"`
// 以下字段只在通过网络URL发送时有效
Cache string `json:"cache,omitempty"` // 1和0表示是否使用已缓存的文件,默认是
Proxy string `json:"proxy,omitempty"` // 1和0表示是否通过代理下载文件(需通过环境变量或配置文件配置代理),默认是
Timeout string `json:"timeout,omitempty"` // 单位秒,表示下载网络文件的超时时间,默认不超时
}
Image 图片
func (*Image) GetMessageType ¶
type LifecycleMetaEvent ¶
type LifecycleMetaEvent struct {
Time int64 `json:"time"` // 事件发生的时间戳
SelfId int64 `json:"self_id"` // 收到事件的机器人 QQ 号
PostType string `json:"post_type"` // "meta_event"
MetaEventType string `json:"meta_event_type"` // "lifecycle"
SubType LifecycleMetaEventSubType `json:"sub_type"` // 请求子类型
}
LifecycleMetaEvent 生命周期事件
type LifecycleMetaEventSubType ¶
type LifecycleMetaEventSubType string
const ( LifecycleMetaEventEnable LifecycleMetaEventSubType = "enable" // OneBot启用 LifecycleMetaEventDisable LifecycleMetaEventSubType = "disable" // OneBot停用 LifecycleMetaEventConnect LifecycleMetaEventSubType = "connect" // WebSocket连接成功 )
type Location ¶
type Location struct {
Lat string `json:"lat"` // 纬度
Lon string `json:"lon"` // 经度
Title string `json:"title,omitempty"` // 标题,发送时可不填
Content string `json:"content,omitempty"` // 内容描述,发送时可不填
}
Location 位置
func (*Location) GetMessageType ¶
type Member ¶
type Member struct {
UserId int64 `json:"user_id"` // QQ号
Nickname string `json:"nickname"` // 昵称
Card string `json:"card"` // 群名片/备注
Sex Sex `json:"sex"` // 性别
Age int32 `json:"age"` // 年龄
Area string `json:"area"` // 地区
Level string `json:"level"` // 成员等级
Role Role `json:"role"` // 角色
}
Member 群成员
func (*Member) CardOrNickname ¶
type Message ¶
type Message struct {
Time int32 `json:"time"` // 发送时间
MessageType MessageType `json:"message_type"` // 消息类型
MessageId int32 `json:"message_id"` // 消息ID
RealId int32 `json:"real_id"` // 消息真实ID
Sender Profile `json:"sender"` // 发送人信息
Message MessageChain `json:"message"` // 消息内容
}
type MessageChain ¶
type MessageChain []SingleMessage
func (*MessageChain) MarshalJSON ¶
func (c *MessageChain) MarshalJSON() ([]byte, error)
func (*MessageChain) UnmarshalJSON ¶
func (c *MessageChain) UnmarshalJSON(data []byte) error
type MessageType ¶
type MessageType string
const ( MessageTypePrivate MessageType = "private" // 私聊消息 MessageTypeGroup MessageType = "group" // 群消息 )
type Music ¶
type Music struct {
// "qq": QQ音乐, "163": 网易云音乐, "xm": 虾米音乐, "custom": 音乐自定义分享
Type string `json:"type"`
// 歌曲ID,用于非自定义分享
Id string `json:"id,omitempty"`
Url string `json:"url,omitempty"` // 点击后跳转目标 URL
Audio string `json:"audio,omitempty"` // 音乐 URL
Title string `json:"title,omitempty"` // 标题
Content string `json:"content,omitempty"` // 内容描述,发送时可不填
Image string `json:"image,omitempty"` // 图片URL,发送时可不填
}
Music 音乐分享
func (*Music) GetMessageType ¶
type Node ¶
type Node struct {
Id string `json:"id,omitempty"` // 转发的消息 ID
UserId string `json:"user_id,omitempty"` // 发送者 QQ 号
Nickname string `json:"nickname,omitempty"` // 发送者昵称
Content MessageChain `json:"content,omitempty"` // 消息内容
}
Node 合并转发节点
func (*Node) GetMessageType ¶
type NotifyNotice ¶
type NotifyNotice struct {
Time int64 `json:"time"` // 事件发生的时间戳
SelfId int64 `json:"self_id"` // 收到事件的机器人 QQ 号
PostType string `json:"post_type"` // "notice"
NoticeType string `json:"notice_type"` // "notify"
SubType NotifyNoticeSubType `json:"sub_type"` // 事件子类型
GroupId int64 `json:"group_id"` // 群号
HonorType NotifyNoticeHonorType `json:"honor_type,omitempty"` // (群成员荣誉变更)荣誉类型
UserId int64 `json:"user_id"` // (戳一戳)发送者/(红包)发送者/(荣誉变更)成员 QQ 号
TargetId int64 `json:"target_id,omitempty"` // (戳一戳)被戳者/(红包)运气王 QQ 号
}
NotifyNotice 其它通知
type NotifyNoticeHonorType ¶
type NotifyNoticeHonorType string
type NotifyNoticeSubType ¶
type NotifyNoticeSubType string
const ( NotifyNoticePoke NotifyNoticeSubType = "poke" // 群内戳一戳 NotifyNoticeLuckyKing NotifyNoticeSubType = "lucky_king" // 群红包运气王 NotifyNoticeHonor NotifyNoticeSubType = "honor" // 群成员荣誉变更 )
const ( NotifyNoticeNone NotifyNoticeSubType = "" NotifyNoticeTalkative NotifyNoticeSubType = "talkative" // 龙王 NotifyNoticePerformer NotifyNoticeSubType = "performer" // 群聊之火 NotifyNoticeEmotion NotifyNoticeSubType = "emotion" // 快乐源泉 )
type Poke ¶
type Poke struct {
Type string `json:"type"`
Id string `json:"id"`
Name string `json:"name,omitempty"` // 表情名,发送时无需此字段
}
Poke 戳一戳,字段含义参考文档
https://github.com/botuniverse/onebot-11/blob/master/message/segment.md#%E6%88%B3%E4%B8%80%E6%88%B3
func (*Poke) GetMessageType ¶
type PrivateMessage ¶
type PrivateMessage struct {
Time int64 `json:"time"` // 事件发生的时间戳
SelfId int64 `json:"self_id"` // 收到事件的机器人 QQ 号
PostType string `json:"post_type"` // "message"
MessageType string `json:"message_type"` // "private"
SubType PrivateMessageSubType `json:"sub_type"` // 消息子类型
MessageId int32 `json:"message_id"` // 消息 ID
UserId int64 `json:"user_id"` // 发送者 QQ 号
Message MessageChain `json:"message"` // 消息内容
RawMessage string `json:"raw_message"` // 原始消息内容
Font int32 `json:"font"` // 字体
Sender Profile `json:"sender"` // 发送人信息
}
PrivateMessage 私聊消息
func (*PrivateMessage) Reply ¶
func (m *PrivateMessage) Reply(b *Bot, reply MessageChain) error
Reply 回复
type PrivateMessageSubType ¶
type PrivateMessageSubType string
const ( PrivateMessageFriend PrivateMessageSubType = "friend" // 好友私聊 PrivateMessageGroup PrivateMessageSubType = "group" // 群私聊 PrivateMessageOther PrivateMessageSubType = "other" // 其它 )
type Profile ¶
type Profile struct {
UserId int64 `json:"user_id"` // QQ号
Nickname string `json:"nickname"` // 昵称
Sex Sex `json:"sex"` // 性别
Age int32 `json:"age"` // 年龄
}
Profile 用户资料
type Record ¶
type Record struct {
// 语音文件名
//
// 当发送语音时,除了可以直接使用收到的文件名直接发送以外,还支持:
//
// 绝对路径,格式使用file URI;
// 网络URL,格式为http://xxx;
// Base64编码,格式为base64://<base64编码>。
File string `json:"file"`
// 发送时可选,是否变声
Magic bool `json:"magic,omitempty"`
// 语音的URL,只有在收语音时才有这个字段
Url string `json:"url,omitempty"`
// 以下字段只在通过网络URL发送时有效
Cache string `json:"cache,omitempty"` // 1和0表示是否使用已缓存的文件,默认是
Proxy string `json:"proxy,omitempty"` // 1和0表示是否通过代理下载文件(需通过环境变量或配置文件配置代理),默认是
Timeout string `json:"timeout,omitempty"` // 单位秒,表示下载网络文件的超时时间,默认不超时
}
Record 语音
func (*Record) GetMessageType ¶
type Reply ¶
type Reply struct {
Id string `json:"id"` // 回复时引用的消息 ID
}
Reply 回复
func (*Reply) GetMessageType ¶
type SingleMessage ¶
type SingleMessage interface {
GetMessageType() string
}
type Text ¶
type Text struct {
Text string `json:"text"` // 文字消息
}
Text 纯文本
func (*Text) GetMessageType ¶
type Video ¶
type Video struct {
// 短视频文件名
//
// 当发送短视频时,除了可以直接使用收到的文件名直接发送以外,还支持:
//
// 绝对路径,格式使用file URI;
// 网络URL,格式为http://xxx;
// Base64编码,格式为base64://<base64编码>。
File string `json:"file"`
// 短视频的URL,只有在收短视频时才有这个字段
Url string `json:"url,omitempty"`
// 以下字段只在通过网络URL发送时有效
Cache string `json:"cache,omitempty"` // 1和0表示是否使用已缓存的文件,默认是
Proxy string `json:"proxy,omitempty"` // 1和0表示是否通过代理下载文件(需通过环境变量或配置文件配置代理),默认是
Timeout string `json:"timeout,omitempty"` // 单位秒,表示下载网络文件的超时时间,默认不超时
}
Video 短视频