bot

package
v0.0.0-...-778c210 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2023 License: AGPL-3.0, AGPL-3.0-or-later Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LoginMethodToken  = "token"
	LoginMethodQRCode = "qrcode"
	LoginMethodCommon = "common"
)
View Source
const (
	AndroidPhone = protocol(client.AndroidPhone)
	IPad         = protocol(client.IPad)
	AndroidWatch = protocol(client.AndroidWatch)
	MacOS        = protocol(client.MacOS)
)

Variables

View Source
var ErrSMSRequestError = errors.New("sms request error")

ErrSMSRequestError SMS请求出错

Functions

func CommonLogin

func CommonLogin() error

CommonLogin 普通账号密码登录

func GenRandomDevice

func GenRandomDevice()

GenRandomDevice 生成随机设备信息

func Init

func Init()

Init 快速初始化 使用 config.GlobalConfig 初始化账号 使用 ./device.json 初始化设备信息

func InitBot

func InitBot(account int64, password string)

InitBot 使用 account password 进行初始化账号

func InitWithDeviceJSONContent

func InitWithDeviceJSONContent(deviceJSONContent []byte)

func InitWithOption

func InitWithOption(option InitOption) error

func Login

func Login() error

Login 登录

func LoginWithOption

func LoginWithOption(option LoginOption) error

func QrcodeLogin

func QrcodeLogin() error

QrcodeLogin 扫码登陆

func RefreshList

func RefreshList()

RefreshList 刷新联系人

func RegisterModule

func RegisterModule(instance Module)

RegisterModule - 向全局添加 Module

func SaveToken

func SaveToken()

SaveToken 会话缓存

func StartService

func StartService()

StartService 启动服务 根据 Module 生命周期 此过程应在Login前调用 请勿重复调用

func Stop

func Stop()

Stop 停止所有服务 调用此函数并不会使Bot离线

func UseDevice

func UseDevice(device []byte) error

UseDevice 使用 device 进行初始化设备信息

func UseProtocol

func UseProtocol(p protocol)

UseProtocol 使用协议 不同协议会有部分功能无法使用 默认为 AndroidPad

Types

type Bot

type Bot struct {
	*client.QQClient
	// contains filtered or unexported fields
}

Bot 全局 Bot

var Instance *Bot

Instance Bot 实例

func (*Bot) OnDisconnected deprecated

func (bot *Bot) OnDisconnected(f func(qqClient *client.QQClient, event *client.ClientDisconnectedEvent))

Deprecated: This function is designed to make the framework compatible with the old plug-in, and the newly developed plug-in should no longer use this method

func (*Bot) OnFriendMessageRecalled deprecated

func (bot *Bot) OnFriendMessageRecalled(f func(qqClient *client.QQClient, event *client.FriendMessageRecalledEvent))

Deprecated: This function is designed to make the framework compatible with the old plug-in, and the newly developed plug-in should no longer use this method

func (*Bot) OnFriendNotify deprecated

func (bot *Bot) OnFriendNotify(f func(qqClient *client.QQClient, event client.INotifyEvent))

Deprecated: This function is designed to make the framework compatible with the old plug-in, and the newly developed plug-in should no longer use this method

func (*Bot) OnGroupDigest deprecated

func (bot *Bot) OnGroupDigest(f func(qqClient *client.QQClient, event *client.GroupDigestEvent))

Deprecated: This function is designed to make the framework compatible with the old plug-in, and the newly developed plug-in should no longer use this method

func (*Bot) OnGroupInvited deprecated

func (bot *Bot) OnGroupInvited(f func(qqClient *client.QQClient, event *client.GroupInvitedRequest))

Deprecated: This function is designed to make the framework compatible with the old plug-in, and the newly developed plug-in should no longer use this method

func (*Bot) OnGroupJoin deprecated

func (bot *Bot) OnGroupJoin(f func(qqClient *client.QQClient, event *client.GroupInfo))

Deprecated: This function is designed to make the framework compatible with the old plug-in, and the newly developed plug-in should no longer use this method

func (*Bot) OnGroupLeave deprecated

