miraihttp

package module
v0.0.0-...-e13a93e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2024 License: AGPL-3.0 Imports: 12 Imported by: 0

README

mirai-api-http的Go SDK

这是针对mirai-api-http编写的Go SDK。

相较于直接使用mirai-core和mirai-console而言,mirai-api-http的好处是,在你更新代码时,你无需进行重新登录。

开始

在使用本项目之前,你应该知道如何使用mirai进行登录,并安装mirai-api-http插件。

请多参阅mirai-api-http的文档

本项目使用ws接口,因此你需要修改mirai的配置文件config/net.mamoe.mirai-api-http/setting.yml,开启ws监听。

adapters:
  - ws
verifyKey: ABCDEFGHIJK
adapterSettings:
  ws:
    ## websocket server 监听的本地地址
    ## 一般为 localhost 即可, 如果多网卡等情况,自定设置
    host: localhost

    ## websocket server 监听的端口
    ## 与 http server 可以重复, 由于协议与路径不同, 不会产生冲突
    port: 8080

    ## 就填-1
    reservedSyncId: -1

引入项目:

go get -u github.com/CuteReimu/mirai-sdk-http

关于如何使用,可以参考examples文件夹下的例子

注意事项

所有ListenXXXXXX函数之间都不支持并发,你可以在启动机器人的情况下调用这些函数,但是不要同时在多个协程调用这些函数。(不过在一般情况下确实不会有这种奇怪的需求)

进度

目前已支持的功能有:

  • 消息链
    • 所有消息类型
    • 所有消息解析
    • 所有其它客户端同步消息解析
  • 事件
    • Bot自身事件
    • 好友事件
    • 群事件
    • 申请事件
    • 其它客户端事件
    • 命令事件
  • 请求
    • 获取插件信息
    • 缓存操作
    • 获取账号信息
    • 消息发送与撤回
    • 文件操作
    • 多媒体内容上传
    • 账号管理
    • 群管理
    • 群公告
    • 事件处理
    • Console命令
  • 其它
    • 连接与认证
    • 断线重连
    • MiraiCode解析

Documentation

Index

Constants

View Source
const (
	// WsChannelMessage 推送消息
	WsChannelMessage = "model"

	// WsChannelEvent 推送事件
	WsChannelEvent = "event"

	// WsChannelAll 推送消息及事件
	WsChannelAll = "all"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	Type    string `json:"type"`
	Content string `json:"content"` // 内容
}

func (*App) FillMessageType

func (m *App) FillMessageType()

type At

type At struct {
	Type    string `json:"type"`
	Target  int64  `json:"target"`            // 群员QQ号
	Display string `json:"display,omitempty"` // At时显示的文字,发送消息时无效,自动使用群名片
}

At @消息

func (*At) FillMessageType

func (m *At) FillMessageType()

type AtAll

type AtAll struct {
	Type string `json:"type"`
}

AtAll @全体消息

func (*AtAll) FillMessageType

func (m *AtAll) FillMessageType()

type Bot

type Bot struct {
	QQ int64
	// contains filtered or unexported fields
}

func Connect

func Connect(host string, port int, channel WsChannel, verifyKey string, qq int64, concurrentEvent bool) (*Bot, error)

Connect 连接mirai-api-http

concurrentEvent 参数如果是true,表示采用并发方式处理事件和消息,由调用者自行解决并发问题。 如果是false表示用单线程处理事件和消息,调用者无需关心并发问题。

func (*Bot) About

func (b *Bot) About() (string, error)

About 获取插件版本号

func (*Bot) BotList

func (b *Bot) BotList() ([]int64, error)

BotList 获取登录账号

func (*Bot) GetGroupConfig

func (b *Bot) GetGroupConfig(group int64) (*GroupConfig, error)

GetGroupConfig 获取群设置

func (*Bot) GetMemberInfo

func (b *Bot) GetMemberInfo(group, qq int64) (*Member, error)

GetMemberInfo 获取群员设置

func (*Bot) Kick

func (b *Bot) Kick(group, qq int64, block bool, msg string) error

Kick 移除群成员(需要有相关限权),group-群,qq-移除的人,block-移除后是否拉黑,msg-信息

func (*Bot) ListenBotGroupPermissionChangeEvent

func (b *Bot) ListenBotGroupPermissionChangeEvent(l func(message *BotGroupPermissionChangeEvent) bool)

ListenBotGroupPermissionChangeEvent 监听Bot在群里的权限被改变

func (*Bot) ListenBotInvitedJoinGroupRequestEvent

func (b *Bot) ListenBotInvitedJoinGroupRequestEvent(l func(message *BotInvitedJoinGroupRequestEvent) bool)

