Documentation
¶
Index ¶
- type AuthResponse
- type Bot
- func (bot *Bot) FetchMessage() error
- func (bot *Bot) FriendList() ([]*Friend, error)
- func (bot *Bot) GetGroupConfig(group int64) (*GroupConfig, error)
- func (bot *Bot) GetGroupMemberInfo(group, member int64) (*GroupMemberInfo, error)
- func (bot *Bot) GroupList() ([]*Group, error)
- func (bot *Bot) InitChannel(size int, t time.Duration)
- func (bot *Bot) Kick(group int64, member int64, msg string) error
- func (bot *Bot) MemberList(group int64) ([]*GroupMember, error)
- func (bot *Bot) MessageFromID(id int64) (*InEvent, error)
- func (bot *Bot) Mute(group int64, member int64, second int64) error
- func (bot *Bot) MuteAll(group int64) error
- func (bot *Bot) Recall(target int64) error
- func (bot *Bot) RefreshFriendList() ([]*Friend, error)
- func (bot *Bot) RefreshGroupList() ([]*Group, error)
- func (bot *Bot) Release() error
- func (bot *Bot) SendFriendMessage(target, quote int64, msg []Message) (int64, error)
- func (bot *Bot) SendGroupMessage(target, quote int64, msg []Message) (int64, error)
- func (bot *Bot) SendImageMessage(target int64, targetType string, urls []string) ([]string, error)
- func (bot *Bot) SetGroupConfig(config GroupConfig, group int64) error
- func (bot *Bot) SetGroupMemberInfo(info *GroupMemberInfo, group, member int64) error
- func (bot *Bot) UnmuteAll(group int64) error
- type Client
- func (client *Client) Auth() (session string, err error)
- func (client *Client) GetManagers(qq int64) (*[]int64, error)
- func (client *Client) GetSessionConfig(session string) (*SessionConfig, error)
- func (client *Client) ReleaseAllSession()
- func (client *Client) SendCommand(commandName string, args []string) string
- func (client *Client) SetSessionConfig(config *SessionConfig) error
- func (client *Client) Verify(qq int64) (*Bot, error)
- type CommonCall
- type Friend
- type Group
- type GroupConfig
- type GroupMember
- type GroupMemberInfo
- type InEvent
- type InEventAll
- type Message
- type MessageCall
- type Response
- type SessionConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthResponse ¶
AuthResponse 认证响应
type Bot ¶
type Bot struct {
Client *Client
QQ int64
MessageChan chan InEvent
Session string
// contains filtered or unexported fields
}
Bot qq机器人
func (*Bot) FetchMessage ¶
FetchMessage 获取消息,会阻塞当前线程,消息保存在bot中的MessageChan 使用前请使用InitChannel初始化Channel
func (*Bot) FriendList ¶
FriendList 获取Bot的好友列表 会获取本地缓存的好友列表,如需刷新请使用RefreshFriendList 没有缓存时会自动刷新
func (*Bot) GetGroupConfig ¶
func (bot *Bot) GetGroupConfig(group int64) (*GroupConfig, error)
GetGroupConfig 获取群设置
func (*Bot) GetGroupMemberInfo ¶
func (bot *Bot) GetGroupMemberInfo(group, member int64) (*GroupMemberInfo, error)
GetGroupMemberInfo 获取群成员信息
func (*Bot) InitChannel ¶
InitChannel 初始化消息管道 size 缓存数量 t 每次Fetch的时间间隔
func (*Bot) MemberList ¶
func (bot *Bot) MemberList(group int64) ([]*GroupMember, error)
MemberList 指定群内的群成员
func (*Bot) MessageFromID ¶
MessageFromID 通过ID获取一条缓存的消息
func (*Bot) RefreshFriendList ¶
RefreshFriendList 刷新好友列表
func (*Bot) RefreshGroupList ¶
RefreshGroupList 刷新群列表s
func (*Bot) Release ¶
Release 使用此方式释放session及其相关资源(Bot不会被释放) 不使用的Session应当被释放,长时间(30分钟)未使用的Session将自动释放,否则Session持续保存Bot收到的消息,将会导致内存泄露
func (*Bot) SendFriendMessage ¶
SendFriendMessage 使用此方法向指定好友发送消息 如果不需要引用回复,quote设0
func (*Bot) SendGroupMessage ¶
SendGroupMessage 使用此方法向指定群发送消息
func (*Bot) SendImageMessage ¶
SendImageMessage 使用此方法向指定对象(群或好友)发送图片消息 除非需要通过此手段获取imageId,否则不推荐使用该接口
func (*Bot) SetGroupConfig ¶
func (bot *Bot) SetGroupConfig(config GroupConfig, group int64) error
SetGroupConfig 设置群设置
func (*Bot) SetGroupMemberInfo ¶
func (bot *Bot) SetGroupMemberInfo(info *GroupMemberInfo, group, member int64) error
SetGroupMemberInfo 设置群成员信息
type Client ¶
type Client struct {
Address string
// 可以对HTTPClient进行自定义配置
HTTPClient http.Client
Bots map[int64]*Bot
// contains filtered or unexported fields
}
Client 用于服务的Client
func NewMiraiClient ¶
NewMiraiClient 创建一个新的Client
func (*Client) GetManagers ¶
GetManagers 获取指定bot的Managers
func (*Client) GetSessionConfig ¶
func (client *Client) GetSessionConfig(session string) (*SessionConfig, error)
GetSessionConfig 获取Session的设置
func (*Client) ReleaseAllSession ¶
func (client *Client) ReleaseAllSession()
ReleaseAllSession 释放所有会话
func (*Client) SendCommand ¶
SendCommand 发送指令
func (*Client) SetSessionConfig ¶
func (client *Client) SetSessionConfig(config *SessionConfig) error
SetSessionConfig 设置Session
type Friend ¶
type Friend struct {
ID int64 `json:"id"`
NickName string `json:"nickName"`
Remark string `json:"remark"`
}
Friend 好友
type Group ¶
type Group struct {
ID int64 `json:"id"`
Name string `json:"name"`
Permission string `json:"permission"`
}
Group 群
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"`
}
GroupConfig 群设置
type GroupMember ¶
type GroupMember struct {
ID int64 `json:"id"`
MemberName string `json:"memberName"`
Permission string `json:"permission"`
Group Group `json:"group"`
}
GroupMember 群成员
type GroupMemberInfo ¶
GroupMemberInfo 群成员信息
type InEvent ¶
type InEvent struct {
Type string `json:"type"`
QQ int64 `json:"qq,omitempty"`
// Event
AuthorID int64 `json:"authorId,omitempty"`
MessageID int64 `json:"messageId,omitempty"`
Time int64 `json:"time,omitempty"`
Group Group `json:"group,omitempty"`
Origin interface{} `json:"origin,omitempty"`
Current interface{} `json:"current,omitempty"`
DurationSeconds int64 `json:"durationSeconds,omitempty"`
IsByBot bool `json:"isByBot,omitempty"`
Member GroupMember `json:"member,omitempty"`
//Message
MessageChain []Message `json:"messageChain,omitempty"`
Sender interface{} `json:"sender,omitempty"`
SenderGroup GroupMember `json:"-"`
SenderFriend Friend `json:"-"`
Operator interface{} `json:"operator,omitempty"` // Operator 可能是GroupMember或int64
OperatorGroup GroupMember `json:"-"`
OperatorFriend int64 `json:"-"`
}
InEvent 获取到的事件
func (*InEvent) OperatorDetail ¶
OperatorDetail 获取Operator的详细信息
type InEventAll ¶
type InEventAll struct {
Code int64 `json:"code"`
ErrorMessage string `json:"errorMessage,omitempty"`
Data []InEvent `json:"data,omitempty"`
}
InEvent http-api新返回格式
type Message ¶
type Message struct {
Type string `json:"type"`
ID int64 `json:"id,omitempty" message:"Source|Quote"`
Text string `json:"text,omitempty" message:"Plain"`
Time int64 `json:"time,omitempty" message:"Source"`
GroupID int64 `json:"groupId,omitempty" message:"Quote"`
SenderID int64 `json:"senderId,omitempty" message:"Quote"`
Origin []Message `json:"origin,omitempty" message:"Quote"`
Target int64 `json:"target,omitempty" message:"At"`
Display string `json:"display,omitempty" message:"At"`
FaceID int64 `json:"faceId,omitempty" message:"Face"`
Name string `json:"name,omitempty" message:"Face"`
ImageID string `json:"imageId,omitempty" message:"Image"`
URL string `json:"url,omitempty" message:"Image"`
Path string `json:"path,omitempty" message:"Image"`
XML string `json:"xml,omitempty" message:"Xml"`
JSON string `json:"json,omitempty" message:"Json"`
Content string `json:"content,omitempty" message:"App"`
}
Message 消息
type MessageCall ¶
type MessageCall struct {
CommonCall
Target int64 `json:"target"`
MessageChain []Message `json:"messageChain"`
}
MessageCall 消息用
type Response ¶
type Response struct {
Code int `json:"code"`
Msg string `json:"msg"`
MessageID int64 `json:"messageId,omitempty"`
}
Response 通用响应
type SessionConfig ¶
type SessionConfig struct {
SessionKey string `json:"sessionKey,omitempty"`
CacheSize int64 `json:"cacheSize"`
EnableWebsocket bool `json:"enableWebsocket"`
}
SessionConfig Session设置