func (bot *Bot) OnGroupLeave(f func(qqClient *client.QQClient, event *client.GroupLeaveEvent))

Deprecated: This function is designed to make the framework compatible with the old plug-in, and the newly developed plug-in should no longer use this method

func (*Bot) OnGroupMemberJoin deprecated

func (bot *Bot) OnGroupMemberJoin(f func(qqClient *client.QQClient, event *client.MemberJoinGroupEvent))

Deprecated: This function is designed to make the framework compatible with the old plug-in, and the newly developed plug-in should no longer use this method

func (*Bot) OnGroupMemberLeave deprecated

func (bot *Bot) OnGroupMemberLeave(f func(qqClient *client.QQClient, event *client.MemberLeaveGroupEvent))

Deprecated: This function is designed to make the framework compatible with the old plug-in, and the newly developed plug-in should no longer use this method

func (*Bot) OnGroupMemberPermissionChanged deprecated

func (bot *Bot) OnGroupMemberPermissionChanged(f func(qqClient *client.QQClient, event *client.MemberPermissionChangedEvent))

Deprecated: This function is designed to make the framework compatible with the old plug-in, and the newly developed plug-in should no longer use this method

func (*Bot) OnGroupMessage deprecated

func (bot *Bot) OnGroupMessage(f func(qqClient *client.QQClient, event *message.GroupMessage))

Deprecated: This function is designed to make the framework compatible with the old plug-in, and the newly developed plug-in should no longer use this method

func (*Bot) OnGroupMessageRecalled deprecated

func (bot *Bot) OnGroupMessageRecalled(f func(qqClient *client.QQClient, event *client.GroupMessageRecalledEvent))

Deprecated: This function is designed to make the framework compatible with the old plug-in, and the newly developed plug-in should no longer use this method

func (*Bot) OnGroupMuted deprecated

func (bot *Bot) OnGroupMuted(f func(qqClient *client.QQClient, event *client.GroupMuteEvent))

Deprecated: This function is designed to make the framework compatible with the old plug-in, and the newly developed plug-in should no longer use this method

func (*Bot) OnGroupNameUpdated deprecated

func (bot *Bot) OnGroupNameUpdated(f func(qqClient *client.QQClient, event *client.GroupNameUpdatedEvent))

Deprecated: This function is designed to make the framework compatible with the old plug-in, and the newly developed plug-in should no longer use this method

func (*Bot) OnGroupNotify deprecated

func (bot *Bot) OnGroupNotify(f func(qqClient *client.QQClient, event client.INotifyEvent))

Deprecated: This function is designed to make the framework compatible with the old plug-in, and the newly developed plug-in should no longer use this method

func (*Bot) OnMemberCardUpdated deprecated

func (bot *Bot) OnMemberCardUpdated(f func(qqClient *client.QQClient, event *client.MemberCardUpdatedEvent))

Deprecated: This function is designed to make the framework compatible with the old plug-in, and the newly developed plug-in should no longer use this method

func (*Bot) OnMemberSpecialTitleUpdated deprecated

func (bot *Bot) OnMemberSpecialTitleUpdated(f func(qqClient *client.QQClient, event *client.MemberSpecialTitleUpdatedEvent))

Deprecated: This function is designed to make the framework compatible with the old plug-in, and the newly developed plug-in should no longer use this method

func (*Bot) OnNewFriend deprecated

func (bot *Bot) OnNewFriend(f func(qqClient *client.QQClient, event *client.NewFriendEvent))

Deprecated: This function is designed to make the framework compatible with the old plug-in, and the newly developed plug-in should no longer use this method

func (*Bot) OnNewFriendRequest deprecated

func (bot *Bot) OnNewFriendRequest(f func(qqClient *client.QQClient, event *client.NewFriendRequest))

Deprecated: This function is designed to make the framework compatible with the old plug-in, and the newly developed plug-in should no longer use this method

func (*Bot) OnOfflineFile deprecated

func (bot *Bot) OnOfflineFile(f func(qqClient *client.QQClient, event *client.OfflineFileEvent))

Deprecated: This function is designed to make the framework compatible with the old plug-in, and the newly developed plug-in should no longer use this method