ListenBotInvitedJoinGroupRequestEvent 监听Bot被邀请入群申请

func (*Bot) ListenBotJoinGroupEvent

func (b *Bot) ListenBotJoinGroupEvent(l func(message *BotJoinGroupEvent) bool)

ListenBotJoinGroupEvent 监听Bot加入了一个新群

func (*Bot) ListenBotLeaveEventActive

func (b *Bot) ListenBotLeaveEventActive(l func(message *BotLeaveEventActive) bool)

ListenBotLeaveEventActive 监听Bot主动退出一个群

func (*Bot) ListenBotLeaveEventDisband

func (b *Bot) ListenBotLeaveEventDisband(l func(message *BotLeaveEventDisband) bool)

ListenBotLeaveEventDisband 监听Bot因群主解散群而退出群

func (*Bot) ListenBotLeaveEventKick

func (b *Bot) ListenBotLeaveEventKick(l func(message *BotLeaveEventKick) bool)

ListenBotLeaveEventKick 监听Bot被踢出一个群

func (*Bot) ListenBotMuteEvent

func (b *Bot) ListenBotMuteEvent(l func(message *BotMuteEvent) bool)

ListenBotMuteEvent 监听Bot被禁言

func (*Bot) ListenBotUnmuteEvent

func (b *Bot) ListenBotUnmuteEvent(l func(message *BotUnmuteEvent) bool)

ListenBotUnmuteEvent 监听Bot被取消禁言

func (*Bot) ListenFriendMessage

func (b *Bot) ListenFriendMessage(l func(message *FriendMessage) bool)

ListenFriendMessage 监听好友消息

func (*Bot) ListenFriendRecallEvent

func (b *Bot) ListenFriendRecallEvent(l func(message *FriendRecallEvent) bool)

ListenFriendRecallEvent 监听好友消息撤回

func (*Bot) ListenFriendSyncMessage

func (b *Bot) ListenFriendSyncMessage(l func(message *FriendSyncMessage) bool)

ListenFriendSyncMessage 监听同步好友消息

func (*Bot) ListenGroupAllowAnonymousChatEvent

func (b *Bot) ListenGroupAllowAnonymousChatEvent(l func(message *GroupAllowAnonymousChatEvent) bool)

ListenGroupAllowAnonymousChatEvent 监听匿名聊天

func (*Bot) ListenGroupAllowConfessTalkEvent

func (b *Bot) ListenGroupAllowConfessTalkEvent(l func(message *GroupAllowConfessTalkEvent) bool)

ListenGroupAllowConfessTalkEvent 监听坦白说

func (*Bot) ListenGroupAllowMemberInviteEvent

func (b *Bot) ListenGroupAllowMemberInviteEvent(l func(message *GroupAllowMemberInviteEvent) bool)

ListenGroupAllowMemberInviteEvent 监听允许群员邀请好友加群

func (*Bot) ListenGroupEntranceAnnouncementChangeEvent

func (b *Bot) ListenGroupEntranceAnnouncementChangeEvent(l func(message *GroupEntranceAnnouncementChangeEvent) bool)

ListenGroupEntranceAnnouncementChangeEvent 监听某群入群公告改变

func (*Bot) ListenGroupMessage

func (b *Bot) ListenGroupMessage(l func(message *GroupMessage) bool)

ListenGroupMessage 监听群消息

func (*Bot) ListenGroupMuteAllEvent

func (b *Bot) ListenGroupMuteAllEvent(l func(message *GroupMuteAllEvent) bool)

ListenGroupMuteAllEvent 监听全员禁言

func (*Bot) ListenGroupNameChangeEvent

func (b *Bot) ListenGroupNameChangeEvent(l func(message *GroupNameChangeEvent) bool)

ListenGroupNameChangeEvent 监听某个群名改变

func (*Bot) ListenGroupRecallEvent

func (b *Bot) ListenGroupRecallEvent(l func(message *GroupRecallEvent) bool)

ListenGroupRecallEvent 监听群消息撤回

func (*Bot) ListenGroupSyncMessage

func (b *Bot) ListenGroupSyncMessage(l func(message *GroupSyncMessage) bool)

ListenGroupSyncMessage 监听同步群消息

func (*Bot) ListenMemberCardChangeEvent

func (b *Bot) ListenMemberCardChangeEvent(l func(message *MemberCardChangeEvent) bool)

ListenMemberCardChangeEvent 监听群名片改动

func (*Bot) ListenMemberHonorChangeEvent

func (b *Bot) ListenMemberHonorChangeEvent(l func(message *MemberHonorChangeEvent) bool)

