Documentation
¶
Overview ¶
Context take example by repo gin-gonic/gin
Index ¶
- type AuthResp
- type Bot
- func (b *Bot) Auth() (string, error)
- func (b *Bot) BotInvitedJoinGroupReply(operate int, msg string, req *model.BotInvitedJoinGroupRequest) error
- func (b *Bot) Connect() error
- func (b *Bot) CountMessage() (int, error)
- func (b *Bot) FetchLatestMessage(count int) ([]model.MsgRecv, error)
- func (b *Bot) FetchMessage(count int) ([]model.MsgRecv, error)
- func (b *Bot) FriendList() ([]model.User, error)
- func (b *Bot) GetConfig() (*Config, error)
- func (b *Bot) GetGroupConfig(group model.GroupId) (*model.GroupConfig, error)
- func (b *Bot) GetMemberInfo(group model.GroupId, qq model.QQId) (*model.MemberInfo, error)
- func (b *Bot) GroupList() ([]model.Group, error)
- func (b *Bot) Id() model.QQId
- func (b *Bot) Kick(group model.GroupId, qq model.QQId, msg string) error
- func (b *Bot) Loop()
- func (b *Bot) MemberJoinReply(operate int, msg string, req *model.MemberJoinRequest) error
- func (b *Bot) MemberList() ([]model.Member, error)
- func (b *Bot) MessageFromId(msgId model.MsgId) (model.MsgRecv, error)
- func (b *Bot) Mute(group model.GroupId, qq model.QQId, time int) error
- func (b *Bot) MuteAll(group model.GroupId) error
- func (b *Bot) NewFriendReply(operate int, msg string, req *model.NewFriendRequest) error
- func (b *Bot) On(t model.MsgRecvType, handlers ...HandlerFunc)
- func (b *Bot) PeekLatestMessage(count int) ([]model.MsgRecv, error)
- func (b *Bot) PeekMessage(count int) ([]model.MsgRecv, error)
- func (b *Bot) Quit(group model.GroupId) error
- func (b *Bot) Recall(msgId model.MsgId) error
- func (b *Bot) Release() error
- func (b *Bot) ReleaseAndReauth() error
- func (b *Bot) SendFriendMessage(qq model.QQId, mc model.MsgChain, quoteId model.MsgId) (model.MsgId, error)
- func (b *Bot) SendGroupMessage(group model.GroupId, mc model.MsgChain, quoteId model.MsgId) (model.MsgId, error)
- func (b *Bot) SendImageMessage(qq model.QQId, group model.GroupId, urls []string) ([]string, error)
- func (b *Bot) SendTempMessage(qq model.QQId, group model.GroupId, mc model.MsgChain, quoteId model.MsgId) (model.MsgId, error)
- func (b *Bot) SessionKey() string
- func (b *Bot) SetConfig(cacheSize int, enableWebsocket bool) error
- func (b *Bot) SetGroupConfig(group model.GroupId, config model.GroupConfig) error
- func (b *Bot) SetMemberInfo(group model.GroupId, qq model.QQId, info model.MemberInfo) error
- func (b *Bot) SetSessionKey(sessionKey string)
- func (b *Bot) Unmute(group model.GroupId, qq model.QQId) error
- func (b *Bot) UnmuteAll(group model.GroupId) error
- func (b *Bot) UploadImage(t string, path string) (*ImgUploadResp, error)
- func (b *Bot) Use(handlers ...HandlerFunc)
- func (b *Bot) Verify(session string) error
- type BotConfig
- type BotInvitedJoinGroupReply
- type Config
- type Context
- type DefaultEventReply
- type DefaultResp
- type HandlerFunc
- type HandlersChan
- type ImgUploadResp
- type KickReq
- type MemberJoinReply
- type Mode
- type MuteOrUnmuteReq
- type NewFriendReply
- type QuitReq
- type RecallReq
- type SendImgMsgReq
- type SendMsgReq
- type SendMsgResp
- type SetGroupConfigReq
- type SetMemberInfoReq
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bot ¶
type Bot struct { Mu sync.RWMutex Log *logrus.Entry Data sync.Map // contains filtered or unexported fields }
func (*Bot) BotInvitedJoinGroupReply ¶
func (b *Bot) BotInvitedJoinGroupReply(operate int, msg string, req *model.BotInvitedJoinGroupRequest) error
响应Bot被邀请入群
0 同意邀请
1 拒绝邀请
func (*Bot) FetchLatestMessage ¶
获取bot接收到的最新消息和最新各类事件(会从MiraiApiHttp消息记录中删除)
func (*Bot) FetchMessage ¶
获取bot接收到的最老消息和最老各类事件(会从MiraiApiHttp消息记录中删除)
func (*Bot) GetGroupConfig ¶
获取群设置
func (*Bot) GetMemberInfo ¶
获取群员资料
func (*Bot) MemberJoinReply ¶
响应用户入群申请(Bot需要有管理员权限)
0 同意入群
1 拒绝入群
2 忽略请求
3 拒绝入群并添加黑名单,不再接收该用户的入群申请
4 忽略入群并添加黑名单,不再接收该用户的入群申请
func (*Bot) MessageFromId ¶
通过messageId获取一条被缓存的消息。当该messageId没有被缓存或缓存失效时,返回code 5(指定对象不存在)
func (*Bot) PeekLatestMessage ¶
获取bot接收到的最新消息和最新各类事件(不会从MiraiApiHttp消息记录中删除)
func (*Bot) PeekMessage ¶
获取bot接收到的最老消息和最老各类事件(不会从MiraiApiHttp消息记录中删除)
func (*Bot) Release ¶ added in v0.2.0
使用此方式释放session及其相关资源(Bot不会被释放),不使用的Session应当被释放
长时间(30分钟)未使用的Session将自动释放,否则Session持续保存Bot收到的消息,将会导致内存泄露
开启websocket后将不会自动释放,请务必定期释放
func (*Bot) ReleaseAndReauth ¶ added in v0.2.0
func (*Bot) SendFriendMessage ¶
func (b *Bot) SendFriendMessage(qq model.QQId, mc model.MsgChain, quoteId model.MsgId) (model.MsgId, error)
向指定好友发送消息,quoteId不为0时使用回复
func (*Bot) SendGroupMessage ¶
func (b *Bot) SendGroupMessage(group model.GroupId, mc model.MsgChain, quoteId model.MsgId) (model.MsgId, error)
向指定群发送消息,quoteId不为0时使用回复
func (*Bot) SendImageMessage ¶
向指定对象(群或好友)发送图片消息(通过url)
除非需要通过此手段获取imageId,否则不推荐使用该接口
当qq和group同时存在时,表示发送临时会话图片(默认为0)
func (*Bot) SendTempMessage ¶
func (b *Bot) SendTempMessage(qq model.QQId, group model.GroupId, mc model.MsgChain, quoteId model.MsgId) (model.MsgId, error)
向临时会话对象发送消息,quoteId不为0时使用回复
func (*Bot) SessionKey ¶ added in v0.2.0
func (*Bot) SetGroupConfig ¶
修改群设置(需要有相关限权)
func (*Bot) SetMemberInfo ¶
修改群员资料(需要有相关限权)
func (*Bot) SetSessionKey ¶ added in v0.2.0
func (*Bot) UploadImage ¶
func (b *Bot) UploadImage(t string, path string) (*ImgUploadResp, error)
上传图片文件至服务器并返回ImageId
func (*Bot) Use ¶ added in v0.2.0
func (b *Bot) Use(handlers ...HandlerFunc)
type BotConfig ¶ added in v0.2.0
type BotConfig struct { Host string // http://Host[:Port?] AuthKey string // authkey for remote mirai client Id model.QQId CacheSize int Websocket bool // 是否使用ws(推荐) RecvMode Mode // M_EVENT, M_MESSAGE, M_EVENT|M_MESSAGE (仅对ws有效) FetchMount int // 使用轮询时每次fetch的信息条数 Debug bool // 开启debug模式 Strict bool // 严格模式下保证按收到的消息的顺序处理消息 (可能造成性能下降) }
type BotInvitedJoinGroupReply ¶
type BotInvitedJoinGroupReply DefaultEventReply
type Context ¶ added in v0.2.0
type DefaultEventReply ¶
type DefaultResp ¶
type HandlerFunc ¶ added in v0.2.0
type HandlerFunc func(ctx *Context)
type HandlersChan ¶ added in v0.2.0
type HandlersChan []HandlerFunc
type ImgUploadResp ¶
type MemberJoinReply ¶
type MemberJoinReply DefaultEventReply
type MuteOrUnmuteReq ¶
type NewFriendReply ¶
type NewFriendReply DefaultEventReply
type SendImgMsgReq ¶
type SendMsgReq ¶
type SendMsgResp ¶
type SendMsgResp struct { DefaultResp MessageId model.MsgId `json:"messageId"` }
type SetGroupConfigReq ¶
type SetGroupConfigReq struct { SessionKey string `json:"sessionKey"` Target model.GroupId `json:"target"` Config model.GroupConfig `json:"config"` }