func (*Bot) OnOtherClientStatusChanged deprecated

func (bot *Bot) OnOtherClientStatusChanged(f func(qqClient *client.QQClient, event *client.OtherClientStatusChangedEvent))

Deprecated: This function is designed to make the framework compatible with the old plug-in, and the newly developed plug-in should no longer use this method

func (*Bot) OnPrivateMessage deprecated

func (bot *Bot) OnPrivateMessage(f func(qqClient *client.QQClient, event *message.PrivateMessage))

Deprecated: This function is designed to make the framework compatible with the old plug-in, and the newly developed plug-in should no longer use this method

func (*Bot) OnPrivateMessageF deprecated

func (bot *Bot) OnPrivateMessageF(filter func(*message.PrivateMessage) bool, f func(*client.QQClient, *message.PrivateMessage))

Deprecated: This function is designed to make the framework compatible with the old plug-in, and the newly developed plug-in should no longer use this method

func (*Bot) OnSelfGroupMessage deprecated

func (bot *Bot) OnSelfGroupMessage(f func(qqClient *client.QQClient, event *message.GroupMessage))

Deprecated: This function is designed to make the framework compatible with the old plug-in, and the newly developed plug-in should no longer use this method

func (*Bot) OnSelfPrivateMessage deprecated

func (bot *Bot) OnSelfPrivateMessage(f func(qqClient *client.QQClient, event *message.PrivateMessage))

Deprecated: This function is designed to make the framework compatible with the old plug-in, and the newly developed plug-in should no longer use this method

func (*Bot) OnTempMessage deprecated

func (bot *Bot) OnTempMessage(f func(qqClient *client.QQClient, event *client.TempMessageEvent))

Deprecated: This function is designed to make the framework compatible with the old plug-in, and the newly developed plug-in should no longer use this method

func (*Bot) OnUserWantJoinGroup deprecated

func (bot *Bot) OnUserWantJoinGroup(f func(qqClient *client.QQClient, event *client.UserJoinGroupRequest))

Deprecated: This function is designed to make the framework compatible with the old plug-in, and the newly developed plug-in should no longer use this method

type InitOption

type InitOption struct {
	Account           int64
	Password          string
	DeviceJSONContent []byte //cannot be nil if using option init
}

type LoginMethod

type LoginMethod string

type LoginOption

type LoginOption struct {
	LoginMethod              LoginMethod
	Token                    []byte //if not nil, try with most priority
	UseTokenWhenUnmatchedUin bool
}

type Module

type Module interface {
	MiraiGoModule() ModuleInfo

	// Init 初始化
	// 待所有 Module 初始化完成后
	// 进行服务注册 Serve
	Init()

	// PostInit 第二次初始化
	// 调用该函数时,所有 Module 都已完成第一段初始化过程
	// 方便进行跨Module调用
	PostInit()

	// Serve 向Bot注册服务函数
	// 结束后调用 Start
	Serve(bot *Bot)

	// Start 启用Module
	// 此处调用为
	// “` go
	// go Start()
	// “`
	// 结束后进行登录
	Start(bot *Bot)

	// Stop 应用结束时对所有 Module 进行通知
	// 在此进行资源回收
	Stop(bot *Bot, wg *sync.WaitGroup)
}

Module MiraiGo 中的模块 用于进行模块化设计

type ModuleID

type ModuleID string

ModuleID 模块ID 请使用 小写 并用 _ 代替空格 Example: - logiase.autoreply

func (ModuleID) Name

func (id ModuleID) Name() string

Name - 获取一个 Module 的 Name

func (ModuleID) Namespace

func (id ModuleID) Namespace() string

Namespace - 获取一个 Module 的 Namespace

type ModuleInfo

type ModuleInfo struct {
	// ID 模块的名称
	// 应全局唯一
	ID ModuleID

	// Instance 返回 Module
	Instance Module
}

ModuleInfo 模块信息

func GetModule

func GetModule(name string) (ModuleInfo, error)

GetModule - 获取一个已注册的 Module 的 ModuleInfo

func (ModuleInfo) String

func (mi ModuleInfo) String() string

Jump to

Keyboard shortcuts

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