Documentation
¶
Overview ¶
Package coolq 包含CQBot实例,CQ码处理,消息发送,消息处理等的相关函数与结构体
Index ¶
- Variables
- func CQCodeEscapeText(raw string) string
- func CQCodeEscapeValue(value string) string
- func CQCodeUnescapeText(content string) string
- func CQCodeUnescapeValue(content string) string
- func SetMessageFormat(f string)
- func ToFormattedMessage(e []message.IMessageElement, id int64, isRaw ...bool) (r interface{})
- func ToStringMessage(e []message.IMessageElement, id int64, isRaw ...bool) (r string)
- func XMLEscape(c string) string
- type CQBot
- func (bot *CQBot) CQCanSendImage() MSG
- func (bot *CQBot) CQCanSendRecord() MSG
- func (bot *CQBot) CQCheckURLSafely(url string) MSG
- func (bot *CQBot) CQDeleteEssenceMessage(messageID int32) MSG
- func (bot *CQBot) CQDeleteMessage(messageID int32) MSG
- func (bot *CQBot) CQDownloadFile(url string, headers map[string]string, threadCount int) MSG
- func (bot *CQBot) CQGetAtAllRemain(groupID int64) MSG
- func (bot *CQBot) CQGetCSRFToken() MSG
- func (bot *CQBot) CQGetCookies(domain string) MSG
- func (bot *CQBot) CQGetCredentials(domain string) MSG
- func (bot *CQBot) CQGetEssenceMessageList(groupCode int64) MSG
- func (bot *CQBot) CQGetForwardMessage(resID string) MSG
- func (bot *CQBot) CQGetFriendList() MSG
- func (bot *CQBot) CQGetGroupFileSystemInfo(groupID int64) MSG
- func (bot *CQBot) CQGetGroupFileURL(groupID int64, fileID string, busID int32) MSG
- func (bot *CQBot) CQGetGroupFilesByFolderID(groupID int64, folderID string) MSG
- func (bot *CQBot) CQGetGroupHonorInfo(groupID int64, t string) MSG
- func (bot *CQBot) CQGetGroupInfo(groupID int64, noCache bool) MSG
- func (bot *CQBot) CQGetGroupList(noCache bool) MSG
- func (bot *CQBot) CQGetGroupMemberInfo(groupID, userID int64, noCache bool) MSG
- func (bot *CQBot) CQGetGroupMemberList(groupID int64, noCache bool) MSG
- func (bot *CQBot) CQGetGroupMessageHistory(groupID int64, seq int64) MSG
- func (bot *CQBot) CQGetGroupRootFiles(groupID int64) MSG
- func (bot *CQBot) CQGetGroupSystemMessages() MSG
- func (bot *CQBot) CQGetImage(file string) MSG
- func (bot *CQBot) CQGetLoginInfo() MSG
- func (bot *CQBot) CQGetMessage(messageID int32) MSG
- func (bot *CQBot) CQGetModelShow(modelName string) MSG
- func (bot *CQBot) CQGetOnlineClients(noCache bool) MSG
- func (bot *CQBot) CQGetQiDianAccountInfo() MSG
- func (bot *CQBot) CQGetStatus() MSG
- func (bot *CQBot) CQGetStrangerInfo(userID int64) MSG
- func (bot *CQBot) CQGetVersionInfo() MSG
- func (bot *CQBot) CQGetVipInfo(userID int64) MSG
- func (bot *CQBot) CQGetWordSlices(content string) MSG
- func (bot *CQBot) CQGroupFileCreateFolder(groupID int64, parentID, name string) MSG
- func (bot *CQBot) CQGroupFileDeleteFile(groupID int64, parentID, id string, busID int32) MSG
- func (bot *CQBot) CQGroupFileDeleteFolder(groupID int64, id string) MSG
- func (bot *CQBot) CQHandleQuickOperation(context, operation gjson.Result) MSG
- func (bot *CQBot) CQOcrImage(imageID string) MSG
- func (bot *CQBot) CQProcessFriendRequest(flag string, approve bool) MSG
- func (bot *CQBot) CQProcessGroupRequest(flag, subType, reason string, approve bool) MSG
- func (bot *CQBot) CQSendGroupForwardMessage(groupID int64, m gjson.Result) MSG
- func (bot *CQBot) CQSendGroupMessage(groupID int64, i interface{}, autoEscape bool) MSG
- func (bot *CQBot) CQSendPrivateMessage(userID int64, groupID int64, i interface{}, autoEscape bool) MSG
- func (bot *CQBot) CQSetEssenceMessage(messageID int32) MSG
- func (bot *CQBot) CQSetGroupAdmin(groupID, userID int64, enable bool) MSG
- func (bot *CQBot) CQSetGroupAnonymousBan(groupID int64, flag string, duration int32) MSG
- func (bot *CQBot) CQSetGroupBan(groupID, userID int64, duration uint32) MSG
- func (bot *CQBot) CQSetGroupCard(groupID, userID int64, card string) MSG
- func (bot *CQBot) CQSetGroupKick(groupID, userID int64, msg string, block bool) MSG
- func (bot *CQBot) CQSetGroupLeave(groupID int64) MSG
- func (bot *CQBot) CQSetGroupMemo(groupID int64, msg string, img string) MSG
- func (bot *CQBot) CQSetGroupName(groupID int64, name string) MSG
- func (bot *CQBot) CQSetGroupPortrait(groupID int64, file, cache string) MSG
- func (bot *CQBot) CQSetGroupSpecialTitle(groupID, userID int64, title string) MSG
- func (bot *CQBot) CQSetGroupWholeBan(groupID int64, enable bool) MSG
- func (bot *CQBot) CQSetModelShow(modelName string, modelShow string) MSG
- func (bot *CQBot) CQUploadGroupFile(groupID int64, file, name, folder string) MSG
- func (bot *CQBot) ConvertObjectMessage(m gjson.Result, isGroup bool) (r []message.IMessageElement)
- func (bot *CQBot) ConvertStringMessage(raw string, isGroup bool) (r []message.IMessageElement)
- func (bot *CQBot) GetMessage(mid int32) MSG
- func (bot *CQBot) InsertGroupMessage(m *message.GroupMessage) int32
- func (bot *CQBot) InsertPrivateMessage(m *message.PrivateMessage) int32
- func (bot *CQBot) InsertTempMessage(target int64, m *message.TempMessage) int32
- func (bot *CQBot) OnEventPush(f func(buf *bytes.Buffer))
- func (bot *CQBot) Release()
- func (bot *CQBot) SendGroupMessage(groupID int64, m *message.SendingMessage) int32
- func (bot *CQBot) SendPrivateMessage(target int64, groupID int64, m *message.SendingMessage) int32
- func (bot *CQBot) ToElement(t string, d map[string]string, isGroup bool) (m interface{}, err error)
- func (bot *CQBot) UploadLocalImageAsGroup(groupCode int64, img *LocalImageElement) (*message.GroupImageElement, error)
- func (bot *CQBot) UploadLocalImageAsPrivate(userID int64, img *LocalImageElement) (*message.FriendImageElement, error)
- func (bot *CQBot) UploadLocalVideo(target int64, v *LocalVideoElement) (*message.ShortVideoElement, error)
- type GiftElement
- type LocalImageElement
- type LocalVideoElement
- type LocalVoiceElement
- type MSG
- type PokeElement
Constants ¶
This section is empty.
Variables ¶
var ExtraReplyData bool
ExtraReplyData 是否上报额外reply信息
var ForceFragmented = false
ForceFragmented 是否启用强制分片
var GiftID = [...]message.GroupGift{ message.SweetWink, message.HappyCola, message.LuckyBracelet, message.Cappuccino, message.CatWatch, message.FleeceGloves, message.RainbowCandy, message.Stronger, message.LoveMicrophone, message.HoldingYourHand, message.CuteCat, message.MysteryMask, message.ImBusy, message.LoveMask, }
GiftID 礼物ID数组
var IgnoreInvalidCQCode = false
IgnoreInvalidCQCode 是否忽略无效CQ码
var RemoveReplyAt bool
RemoveReplyAt 是否删除reply后的at
var SplitURL = false
SplitURL 是否分割URL
var Version = "unknown"
Version go-cqhttp的版本信息,在编译时使用ldflags进行覆盖
Functions ¶
func CQCodeEscapeValue ¶
CQCodeEscapeValue 将字符串value中部分字符转义
, -> ,
& -> &
[ -> [
] -> ]
func CQCodeUnescapeValue ¶
CQCodeUnescapeValue 将字符串content中部分字符反转义
, -> ,
& -> &
[ -> [
] -> ]
func ToFormattedMessage ¶
func ToFormattedMessage(e []message.IMessageElement, id int64, isRaw ...bool) (r interface{})
ToFormattedMessage 将给定[]message.IMessageElement转换为通过coolq.SetMessageFormat所定义的消息上报格式
func ToStringMessage ¶
func ToStringMessage(e []message.IMessageElement, id int64, isRaw ...bool) (r string)
ToStringMessage 将消息元素数组转为字符串以用于消息上报
Types ¶
type CQBot ¶
CQBot CQBot结构体,存储Bot实例相关配置
func (*CQBot) CQCanSendImage ¶
CQCanSendImage 检查是否可以发送图片(此处永远返回true)
func (*CQBot) CQCanSendRecord ¶
CQCanSendRecord 检查是否可以发送语音(此处永远返回true)
func (*CQBot) CQCheckURLSafely ¶
CQCheckURLSafely 扩展API-检查链接安全性
https://docs.go-cqhttp.org/api/#%E6%A3%80%E6%9F%A5%E9%93%BE%E6%8E%A5%E5%AE%89%E5%85%A8%E6%80%A7
func (*CQBot) CQDeleteEssenceMessage ¶
CQDeleteEssenceMessage 扩展API-移出精华消息
https://docs.go-cqhttp.org/api/#%E7%A7%BB%E5%87%BA%E7%B2%BE%E5%8D%8E%E6%B6%88%E6%81%AF
func (*CQBot) CQDownloadFile ¶
CQDownloadFile 扩展API-下载文件到缓存目录
func (*CQBot) CQGetAtAllRemain ¶
CQGetAtAllRemain 扩展API-获取群 @全体成员 剩余次数
func (*CQBot) CQGetCSRFToken ¶
func (*CQBot) CQGetCookies ¶
func (*CQBot) CQGetCredentials ¶
func (*CQBot) CQGetEssenceMessageList ¶
CQGetEssenceMessageList 扩展API-获取精华消息列表
func (*CQBot) CQGetForwardMessage ¶
CQGetForwardMessage 获取合并转发消息
func (*CQBot) CQGetFriendList ¶
CQGetFriendList 获取好友列表
func (*CQBot) CQGetGroupFileSystemInfo ¶
CQGetGroupFileSystemInfo 扩展API-获取群文件系统信息
func (*CQBot) CQGetGroupFileURL ¶
CQGetGroupFileURL 扩展API-获取群文件资源链接
func (*CQBot) CQGetGroupFilesByFolderID ¶
CQGetGroupFilesByFolderID 扩展API-获取群子目录文件列表
func (*CQBot) CQGetGroupHonorInfo ¶
CQGetGroupHonorInfo 获取群荣誉信息
func (*CQBot) CQGetGroupInfo ¶
CQGetGroupInfo 获取群信息
func (*CQBot) CQGetGroupList ¶
CQGetGroupList 获取群列表
func (*CQBot) CQGetGroupMemberInfo ¶
CQGetGroupMemberInfo 获取群成员信息
func (*CQBot) CQGetGroupMemberList ¶
CQGetGroupMemberList 获取群成员列表
func (*CQBot) CQGetGroupMessageHistory ¶
CQGetGroupMessageHistory 获取群消息历史记录
func (*CQBot) CQGetGroupRootFiles ¶
CQGetGroupRootFiles 扩展API-获取群根目录文件列表
func (*CQBot) CQGetGroupSystemMessages ¶
CQGetGroupSystemMessages 扩展API-获取群文件系统消息
https://docs.go-cqhttp.org/api/#%E8%8E%B7%E5%8F%96%E7%BE%A4%E7%B3%BB%E7%BB%9F%E6%B6%88%E6%81%AF
func (*CQBot) CQGetImage ¶
CQGetImage 获取图片(修改自OneBot)
https://docs.go-cqhttp.org/api/#%E8%8E%B7%E5%8F%96%E5%9B%BE%E7%89%87%E4%BF%A1%E6%81%AF
func (*CQBot) CQGetLoginInfo ¶
CQGetLoginInfo 获取登录号信息
func (*CQBot) CQGetMessage ¶
CQGetMessage 获取消息
func (*CQBot) CQGetModelShow ¶
CQGetModelShow 获取在线机型
func (*CQBot) CQGetOnlineClients ¶
CQGetOnlineClients 扩展API-获取当前账号在线客户端列表
func (*CQBot) CQGetQiDianAccountInfo ¶
CQGetQiDianAccountInfo 获取企点账号信息
func (*CQBot) CQGetStatus ¶
CQGetStatus 获取运行状态
func (*CQBot) CQGetStrangerInfo ¶
CQGetStrangerInfo 获取陌生人信息
func (*CQBot) CQGetVersionInfo ¶
CQGetVersionInfo 获取版本信息
func (*CQBot) CQGetVipInfo ¶
CQGetVipInfo 扩展API-获取VIP信息
https://docs.go-cqhttp.org/api/#%E8%8E%B7%E5%8F%96vip%E4%BF%A1%E6%81%AF
func (*CQBot) CQGetWordSlices ¶
CQGetWordSlices 隐藏API-获取中文分词
func (*CQBot) CQGroupFileCreateFolder ¶
CQGroupFileCreateFolder 拓展API-创建群文件文件夹
func (*CQBot) CQGroupFileDeleteFile ¶
CQGroupFileDeleteFile 拓展API-删除群文件
func (*CQBot) CQGroupFileDeleteFolder ¶
CQGroupFileDeleteFolder 拓展API-删除群文件文件夹
func (*CQBot) CQHandleQuickOperation ¶
CQHandleQuickOperation 隐藏API-对事件执行快速操作
func (*CQBot) CQOcrImage ¶
CQOcrImage 扩展API-图片OCR
func (*CQBot) CQProcessFriendRequest ¶
CQProcessFriendRequest 处理加好友请求
func (*CQBot) CQProcessGroupRequest ¶
CQProcessGroupRequest 处理加群请求/邀请
func (*CQBot) CQSendGroupForwardMessage ¶
CQSendGroupForwardMessage 扩展API-发送合并转发(群)
https://docs.go-cqhttp.org/api/#%E5%8F%91%E9%80%81%E5%90%88%E5%B9%B6%E8%BD%AC%E5%8F%91-%E7%BE%A4
func (*CQBot) CQSendGroupMessage ¶
CQSendGroupMessage 发送群消息
func (*CQBot) CQSendPrivateMessage ¶
func (bot *CQBot) CQSendPrivateMessage(userID int64, groupID int64, i interface{}, autoEscape bool) MSG
CQSendPrivateMessage 发送私聊消息
func (*CQBot) CQSetEssenceMessage ¶
CQSetEssenceMessage 扩展API-设置精华消息
https://docs.go-cqhttp.org/api/#%E8%AE%BE%E7%BD%AE%E7%B2%BE%E5%8D%8E%E6%B6%88%E6%81%AF
func (*CQBot) CQSetGroupAdmin ¶
CQSetGroupAdmin 群组设置管理员
func (*CQBot) CQSetGroupAnonymousBan ¶
CQSetGroupAnonymousBan 群组匿名用户禁言
func (*CQBot) CQSetGroupBan ¶
CQSetGroupBan 群组单人禁言
func (*CQBot) CQSetGroupCard ¶
CQSetGroupCard 设置群名片(群备注)
func (*CQBot) CQSetGroupKick ¶
CQSetGroupKick 群组踢人
func (*CQBot) CQSetGroupLeave ¶
CQSetGroupLeave 退出群组
func (*CQBot) CQSetGroupMemo ¶
CQSetGroupMemo 扩展API-发送群公告
https://docs.go-cqhttp.org/api/#%E5%8F%91%E9%80%81%E7%BE%A4%E5%85%AC%E5%91%8A
func (*CQBot) CQSetGroupName ¶
CQSetGroupName 设置群名
func (*CQBot) CQSetGroupPortrait ¶
CQSetGroupPortrait 扩展API-设置群头像
https://docs.go-cqhttp.org/api/#%E8%AE%BE%E7%BD%AE%E7%BE%A4%E5%A4%B4%E5%83%8F
func (*CQBot) CQSetGroupSpecialTitle ¶
CQSetGroupSpecialTitle 设置群组专属头衔
func (*CQBot) CQSetGroupWholeBan ¶
CQSetGroupWholeBan 群组全员禁言
func (*CQBot) CQSetModelShow ¶
CQSetModelShow 设置在线机型
func (*CQBot) CQUploadGroupFile ¶
CQUploadGroupFile 扩展API-上传群文件
https://docs.go-cqhttp.org/api/#%E4%B8%8A%E4%BC%A0%E7%BE%A4%E6%96%87%E4%BB%B6
func (*CQBot) ConvertObjectMessage ¶
ConvertObjectMessage 将消息JSON对象转为消息元素数组
func (*CQBot) ConvertStringMessage ¶
func (bot *CQBot) ConvertStringMessage(raw string, isGroup bool) (r []message.IMessageElement)
ConvertStringMessage 将消息字符串转为消息元素数组
func (*CQBot) InsertGroupMessage ¶
func (bot *CQBot) InsertGroupMessage(m *message.GroupMessage) int32
InsertGroupMessage 群聊消息入数据库
func (*CQBot) InsertPrivateMessage ¶
func (bot *CQBot) InsertPrivateMessage(m *message.PrivateMessage) int32
InsertPrivateMessage 私聊消息入数据库
func (*CQBot) InsertTempMessage ¶
func (bot *CQBot) InsertTempMessage(target int64, m *message.TempMessage) int32
InsertTempMessage 临时消息入数据库
func (*CQBot) OnEventPush ¶
OnEventPush 注册事件上报函数
func (*CQBot) SendGroupMessage ¶
func (bot *CQBot) SendGroupMessage(groupID int64, m *message.SendingMessage) int32
SendGroupMessage 发送群消息
func (*CQBot) SendPrivateMessage ¶
SendPrivateMessage 发送私聊消息
func (*CQBot) ToElement ¶
ToElement 将解码后的CQCode转换为Element.
返回 interface{} 存在三种类型
message.IMessageElement []message.IMessageElement nil
func (*CQBot) UploadLocalImageAsGroup ¶
func (bot *CQBot) UploadLocalImageAsGroup(groupCode int64, img *LocalImageElement) (*message.GroupImageElement, error)
UploadLocalImageAsGroup 上传本地图片至群聊
func (*CQBot) UploadLocalImageAsPrivate ¶
func (bot *CQBot) UploadLocalImageAsPrivate(userID int64, img *LocalImageElement) (*message.FriendImageElement, error)
UploadLocalImageAsPrivate 上传本地图片至私聊
func (*CQBot) UploadLocalVideo ¶
func (bot *CQBot) UploadLocalVideo(target int64, v *LocalVideoElement) (*message.ShortVideoElement, error)
UploadLocalVideo 上传本地短视频至群聊
type GiftElement ¶
GiftElement 礼物
type LocalImageElement ¶
type LocalImageElement struct { message.ImageElement Stream io.ReadSeeker File string }
LocalImageElement 本地图片
type LocalVideoElement ¶
type LocalVideoElement struct { message.ShortVideoElement File string // contains filtered or unexported fields }
LocalVideoElement 本地视频
type LocalVoiceElement ¶
type LocalVoiceElement struct { message.VoiceElement Stream io.ReadSeeker }
LocalVoiceElement 本地语音
type MSG ¶
type MSG map[string]interface{}
MSG 消息Map
func ToArrayMessage ¶
func ToArrayMessage(e []message.IMessageElement, id int64, isRaw ...bool) (r []MSG)
ToArrayMessage 将消息元素数组转为MSG数组以用于消息上报