ListenMemberHonorChangeEvent 监听群员称号改变

func (*Bot) ListenMemberJoinEvent

func (b *Bot) ListenMemberJoinEvent(l func(message *MemberJoinEvent) bool)

ListenMemberJoinEvent 监听新人入群的事件

func (*Bot) ListenMemberJoinRequestEvent

func (b *Bot) ListenMemberJoinRequestEvent(l func(message *MemberJoinRequestEvent) bool)

ListenMemberJoinRequestEvent 监听用户入群申请(Bot需要有管理员权限)

func (*Bot) ListenMemberLeaveEventKick

func (b *Bot) ListenMemberLeaveEventKick(l func(message *MemberLeaveEventKick) bool)

ListenMemberLeaveEventKick 监听成员被踢出群

func (*Bot) ListenMemberLeaveEventQuit

func (b *Bot) ListenMemberLeaveEventQuit(l func(message *MemberLeaveEventQuit) bool)

ListenMemberLeaveEventQuit 监听成员主动离群

func (*Bot) ListenMemberMuteEvent

func (b *Bot) ListenMemberMuteEvent(l func(message *MemberMuteEvent) bool)

ListenMemberMuteEvent 监听群成员被禁言事件

func (*Bot) ListenMemberPermissionChangeEvent

func (b *Bot) ListenMemberPermissionChangeEvent(l func(message *MemberPermissionChangeEvent) bool)

ListenMemberPermissionChangeEvent 监听成员权限改变的事件

func (*Bot) ListenMemberSpecialTitleChangeEvent

func (b *Bot) ListenMemberSpecialTitleChangeEvent(l func(message *MemberSpecialTitleChangeEvent) bool)

ListenMemberSpecialTitleChangeEvent 监听群头衔改动

func (*Bot) ListenMemberUnmuteEvent

func (b *Bot) ListenMemberUnmuteEvent(l func(message *MemberUnmuteEvent) bool)

ListenMemberUnmuteEvent 监听群成员被取消禁言事件

func (*Bot) ListenNewFriendRequestEvent

func (b *Bot) ListenNewFriendRequestEvent(l func(message *NewFriendRequestEvent) bool)

ListenNewFriendRequestEvent 监听添加好友申请

func (*Bot) ListenNudgeEvent

func (b *Bot) ListenNudgeEvent(l func(message *NudgeEvent) bool)

ListenNudgeEvent 监听戳一戳事件

func (*Bot) ListenOtherClientMessage

func (b *Bot) ListenOtherClientMessage(l func(message *OtherClientMessage) bool)

ListenOtherClientMessage 监听其他客户端消息

func (*Bot) ListenStrangerMessage

func (b *Bot) ListenStrangerMessage(l func(message *StrangerMessage) bool)

ListenStrangerMessage 监听陌生人消息

func (*Bot) ListenStrangerSyncMessage

func (b *Bot) ListenStrangerSyncMessage(l func(message *StrangerSyncMessage) bool)

ListenStrangerSyncMessage 监听同步好友消息

func (*Bot) ListenTempMessage

func (b *Bot) ListenTempMessage(l func(message *TempMessage) bool)

ListenTempMessage 监听群临时消息

func (*Bot) ListenTempSyncMessage

func (b *Bot) ListenTempSyncMessage(l func(message *TempSyncMessage) bool)

ListenTempSyncMessage 监听同步群临时消息

func (*Bot) MemberAdmin

func (b *Bot) MemberAdmin(group, qq int64, assign bool) error

MemberAdmin 修改群员管理员(需要有群主限权),assign-是否设置为管理员

func (*Bot) MessageFromId

func (b *Bot) MessageFromId(messageId, target int64) (any, error)

MessageFromId 通过messageId获取消息,target-好友或QQ群,视情况返回 FriendMessage, GroupMessage, TempMessage, StrangerMessage

func (*Bot) Mute

func (b *Bot) Mute(group, qq, time int64) error

Mute 禁言群成员(需要有相关限权),group-群,qq-被禁言的人,time-时间,单位秒,最多30天

func (*Bot) MuteAll

func (b *Bot) MuteAll(group int64) error

MuteAll 全体禁言(需要有相关限权)

func (*Bot) Quit

func (b *Bot) Quit(group int64) error

Quit 退出群聊(自己不能是群主)

func (*Bot) Recall

func (b *Bot) Recall(target, messageId int64) error

Recall 撤回消息,target-撤回哪的消息(好友/群),messageId-需要撤回的消息的messageId

func (*Bot) RoamingMessages

func (b *Bot) RoamingMessages(timeStart, timeEnd, qq int64) ([]any, error)

