Documentation
¶
Index ¶
- Constants
- Variables
- func CheckPath(path string) error
- func ConnectWS(url url.URL) (*websocket.Conn, *http.Response, error)
- func DeleteMsg(message_id int32) error
- func GetForwardMsg(id string) (map[string]interface{}, error)
- func GetFriendList() (map[string]interface{}, error)
- func GetGroupHonorInfo(group_id int64, type_ int) (map[string]interface{}, error)
- func GetGroupInfo(group_id int64, no_cache bool) (map[string]interface{}, error)
- func GetGroupList() (map[string]interface{}, error)
- func GetGroupMemberInfo(group_id int64, user_id int64, no_cache bool) (map[string]interface{}, error)
- func GetGroupMemberList(group_id int64) (map[string]interface{}, error)
- func GetImage(file string) (map[string]interface{}, error)
- func GetLoginInfo() (map[string]interface{}, error)
- func GetMsg(message_id int32) (map[string]interface{}, error)
- func GetStrangerInfo(user_id int64, no_cache bool) (map[string]interface{}, error)
- func InitLogger(lvl int)
- func OCRImage(image string) (map[string]interface{}, error)
- func SendGroupMsg(message string, group_id int64) (map[string]interface{}, error)
- func SendLike(user_id int64, times int64) error
- func SendMsg(msgtype string, message string, toid int64) (map[string]interface{}, error)
- func SendPrivateMsg(message string, user_id int64) (map[string]interface{}, error)
- func SetFriendAddRequest(flag string, approve bool) error
- func SetGroupAddRequest(flag string, approve bool, reason string) error
- func SetGroupAdmin(group_id int64, user_id int64, enable bool) error
- func SetGroupAnonymous(group_id int64, enable bool) error
- func SetGroupAnonymousBan(group_id int64, anymous_flag string, duration int64) error
- func SetGroupBan(group_id int64, user_id int64, duration int64) error
- func SetGroupCard(group_id int64, user_id int64, card string) error
- func SetGroupInviteRequest(flag string, approve bool, reason string) error
- func SetGroupKick(group_id int64, user_id int64, reject_add_request bool) error
- func SetGroupLeave(group_id int64, is_dismiss bool) error
- func SetGroupName(group_id int64, group_name string) error
- func SetGroupSpecialTitle(group_id int64, user_id int64, special_title string) error
- func SetGroupWholeBan(group_id int64, enable bool) error
- type Bot
- type Config
- type FriendAdd
- type FriendRecall
- type FriendRequest
- type GroupAdmin
- type GroupBan
- type GroupDecrease
- type GroupIncrease
- type GroupRecall
- type GroupRequest
- type GroupUpload
- type LongEvent
- type MessageGroup
- type MessagePrivate
- type MetaHeartbeat
- type MetaLifecycle
- type Notify
- type Plugin
- type ShortEvent
Constants ¶
const ( LOGGER_LEVEL_EMERGENCY = iota // 系统级紧急,比如磁盘出错,内存异常,网络不可用等 LOGGER_LEVEL_ALERT // 系统级警告,比如数据库访问异常,配置文件出错等 LOGGER_LEVEL_CRITICAL // 系统级危险,比如权限出错,访问异常等 LOGGER_LEVEL_ERROR // 用户级错误 LOGGER_LEVEL_WARNING // 用户级警告 LOGGER_LEVEL_NOTICE // 用户级重要 LOGGER_LEVEL_INFO // 用户级提示 LOGGER_LEVEL_DEBUG // 用户级调试 )
Variables ¶
var Connect *websocket.Conn // Websocket 连接接口
var Listeners listeners // Listeners 监听器
var Logger *go_logger.Logger
日志接口
var LongEvents = make(map[string]LongEvent) // 长事件容器
var ShortEvents = make(map[string]ShortEvent) // 短事件容器
Functions ¶
func GetForwardMsg ¶
GetForwardMsg 获取合并转发消息 id - 合并转发 ID return message err
func GetFriendList ¶ added in v0.3.7
GetFriendList 获取好友列表 return [{user_id nickname}] err
func GetGroupHonorInfo ¶ added in v0.3.7
GetGroupHonorInfo 获取群荣誉信息 group_id 群号 type 荣誉类型
func GetGroupInfo ¶ added in v0.3.7
GetGroupInfo 获取群信息 group_id 群号 no_cache 是否不使用缓存(使用缓存可能更新不及时,但响应更快)
func GetGroupList ¶ added in v0.3.7
GetGroupList 获取群列表 return [{group_id name}] err
func GetGroupMemberInfo ¶ added in v0.3.7
func GetGroupMemberInfo(group_id int64, user_id int64, no_cache bool) (map[string]interface{}, error)
GetGroupMemberInfo 获取群成员信息 group_id 群号 user_id 成员QQ no_cache 是否不使用缓存(使用缓存可能更新不及时,但响应更快)
func GetGroupMemberList ¶ added in v0.3.7
GetGroupMemberList 获取群成员列表 group_id 群号
func GetImage ¶
GetImage 获取图片信息 file string get_image return size int32 图片源文件大小
filename string 图片文件原名 url string 图片下载地址 err
func GetLoginInfo ¶
GetLoginInfo 获取登录号信息 return {user_id nickname} err
func GetMsg ¶
GetMsg 获取消息 message_id - 获取消息 return {time message_type message_id real_id sender message} error
func GetStrangerInfo ¶ added in v0.3.7
GetStrangerInfo 获取陌生人信息 user_id 陌生人QQ no_cache 是否不使用缓存(使用缓存可能更新不及时,但响应更快)
func InitLogger ¶
func InitLogger(lvl int)
func OCRImage ¶
OCRImage 图片OCR image file - string return texts TextDetection[] OCR结果
- text string 文本
- confidence int32 置信度
- coordinates vector2 坐标 language string 语言 err
func SendGroupMsg ¶
SendGroupMsg 发送群聊消息 message - 要发送的内容 group_id - 群号 return message_id error
func SendMsg ¶
SendMsg 发送消息 msgtype - 消息类型 group/private message - 消息内容 toid - 群号/QQ号 本条API并不是 Onebot/CQhttp 原生API return message_id error
func SendPrivateMsg ¶
SendPrivateMsg 发送私聊信息 message - 消息内容 自动解析CQ码 user_id - 对方QQ号 return message_id error
func SetFriendAddRequest ¶
SetFriendAddRequest 处理加好友请求 flag 加好友请求的 flag(需从上报的数据中获得) approve 是否同意请求 return err
func SetGroupAddRequest ¶
SetGroupAddRequest 处理加群请求 flag 加群请求的 flag approve 是否同意请求 reason 拒绝理由(只有在拒绝时有效) return err
func SetGroupAdmin ¶
SetGroupAdmin 群组设置管理员(需要机器人为群主) group_id 群号 user_id QQ号 enable true 为设置,false 为取消 return err
func SetGroupAnonymous ¶
SetGroupAnonymous 群组匿名 group_id 群号 enable 是否允许匿名聊天 return err
func SetGroupAnonymousBan ¶
SetGroupAnonymousBan 群组匿名用户禁言 group_id - 群号 anymous_flag - 匿名用户的 flag(需从群消息上报的数据中获得) duration - 禁言时长(s) 0表示取消禁言 return err
func SetGroupBan ¶
SetGroupBan 群组单人禁言 group_id - 群号 user_id - 要禁言的QQ号 duration - 禁言时长(s) 0表示取消禁言 return err
func SetGroupCard ¶
SetGroupCard 设置群名片 group_id 群号 user_id 成员QQ card 空字符串表示删除群名片 return err
func SetGroupInviteRequest ¶
SetGroupInviteRequest 处理加群邀请 flag 加群邀请的 flag approve 是否同意邀请 reason 拒绝理由(只有在拒绝时有效) return err
func SetGroupKick ¶
SetGroupKick 群组踢人 group_id - 群号 user_id - 要踢的 QQ 号 reject_add_request - 是否拒绝再次入群 return err
func SetGroupLeave ¶
SetGroupLeave 退群 group_id 群号 is_dismiss 是否解散,如果登录号是群主,则仅在此项为 true 时能够解散 return err
func SetGroupName ¶
SetGroupName 设置群名 group_id 群号 group_name 新群名 return err
func SetGroupSpecialTitle ¶
SetGroupSpecialTitle 设置群组专属头衔 group_id 群号 user_id 成员QQ special_title 空字符串表示删除专属头衔 return err
func SetGroupWholeBan ¶
SetGroupWholeBan 群全员禁言 group_id 群号 enable 是否禁言 return err
Types ¶
type FriendAdd ¶
type FriendAdd struct {
Time int64 // 事件发生的时间戳
SelfId int64 // 收到事件的机器人 QQ 号
UserId int64 // 新添加好友 QQ 号
}
FriendAdd 添加好友
type FriendRecall ¶
type FriendRecall struct {
Time int64 // 事件发生的时间戳
SelfId int64 // 收到事件的机器人 QQ 号
UserId int64 // 消息发送者 QQ 号
MessageId int64 // 被撤回的消息 ID
}
FriendRecall 私聊撤回消息
type FriendRequest ¶
type FriendRequest struct {
Time int64 // 事件发生的时间戳
SelfId int64 // 收到事件的机器人 QQ 号
UserId int64 // 发送请求的 QQ 号
Comment string // 验证信息
Flag string // 请求 flag,在调用处理请求的 API 时需要传入
}
FriendRequest 好友申请
type GroupAdmin ¶
type GroupAdmin struct {
Time int64 // 事件发生的时间戳
SelfId int64 // 收到事件的机器人 QQ 号
SubType string // set|unset 事件子类型,分别表示设置和取消管理员
GroupId int64 // 群号
UserId int64 // 管理员 QQ 号
}
GroupAdmin 管理员变更
type GroupBan ¶
type GroupBan struct {
Time int64 // 事件发生的时间戳
SelfId int64 // 收到事件的机器人 QQ 号
SubType string // ban、lift_ban 事件子类型,分别表示禁言、解除禁言
GroupId int64 // 群号
OperatorId int64 // 操作者 QQ 号
UserId int64 // 被禁言 QQ 号
Duration int64 // 禁言时长,单位秒
}
GroupBan 成员禁言
type GroupDecrease ¶
type GroupDecrease struct {
Time int64 // 事件发生的时间戳
SelfId int64 // 收到事件的机器人 QQ 号
SubType string // leave|kick|kick_me 事件子类型,分别表示主动退群、成员被踢、登录号被踢
GroupId int64 // 群号
OperatorId int64 // 操作者 QQ 号(如果是主动退群,则和 user_id 相同)
UserId int64 // 离开者 QQ 号
}
GroupDecrease 成员离开群聊
type GroupIncrease ¶
type GroupIncrease struct {
Time int64 // 事件发生的时间戳
SelfId int64 // 收到事件的机器人 QQ 号
SubType string // approve|invite 事件子类型,分别表示管理员已同意入群、管理员邀请入群
GroupId int64 // 群号
OperatorId int64 // 操作者 QQ 号
UserId int64 // 加入者 QQ 号
}
GroupIncrease 成员加入群聊
type GroupRecall ¶
type GroupRecall struct {
Time int64 // 事件发生的时间戳
SelfId int64 // 收到事件的机器人 QQ 号
GroupId int64 // 群号
UserId int64 // 消息发送者 QQ 号
OperatorId int64 // 操作者 QQ 号
MessageId int64 // 被撤回的消息 ID
}
GroupRecall 群聊撤回消息
type GroupRequest ¶
type GroupRequest struct {
Time int64 // 事件发生的时间戳
SelfId int64 // 收到事件的机器人 QQ 号
SubType string // add、invite 请求子类型,分别表示加群请求、邀请登录号入群
GroupId int64 // 群号
UserId int64 // 发送请求的 QQ 号
Comment string // 验证信息
Flag string // 请求 flag,在调用处理请求的 API 时需要传入
}
GroupRequest 群聊邀请
type GroupUpload ¶
type GroupUpload struct {
Time int64 // 事件发生的时间戳
SelfId int64 // 收到事件的机器人 QQ 号
GroupId int64 // 群号
UserId int64 // 发送者 QQ 号
File struct {
Id string // 文件 ID
Name string // 文件名
Size int64 // 文件大小(字节数)
Busid int64 // busid(目前不清楚有什么作用)
} // 文件信息
}
GroupUpload 上传群文件
type LongEvent ¶
type LongEvent struct {
UserID int64
GroupID int64
Channel *chan string
EventKey string
EventID string
}
type MessageGroup ¶
type MessageGroup struct {
SelfID int64 // 收到事件的机器人 QQ 号
SubType string // 消息子类型 正常消息是 normal 匿名消息是 anonymous 系统提示是 notice
MessageID int64 // 消息 ID
GroupID int64 // 群号
UserID int64 // 发送者 QQ 号
Anonymous struct {
Id int64 // 匿名用户 ID
Name string // 匿名用户名称
Flag string // 匿名用户 flag,在调用禁言 API 时需要传入
} // 匿名信息,如果不是匿名消息则为 null
Message string // 消息内容
RawMessage string // 原始消息内容
Sender struct {
UserID int64 // 发送者 QQ 号
Nickname string // 昵称
Card string // 群名片/备注
Sex string // 性别,male 或 female 或 unknown
Age int64 // 年龄
Area string // 地区
Level string // 成员等级
Role string // 角色,owner 或 admin 或 member
Title string // 专属头衔
} // 发送人信息
}
MessageGroup 群聊消息事件
type MessagePrivate ¶
type MessagePrivate struct {
SelfID int64 // 收到事件的机器人 QQ 号
SubType string // 消息子类型(friend,group,other)
MessageID int64 // 消息id
UserID int64 // 发送者 QQ 号
Message string // 消息内容
RawMessage string // 原始消息内容
Sender struct {
UserID int64 // 发送者 QQ 号
Nickname string // 昵称
Sex string // 性别,male 或 female 或 unknown
Age int64 // 年龄
} // 发送人信息
}
MessagePrivate 私聊消息事件
type MetaHeartbeat ¶
type MetaHeartbeat struct {
Time int64 // 事件发生的时间戳
SelfId int64 // 收到事件的机器人 QQ 号
Status interface{} // 状态信息
Interval int64 // 到下次心跳的间隔,单位毫秒
}
MetaHeartbeat 心跳包
type MetaLifecycle ¶
type MetaLifecycle struct {
Time int64 // 事件发生的时间戳
SelfId int64 // 收到事件的机器人 QQ 号
SubType string // enable、disable、connect 事件子类型,分别表示 OneBot 启用、停用、WebSocket 连接成功
}
* Meta Event Part MetaLifecycle 生命周期
type Notify ¶
type Notify struct {
Time int64 // 事件发生的时间戳
SelfId int64 // 收到事件的机器人 QQ 号
SubType string // poke|lucky_king|honor 提示类型:戳一戳|红包运气王|荣誉
GroupId int64 // 群号
UserId int64 // 发送者 QQ 号|红包发送者 QQ 号|成员 QQ 号
TargetId int64 // 被戳者 QQ 号|运气王 QQ 号 //!仅在戳一戳|运气王事件中有值
Honor_type string // talkative|performer|emotion 荣誉类型:龙王|群聊之火|快乐源泉 //!仅在荣誉事件中有值
}
Notify 群聊提醒类消息