utility

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2022 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	COSSecretID        = os.Getenv("COS_SECRET_ID")
	COSSecretKey       = os.Getenv("COS_SECRET_KEY")
	COSBaseURL         = os.Getenv("COS_BASE_URL")
	COSBucketRegionURL = os.Getenv("COS_BUCKET_REGION_URL")
)

var cosBucket = "kevinmatt-1303917904"

View Source
var (
	ZapLogger   *zaplog.ZapLogger
	SugerLogger *zaplog.ZapLoggerSugar
)

var ZapLog日志变量

View Source
var GlowSansSC *truetype.Font

GlowSansSC 字体类型,未来荧黑

Functions

func BuildCardMessageCols added in v0.0.5

func BuildCardMessageCols(titleK, titleV string, kvMap map[string]interface{}) (res []interface{}, err error)

BuildCardMessageCols 创建卡片消息的列

func CheckIsAdmin added in v1.0.1

func CheckIsAdmin(userID string) (isAdmin bool)

CheckIsAdmin 检查是否是管理员

@param userID
@return isAdmin

func ForDebug

func ForDebug(test ...interface{})

ForDebug 用于测试

func GetAdminLevel added in v1.0.1

func GetAdminLevel(userID string) int

GetAdminLevel 获取管理员等级

@param userID
@return level

func GetChannnelInfo added in v0.0.5

func GetChannnelInfo(channelID string) (channelInfo *khl.Channel, err error)

GetChannnelInfo 获取频道信息

@param channelID
@return channelInfo
@return err

func GetCommandWithParameters added in v1.0.1

func GetCommandWithParameters(rawCommand string) (command string, params []string)

GetCommandWithParameters 获取命令及参数

@param rawCommand
@return command
@return params

func GetCurrentTime

func GetCurrentTime() (localTime string)

GetCurrentTime 获取当前时间

func GetDbConnection added in v1.0.1

func GetDbConnection() *gorm.DB

GetDbConnection returns the db connection

@return *gorm.DB

func GetGuildInfo added in v0.0.5

func GetGuildInfo(guildID string) (guildInfo *khl.Guild, err error)

GetGuildInfo 获取公会信息

@param guildID
@return guildInfo
@return err

func GetOutBoundIP

func GetOutBoundIP() (ip string, err error)

GetOutBoundIP 获取机器人部署的当前ip

func GetUserInfo added in v0.0.5

func GetUserInfo(userID, guildID string) (userInfo *khl.User, err error)

GetUserInfo 获取用户信息

@param userID
@param guildID
@return userInfo

func InitGlowSansSCFontType added in v1.0.1

func InitGlowSansSCFontType()

InitGlowSansSCFontType 初始化字体类型

func InitLogger added in v1.0.1

func InitLogger()

InitLogger 初始化日志

func IsInSlice

func IsInSlice(target string, slice []string) bool

IsInSlice 判断机器人是否被at到

@param target
@param slice
@return bool

func MustAtoI added in v0.0.5

func MustAtoI(str string) int

MustAtoI 将字符串转换为int

@param str
@return int

func SendMessage added in v1.0.1

func SendMessage(targetID, QuoteID, authorID string, message string)

SendMessage 发送消息

@param targetID 目标ID
@param QuoteID 引用ID
@param authorID 作者ID
@param err 错误信息

func SendMessageTemp added in v1.0.1

func SendMessageTemp(targetID, QuoteID, authorID string, message string)

SendMessageTemp 发送消息

@param targetID 目标ID
@param QuoteID 引用ID
@param authorID 作者ID
@param err 错误信息

func Struct2Map added in v0.0.5

func Struct2Map(obj interface{}) map[string]interface{}

Struct2Map 将结构体转换为map

@param obj
@return map

func UploadFileToCos added in v1.0.1

func UploadFileToCos(filePath string) (linkURL string, err error)

UploadFileToCos 将文件上传到cos

Types

type Administrator added in v1.0.1

type Administrator struct {
	gorm.Model
	UserID   int64  `json:"user_id"`
	UserName string `json:"user_name"`
	Level    int64  `json:"level"`
}

Administrator is the struct of administrator

type ChannelLog added in v1.0.1

type ChannelLog struct {
	UserID      string    `json:"user_id"`
	UserName    string    `json:"user_name"`
	ChannelID   string    `json:"channel_id"`
	ChannelName string    `json:"channel_name"`
	JoinedTime  time.Time `json:"joined_time"`
	LeftTime    time.Time `json:"left_time"`
	ISUpdate    bool      `json:"is_update"`
}

ChannelLog is the struct of channel log

func (*ChannelLog) AddJoinedRecord added in v1.0.1

func (cl *ChannelLog) AddJoinedRecord() error

AddJoinedRecord 添加加入记录

@receiver cl
@return error

func (*ChannelLog) UpdateLeftTime added in v1.0.1

func (cl *ChannelLog) UpdateLeftTime() error

UpdateLeftTime 更新离开时间

@receiver cl
@return error

type CommandInfo added in v1.0.1

type CommandInfo struct {
	CommandName     string    `json:"command_name" gorm:"primaryKey;autoIncrement:false"`
	CommandDesc     string    `json:"command_desc"`
	CommandParamLen int       `json:"command_param_len"`
	CommandType     string    `json:"command_type"`
	CreatedAt       time.Time `json:"created_at" gorm:"autoCreateTime"`
	UpdatedAt       time.Time `json:"updated_at" gorm:"autoUpdateTime"`
}

CommandInfo is the struct of command info

func GetCommandInfo added in v1.0.1

func GetCommandInfo(command string) (commandInfoList []*CommandInfo, err error)

GetCommandInfo 获取命令信息

@param command
@return info

func GetCommandInfoWithOpt added in v1.0.1

func GetCommandInfoWithOpt(optionf string) (commandInfoList []*CommandInfo, err error)

GetCommandInfoWithOpt 获取命令信息

@param option
@return info

type ErrorCollector added in v1.0.1

type ErrorCollector []*error

ErrorCollector is a function that collects errors and returns the collected errors.

func (ErrorCollector) Collect added in v1.0.1

func (ec ErrorCollector) Collect(err error)

Collect adds an error to the collector.

@receiver ec
@param err

func (ErrorCollector) Error added in v1.0.1

func (ec ErrorCollector) Error() string

Error is a wrapper for the error type that implements the ErrorCollector interface.

@receiver ec
@return string

func (ErrorCollector) Errorf added in v1.0.1

func (ec ErrorCollector) Errorf(format string, args ...interface{})

Errorf is a wrapper for the error type that implements the ErrorCollector interface.

@receiver ec
@param format
@param args

func (ErrorCollector) GenErr added in v1.0.1

func (ec ErrorCollector) GenErr() error

GenErr is a wrapper for the error type that implements the ErrorCollector interface.

@receiver ec
@return error

func (ErrorCollector) NoError added in v1.0.1

func (ec ErrorCollector) NoError() bool

NoError is a wrapper for the error type that implements the ErrorCollector interface.

@receiver ec
@return bool

func (ErrorCollector) String added in v1.0.1

func (ec ErrorCollector) String() string

String is a wrapper for the string type that implements the ErrorCollector interface.

@receiver ec
@return string

Jump to

Keyboard shortcuts

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