RoamingMessages 获取漫游消息,timeStart和timeEnd为开始和结束的时间戳,单位为秒。qq为查询的对象QQ,目前仅支持好友漫游消息。

返回数组的元素为 FriendMessage, GroupMessage, TempMessage, StrangerMessage

func (*Bot) SendFriendMessage

func (b *Bot) SendFriendMessage(qq, quote int64, messageChain []SingleMessage) (int64, error)

SendFriendMessage 发送好友消息,qq-目标好友的QQ号,quote-引用回复的消息,messageChain-发送的内容,返回消息id

func (*Bot) SendGroupMessage

func (b *Bot) SendGroupMessage(group, quote int64, messageChain []SingleMessage) (int64, error)

SendGroupMessage 发送群消息,group-群号,quote-引用回复的消息,messageChain-发送的内容,返回消息id

func (*Bot) SendNudge

func (b *Bot) SendNudge(qq, subject int64, kind Kind) error

SendNudge 发送头像戳一戳消息,qq-戳谁,subject-这条消息发到哪(好友/群),kind-上下文类型

func (*Bot) SendTempMessage

func (b *Bot) SendTempMessage(qq, group, quote int64, messageChain []SingleMessage) (int64, error)

SendTempMessage 发送临时会话消息,qq-临时会话对象QQ号,group-临时会话群号,quote-引用回复的消息,messageChain-发送的内容,返回消息id

func (*Bot) SetEssence

func (b *Bot) SetEssence(group, messageId int64) error

SetEssence 设置群精华消息(需要有相关限权)

func (*Bot) Unmute

func (b *Bot) Unmute(group, qq int64) error

Unmute 解除禁言群成员(需要有相关限权),group-群,qq-解除禁言的人

func (*Bot) UnmuteAll

func (b *Bot) UnmuteAll(group int64) error

UnmuteAll 解除全体禁言(需要有相关限权)

func (*Bot) UpdateGroupConfig

func (b *Bot) UpdateGroupConfig(group int64, groupConfig *GroupConfig) error

UpdateGroupConfig 修改群设置(需要有相关限权)

func (*Bot) UpdateMemberInfo

func (b *Bot) UpdateMemberInfo(group, qq int64, name, specialTitle string) error

UpdateMemberInfo 修改群员设置(需要有相关限权),name-群昵称,specialTitle-群头衔,这两项都是选填

type BotGroupPermissionChangeEvent

type BotGroupPermissionChangeEvent struct {
	Origin  Perm  `json:"origin"`  // Bot的原权限
	Current Perm  `json:"current"` // Bot的新权限
	Group   Group `json:"group"`
}

BotGroupPermissionChangeEvent Bot在群里的权限被改变. 操作人一定是群主

type BotInvitedJoinGroupRequestEvent

type BotInvitedJoinGroupRequestEvent struct {
	EventId   int64  `json:"eventId"`   // 事件标识,响应该事件时的标识
	QQ        int64  `json:"fromId"`    // 邀请人QQ号
	Group     int64  `json:"groupId"`   // 被邀请进入群的群号
	GroupName string `json:"groupName"` // 被邀请进入群的群名称
	Nick      string `json:"nick"`      // 邀请人(好友)的昵称
	Message   string `json:"message"`   // 邀请消息
}

BotInvitedJoinGroupRequestEvent Bot被邀请入群申请

type BotJoinGroupEvent

type BotJoinGroupEvent struct {
	Group   Group   `json:"group"`
	Invitor *Member `json:"invitor,omitempty"` // 邀请者,可能为空
}

BotJoinGroupEvent Bot加入了一个新群

type BotLeaveEventActive

type BotLeaveEventActive struct {
	Group Group `json:"group"`
}

BotLeaveEventActive Bot主动退出一个群

type BotLeaveEventDisband

type BotLeaveEventDisband struct {
	Group    Group   `json:"group"`
	Operator *Member `json:"operator"`
}

BotLeaveEventDisband Bot因群主解散群而退出群, 操作人一定是群主

type BotLeaveEventKick

type BotLeaveEventKick struct {
	Group Group `json:"group"`
}

BotLeaveEventKick Bot被踢出一个群

type BotMuteEvent

type BotMuteEvent struct {
	DurationSeconds int64  `json:"durationSeconds"` // 禁言时长,单位为秒
	Operator        Member `json:"operator"`
}

BotMuteEvent Bot被禁言

type BotUnmuteEvent

type BotUnmuteEvent struct {
	Operator Member `json:"operator"`
}

BotUnmuteEvent Bot被取消禁言

type Dice

type Dice struct {
	Type  string `json:"type"`
	Value int32  `json:"value"` // 点数
}

Dice 骰子

