bot

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2020 License: AGPL-3.0 Imports: 11 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bot

type Bot struct {
	QQ         uint
	SessionKey string

	Client *Client

	Logger *logrus.Entry

	Chan chan message.Event

	Friends []message.Friend
	Groups  []message.Group
	// contains filtered or unexported fields
}

Bot 对应一个机器人账号 进行所有对账号相关操作

func (*Bot) FetchMessages

func (b *Bot) FetchMessages() error

FetchMessages 获取消息

func (*Bot) FriendList

func (b *Bot) FriendList() error

FriendList 使用此方法获取bot的好友列表

func (*Bot) GetGroupConfig

func (b *Bot) GetGroupConfig(target int64) (message.GroupConfig, error)

GetGroupConfig 使用此方法获取群设置

func (*Bot) GetMemberInfo

func (b *Bot) GetMemberInfo(target, memberID int64) (message.MemberInfo, error)

GetMemberInfo 使用此方法获取群员资料

func (*Bot) GroupConfig

func (b *Bot) GroupConfig(target int64, config message.GroupConfig) error

GroupConfig 使用此方法修改群设置(需要有相关限权)

func (*Bot) GroupList

func (b *Bot) GroupList() error

GroupList 使用此方法获取bot的群列表

func (*Bot) Kick

func (b *Bot) Kick(target, memberID int64, msg string) error

Kick 使用此方法移除指定群成员(需要有相关限权)

func (*Bot) MemberInfo

func (b *Bot) MemberInfo(target, memberID int64, info message.MemberInfo) error

MemberInfo 使用此方法修改群员资料(需要有相关限权)

func (*Bot) MemberList

func (b *Bot) MemberList(target int64) ([]message.Sender, error)

MemberList 使用此方法获取bot指定群种的成员列表

func (*Bot) Mute

func (b *Bot) Mute(target, memberID, time int64) error

Mute 使用此方法指定群禁言指定群员(需要有相关限权)

func (*Bot) MuteAll

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

MuteAll 使用此方法令指定群进行全体禁言(需要有相关限权)

func (*Bot) Quit

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

Quit 使用此方法使Bot退出群聊

func (*Bot) Recall

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

Recall 使用此方法撤回指定消息 对于bot发送的消息,有2分钟时间限制。对于撤回群聊中群员的消息,需要有相应权限 target 消息id

func (*Bot) RespondMemberJoinRequest

func (b *Bot) RespondMemberJoinRequest(eventID, fromID, groupID int64, operate int, message string) error

RespondMemberJoinRequest 响应用户加群请求 operate 说明 0 同意入群 1 拒绝入群 2 忽略请求 3 拒绝入群并添加黑名单,不再接收该用户的入群申请 4 忽略入群并添加黑名单,不再接收该用户的入群申请

func (*Bot) SendFriendMessage

func (b *Bot) SendFriendMessage(qq, quote uint, msg ...message.Message) (uint, error)

SendFriendMessage 使用此方法向指定好友发送消息 qq 好友qq quote 引用消息id 0为不引用 msg 消息内容

func (*Bot) SendGroupMessage

func (b *Bot) SendGroupMessage(group, quote uint, msg ...message.Message) (uint, error)

SendGroupMessage 使用此方法向指定群发送消息 group 群qq quote 引用消息id 0为不引用 msg 消息内容

func (*Bot) SendImageMessage

func (b *Bot) SendImageMessage(qq, group int64, urls ...string) (imageIds []string, err error)

SendImageMessage 使用此方法向指定对象(群或好友)发送图片消息 除非需要通过此手段获取imageId,否则不推荐使用该接口 请保证 qq group 不同时有值

func (*Bot) SendTempMessage

func (b *Bot) SendTempMessage(group, qq uint, msg ...message.Message) (uint, error)

SendTempMessage 使用此方法向临时会话对象发送消息 qq 好友qq group 群qq msg 消息内容

func (*Bot) SetChannel

func (b *Bot) SetChannel(time time.Duration, size int)

SetChannel Channel相关设置

func (*Bot) UnMute

func (b *Bot) UnMute(target, memberID int64) error

UnMute 使用此方法指定群解除群成员禁言(需要有相关限权)

func (*Bot) UnMuteAll

func (b *Bot) UnMuteAll(target int64) error

UnMuteAll 使用此方法令指定群解除全体禁言(需要有相关限权)

func (*Bot) UploadImage

func (b *Bot) UploadImage(t string, imgFilepath string) (string, error)

UploadImage 使用此方法上传图片文件至服务器并返回ImageId

type Client

type Client struct {
	Name    string
	AuthKey string

	HttpClient *gentleman.Client
	Bots       map[uint]*Bot

	Logger *logrus.Entry
}

Client 与Mirai进行沟通

func NewClient

func NewClient(name, url, authKey string) *Client

NewClient 新建Client

func (*Client) About

func (c *Client) About() (string, error)

About 使用此方法获取插件的信息,如版本号

func (*Client) Auth

func (c *Client) Auth() (string, error)

Auth 使用此方法验证你的身份,并返回一个会话

func (*Client) Release

func (c *Client) Release(qq uint) error

Release 使用此方式释放session及其相关资源(Bot不会被释放) 不使用的Session应当被释放,长时间(30分钟)未使用的Session将自动释放,否则Session持续保存Bot收到的消息,将会导致内存泄露(开启websocket后将不会自动释放)

func (*Client) Verify

func (c *Client) Verify(qq uint, sessionKey string) (*Bot, error)

Verify 使用此方法校验并激活你的Session,同时将Session与一个已登录的Bot绑定

Jump to

Keyboard shortcuts

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