data

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AppDir string

AppDir 当前插件数据目录

View Source
var Config struct {
	// 游戏群
	GroupID int64
	// 管理群
	AdminID int64
	// 管理员
	Administrators []int64
	// 处理进群请求
	DealWithGroupRequest struct {
		Enable    bool
		CanReject bool
		CheckURL  string
		Token     string
	}

	// 数据库配置
	Database struct {
		Driver string
		Source string
	}

	// MC服务器远程控制台
	RCON struct {
		Address  string
		Password string
	}
	// Ping工具配置
	Ping struct {
		DefaultServer string
		Timeout       duration
	}

	// 自定义命令
	Cmd map[string]struct {
		Level     int64  // 所需权限
		Command   string // 指令本身
		Silent    bool   // 是否不回显
		AllowArgs bool   // 是否允许使用参数
	}
}
View Source
var Logger interface {
	Error(str string)
	Errorf(format string, args ...interface{})

	Waring(str string)
	Waringf(format string, args ...interface{})

	Info(str string)
	Infof(format string, args ...interface{})

	Debug(str string)
	Debugf(format string, args ...interface{})
}

Functions

func AddWhitelist

func AddWhitelist(name string) error

AddWhitelist 从游戏服务器添加白名单

func Close

func Close() error

Close 关闭所有打开的资源

func GetLevel

func GetLevel(QQ int64) (level int64, err error)

GetLevel 获取某人的权限等级

func GetWhitelistByQQ

func GetWhitelistByQQ(QQ int64) (id uuid.UUID, err error)

GetWhitelistByQQ 从数据库读取玩家绑定的ID,若没有绑定ID则返回uuid.Nil

func GetWhitelistByUUID

func GetWhitelistByUUID(ID uuid.UUID) (qq int64, err error)

GetWhitelistByUUID 从数据库读取绑定ID的玩家,若ID没有被绑定则则返回0

func Init

func Init(dir string) error

Init 初始化插件的数据源,包括读取配置文件、建立数据库连接

func RCONCmd

func RCONCmd(cmd string, ret func(string)) error

RCONCmd 执行RCON命令,每次都创建一个连接。 当ret不为nil时,通过回调方式返回RCON执行结果,ret可能被调用多次。

func RemoveWhitelist

func RemoveWhitelist(name string) error

RemoveWhitelist 从游戏服务器删除白名单

func SetLevel

func SetLevel(QQ, level int64) (err error)

SetLevel 设置某人的权限等级

func SetWhitelist

func SetWhitelist(QQ int64, ID uuid.UUID, onOldID func(oldID uuid.UUID) error, onSuccess func() error) (owner int64, err error)

SetWhitelist 尝试向数据库写入白名单数据,当ID未被占用时返回自己的QQ,当ID被占用则返回占用者的QQ 若原本该账号占有一个UUID,则会返回当时的UUID

func UnsetWhitelist

func UnsetWhitelist(QQ int64, onHas func(ID uuid.UUID) error) error

UnsetWhitelist 从数据库获取玩家绑定的ID,返回UUID并删除记录

Types

This section is empty.

Jump to

Keyboard shortcuts

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