func (*Dice) FillMessageType

func (m *Dice) FillMessageType()

type Face

type Face struct {
	Type   string `json:"type"`
	FaceId int32  `json:"faceId,omitempty"` // QQ表情编号,可选,优先高于name
	Name   string `json:"name,omitempty"`   // QQ表情拼音,可选
}

Face QQ表情

func (*Face) FillMessageType

func (m *Face) FillMessageType()

type File

type File struct {
	Type string `json:"type"`
	Id   string `json:"id"`   // 文件识别id
	Name string `json:"name"` // 文件名
	Size int64  `json:"size"` // 文件大小
}

File 文件

func (*File) FillMessageType

func (m *File) FillMessageType()

type FlashImage

type FlashImage struct {
	Type    string `json:"type"`
	ImageId string `json:"imageId,omitempty"`
	Url     string `json:"url,omitempty"`
	Path    string `json:"path,omitempty"`
	Base64  string `json:"base64,omitempty"`
}

FlashImage 闪照,参数同Image

func (*FlashImage) FillMessageType

func (m *FlashImage) FillMessageType()

type ForwardMessage

type ForwardMessage struct {
	Type string `json:"type"`

	// Display 转发消息的卡片显示文本,值为表示使用客户端默认值。发送时可以直接填nil,表示全用默认值。
	//
	// 参考 https://docs.mirai.mamoe.net/mirai-api-http/api/MessageType.html#forwardmessage
	Display map[string]any `json:"display,omitempty"`

	NodeList []*ForwardMessageNode `json:"nodeList"` // 消息节点
}

ForwardMessage 转发消息

func (*ForwardMessage) FillMessageType

func (m *ForwardMessage) FillMessageType()

type ForwardMessageNode

type ForwardMessageNode struct {
	SenderId     int64  `json:"senderId,omitempty"`     // 消息节点
	Time         int64  `json:"time,omitempty"`         // 发送时间
	SenderName   string `json:"senderName,omitempty"`   // 显示名称
	MessageChain []any  `json:"messageChain,omitempty"` // 消息数组

	MessageId int64 `json:"messageId,omitempty"` // 可以只使用消息messageId,从当前对话上下文缓存中读取一条消息作为节点

	// MessageRef 引用缓存中其他对话上下文的消息作为节点
	//
	// 参考 https://docs.mirai.mamoe.net/mirai-api-http/api/MessageType.html#forwardmessage
	MessageRef map[string]any `json:"messageRef,omitempty"`
}

type Friend

type Friend struct {
	Id       int64  `json:"id"`       // QQ号
	Nickname string `json:"nickname"` // 昵称
	Remark   string `json:"remark"`   // 备注
}

Friend 好友

type FriendMessage

type FriendMessage struct {
	Sender       Friend
	MessageChain []SingleMessage
}

FriendMessage 好友消息

type FriendRecallEvent

type FriendRecallEvent struct {
	AuthorId  int64 `json:"authorId"`  // 原消息发送者的QQ号
	MessageId int64 `json:"messageId"` // 原消息messageId
	Time      int64 `json:"time"`      // 原消息发送时间
	Operator  int64 `json:"operator"`  // 好友QQ号或BotQQ号
}

FriendRecallEvent 好友消息撤回

type FriendSyncMessage

type FriendSyncMessage struct {
	Subject      Friend
	MessageChain []SingleMessage
}

FriendSyncMessage 同步好友消息

type Group

type Group struct {
	Id         int64  `json:"id"`         // 群号
	Name       string `json:"name"`       // 群名称
	Permission Perm   `json:"permission"` // Bot在群中的权限
}

Group 群

type GroupAllowAnonymousChatEvent

type GroupAllowAnonymousChatEvent struct {
	Origin   bool   `json:"origin"`
	Current  bool   `json:"current"`
	Group    Group  `json:"group"`
	Operator Member `json:"operator"`
}

GroupAllowAnonymousChatEvent 匿名聊天

type GroupAllowConfessTalkEvent

type GroupAllowConfessTalkEvent struct {
	Origin  bool  `json:"origin"`
	Current bool  `json:"current"`
	Group   Group `json:"group"`
	IsByBot bool  `json:"isByBot"` // 是否Bot进行该操作
}

GroupAllowConfessTalkEvent 坦白说

type GroupAllowMemberInviteEvent

type GroupAllowMemberInviteEvent struct {
	Origin   bool   `json:"origin"`
	Current  bool   `json:"current"`
	Group    Group  `json:"group"`
	Operator Member `json:"operator"`
}

GroupAllowMemberInviteEvent 允许群员邀请好友加群

type GroupConfig

type GroupConfig struct {
	Name              string `json:"name"`
	Announcement      string `json:"announcement"`
	ConfessTalk       bool   `json:"confessTalk"`
	AllowMemberInvite bool   `json:"allowMemberInvite"`
	AutoApprove       bool   `json:"autoApprove"`
	AnonymousChat     bool   `json:"anonymousChat"`

	// MuteAll 是否禁言,修改群设置时不要填这个字段,而应该用 Bot.MuteAll(group) 方法
	MuteAll bool `json:"muteAll,omitempty"`
}

GroupConfig 群设置

type GroupEntranceAnnouncementChangeEvent

type GroupEntranceAnnouncementChangeEvent struct {
	Origin   string `json:"origin"`  // 原公告
	Current  string `json:"current"` // 新公告
	Group    Group  `json:"group"`
	Operator Member `json:"operator"`
}

GroupEntranceAnnouncementChangeEvent 某群入群公告改变

type GroupMessage

type GroupMessage struct {
	Sender       Member
	MessageChain []SingleMessage
}

GroupMessage 群消息

type GroupMuteAllEvent

type GroupMuteAllEvent struct {
	Origin   bool   `json:"origin"`
	Current  bool   `json:"current"`
	Group    Group  `json:"group"`
	Operator Member `json:"operator"`
}

GroupMuteAllEvent 全员禁言

type GroupNameChangeEvent

type GroupNameChangeEvent struct {
	Origin   string `json:"origin"`  // 原群名
	Current  string `json:"current"` // 新群名
	Group    Group  `json:"group"`
	Operator Member `json:"operator"`
}

GroupNameChangeEvent 某个群名改变

type GroupRecallEvent

type GroupRecallEvent struct {
	AuthorId  int64  `json:"authorId"`  // 原消息发送者的QQ号
	MessageId int64  `json:"messageId"` // 原消息messageId
	Time      int64  `json:"time"`      // 原消息发送时间
	Group     Group  `json:"group"`     // 消息撤回所在的群
	Operator  Member `json:"operator"`  // 撤回消息的操作人,当null时为bot操作
}

GroupRecallEvent 群消息撤回

type GroupSyncMessage

type GroupSyncMessage struct {
	Subject      Group
	MessageChain []SingleMessage
}

GroupSyncMessage 同步群消息

type HonorAction

type HonorAction string
const (
	HonorActionAchieve HonorAction = "achieve" // 获得称号
	HonorActionLose    HonorAction = "lose"    // 失去称号
)

type Image

type Image struct {
	Type    string `json:"type"`
	ImageId string `json:"imageId,omitempty"` // 图片的imageId,群图片与好友图片格式不同。不为空时将忽略url属性
	Url     string `json:"url,omitempty"`     // 图片的URL,发送时可作网络图片的链接;接收时为腾讯图片服务器的链接,可用于图片下载
	Path    string `json:"path,omitempty"`    // 图片的路径,发送本地图片,路径相对于 JVM 工作路径(默认是当前路径,可通过 -Duser.dir=...指定),也可传入绝对路径。
	Base64  string `json:"base64,omitempty"`  // 图片的 Base64 编码
}

Image 图片(参数优先级imageId > url > path > base64)

func (*Image) FillMessageType

func (m *Image) FillMessageType()

type Json

type Json struct {
	Type string `json:"type"`
	Json string `json:"json"` // Json文本
}

func (*Json) FillMessageType

func (m *Json) FillMessageType()

type Kind

type Kind string
const (
	KindFriend   Kind = "Friend"   // 好友
	KindGroup    Kind = "Group"    // 群
	KindStranger Kind = "Stranger" // 陌生人
)

type MarketFace

type MarketFace struct {
	Type string `json:"type"`
	Id   int32  `json:"id"`   // 商城表情唯一标识
	Name string `json:"name"` // 表情显示名称
}

MarketFace 商城表情(目前商城表情仅支持接收和转发,不支持构造发送)

func (*MarketFace) FillMessageType

func (m *MarketFace) FillMessageType()

type Member

type Member struct {
	Id                 int64  `json:"id"`                 // QQ号
	MemberName         string `json:"memberName"`         // 群名片
	SpecialTitle       string `json:"specialTitle"`       // 群头衔
	Permission         Perm   `json:"permission"`         // 在群中的权限
	JoinTimestamp      int64  `json:"joinTimestamp"`      // 入群时间时间戳
	LastSpeakTimestamp int64  `json:"lastSpeakTimestamp"` // 最近发言时间戳
	MuteTimeRemaining  int64  `json:"muteTimeRemaining"`  // 剩余禁言时长
	Group              Group  `json:"group"`              // 群信息
}

Member 群成员

type MemberCardChangeEvent

type MemberCardChangeEvent struct {
	Origin  string `json:"origin"`
	Current string `json:"current"`
	Member  Member `json:"member"` // 名片改动的群员的信息
}

MemberCardChangeEvent 群名片改动

type MemberHonorChangeEvent

type MemberHonorChangeEvent struct {
	Member Member      `json:"member"`
	Action HonorAction `json:"action"` // 称号变化行为
	Honor  string      `json:"honor"`  // 称号名称
}

MemberHonorChangeEvent 群员称号改变

type MemberJoinEvent

type MemberJoinEvent struct {
	Member  Member  `json:"member"`
	Invitor *Member `json:"invitor"` // 邀请人,可能为空
}

MemberJoinEvent 新人入群的事件

type MemberJoinRequestEvent

type MemberJoinRequestEvent struct {
	EventId   int64  `json:"eventId"`   // 事件标识,响应该事件时的标识
	QQ        int64  `json:"fromId"`    // 申请人QQ号
	Group     int64  `json:"groupId"`   // 申请人申请入群的群号
	GroupName string `json:"groupName"` // 申请人申请入群的群名称
	Nick      string `json:"nick"`      // 申请人的昵称或群名片
	Message   string `json:"message"`   // 申请消息
	InvitorId int64  `json:"invitorId"` // 邀请人,可能没有
}

MemberJoinRequestEvent 用户入群申请(Bot需要有管理员权限)

type MemberLeaveEventKick

type MemberLeaveEventKick struct {
	Member   Member `json:"member"`
	Operator Member `json:"operator"`
}

MemberLeaveEventKick 成员被踢出群(该成员不是Bot)

type MemberLeaveEventQuit

type MemberLeaveEventQuit struct {
	Member Member `json:"member"`
}

MemberLeaveEventQuit 成员主动离群(该成员不是Bot)

type MemberMuteEvent

type MemberMuteEvent struct {
	DurationSeconds int64  `json:"durationSeconds"`
	Member          Member `json:"member"`
	Operator        Member `json:"operator"`
}

MemberMuteEvent 群成员被禁言事件(该成员不是Bot)

type MemberPermissionChangeEvent

type MemberPermissionChangeEvent struct {
	Origin  Perm   `json:"origin"`
	Current Perm   `json:"current"`
	Member  Member `json:"member"`
}

MemberPermissionChangeEvent 成员权限改变的事件(该成员不是Bot)

type MemberSpecialTitleChangeEvent

type MemberSpecialTitleChangeEvent struct {
	Origin  string `json:"origin"`
	Current string `json:"current"`
	Member  Member `json:"member"`
}

MemberSpecialTitleChangeEvent 群头衔改动(只有群主有操作限权)

type MemberUnmuteEvent

type MemberUnmuteEvent struct {
	Member   Member `json:"member"`
	Operator Member `json:"operator"`
}

MemberUnmuteEvent 群成员被取消禁言事件(该成员不是Bot)

type MiraiCode

type MiraiCode struct {
	Type string `json:"type"`
	Code string `json:"code"`
}

func (*MiraiCode) FillMessageType

func (m *MiraiCode) FillMessageType()

type MusicShare

type MusicShare struct {
	Type       string `json:"type"`
	Kind       string `json:"kind"`       // 类型
	Title      string `json:"title"`      // 标题
	Summary    string `json:"summary"`    // 概括
	JumpUrl    string `json:"jumpUrl"`    // 跳转路径
	PictureUrl string `json:"pictureUrl"` // 封面路径
	MusicUrl   string `json:"musicUrl"`   // 音源路径
	Brief      string `json:"brief"`      // 简介
}

MusicShare 音乐分享

func (*MusicShare) FillMessageType

func (m *MusicShare) FillMessageType()

type NewFriendRequestEvent

type NewFriendRequestEvent struct {
	EventId int64  `json:"eventId"` // 事件标识,响应该事件时的标识
	QQ      int64  `json:"fromId"`  // 申请人QQ号
	Group   int64  `json:"groupId"` // 申请人如果通过某个群添加好友,该项为该群群号;否则为0
	Nick    string `json:"nick"`    // 申请人的昵称或群名片
	Message string `json:"message"` // 申请消息
}

NewFriendRequestEvent 添加好友申请

type NudgeEvent

type NudgeEvent struct {
	FromId  int64 `json:"fromId"` // 动作发出者的QQ号
	Subject struct {
		Id   int64 `json:"id"`   // 来源的QQ号(好友)或群号
		Kind Kind  `json:"kind"` // 来源的类型
	} `json:"subject"`
	Action string `json:"action"` // 动作类型
	Suffix string `json:"suffix"` // 自定义动作内容
	Target int64  `json:"target"` // 动作目标的QQ号
}

NudgeEvent 戳一戳事件

type OtherClient

type OtherClient struct {
	Id       int64  `json:"id"`
	Platform string `json:"platform"`
}

type OtherClientMessage

type OtherClientMessage struct {
	Sender       OtherClient
	MessageChain []SingleMessage
}

OtherClientMessage 其他客户端消息

type Perm

type Perm string
const (
	PermOwner         Perm = "OWNER"         // 群主
	PermAdministrator Perm = "ADMINISTRATOR" // 管理员
	PermMember        Perm = "MEMBER"        // 群成员
)

type Plain

type Plain struct {
	Type string `json:"type"`
	Text string `json:"text"` // 文字消息
}

Plain 文字消息

func (*Plain) FillMessageType

func (m *Plain) FillMessageType()

type Poke

type Poke struct {
	Type string   `json:"type"`
	Name PokeName `json:"name"` // 戳一戳的类型
}

Poke 戳一戳

func (*Poke) FillMessageType

func (m *Poke) FillMessageType()

type PokeName

type PokeName string

PokeName 戳一戳的类型

const (
	PokeNamePoke        PokeName = "Poke"        // 戳一戳
	PokeNameShowLove    PokeName = "ShowLove"    // 比心
	PokeNameLike        PokeName = "Like"        // 点赞
	PokeNameHeartbroken PokeName = "Heartbroken" // 心碎
	PokeNameSixSixSix   PokeName = "SixSixSix"   // 666
	PokeNameFangDaZhao  PokeName = "FangDaZhao"  // 放大招
)

type Quote

type Quote struct {
	Type     string `json:"type"`
	Id       int64  `json:"id"`       // 被引用回复的原消息的messageId
	GroupId  int64  `json:"groupId"`  // 被引用回复的原消息所接收的群号,当为好友消息时为0
	SenderId int64  `json:"senderId"` // 被引用回复的原消息的发送者的QQ号
	TargetId int64  `json:"targetId"` // 被引用回复的原消息的接收者的QQ号(或群号)
	Origin   []any  `json:"origin"`   // 被引用回复的原消息的消息链对象
}

Quote 引用回复

func (*Quote) FillMessageType

func (m *Quote) FillMessageType()

type SingleMessage

type SingleMessage interface {
	FillMessageType()
}

func MessageChain

func MessageChain(messages ...SingleMessage) []SingleMessage

MessageChain 构建 MessageChain ,自动填上每个元素的Type字段

type Source

type Source struct {
	Type string `json:"type"`
	Id   int64  `json:"id"`   // 消息的识别号,用于引用回复
	Time int64  `json:"time"` // 时间戳
}

Source 永远为chain的第一个元素

func (*Source) FillMessageType

func (m *Source) FillMessageType()

type StrangerMessage

type StrangerMessage struct {
	Sender       Friend
	MessageChain []SingleMessage
}

StrangerMessage 陌生人消息

type StrangerSyncMessage

type StrangerSyncMessage struct {
	Subject      Friend
	MessageChain []SingleMessage
}

StrangerSyncMessage 同步好友消息

type TempMessage

type TempMessage struct {
	Sender       Member
	MessageChain []SingleMessage
}

TempMessage 群临时消息

type TempSyncMessage

type TempSyncMessage struct {
	Subject      Member
	MessageChain []SingleMessage
}

TempSyncMessage 同步群临时消息

type Voice

type Voice struct {
	Type    string `json:"type"`
	VoiceId string `json:"voiceId,omitempty"` // 语音的voiceId,不为空时将忽略url属性
	Url     string `json:"url,omitempty"`     // 语音的URL,发送时可作网络语音的链接;接收时为腾讯语音服务器的链接,可用于语音下载
	Path    string `json:"path,omitempty"`    // 语音的路径,发送本地语音,路径相对于 JVM 工作路径(默认是当前路径,可通过 -Duser.dir=...指定),也可传入绝对路径。
	Base64  string `json:"base64,omitempty"`  // 语音的 Base64 编码
	Length  string `json:"length,omitempty"`  // 返回的语音长度, 发送消息时可以不传
}

Voice 语音(参数优先级imageId > url > path > base64)

func (*Voice) FillMessageType

func (m *Voice) FillMessageType()

type WsChannel

type WsChannel string

WsChannel 连接通道

type Xml

type Xml struct {
	Type string `json:"type"`
	Xml  string `json:"xml"` // XML文本
}

func (*Xml) FillMessageType

func (m *Xml) FillMessageType()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL