model

package
v0.0.0-...-9415ce5 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEndpointInfoUIDEmpty = errors.New("user id is empty")

Functions

func AttrGroupGetAll

func AttrGroupGetAll(db *sqlx.DB, groupID string) []byte

func AttrGroupSave

func AttrGroupSave(db *sqlx.DB, groupID string, data []byte)

func AttrGroupUserGetAll

func AttrGroupUserGetAll(db *sqlx.DB, groupID string, userID string) []byte

func AttrGroupUserSave

func AttrGroupUserSave(db *sqlx.DB, groupID string, userID string, data []byte)

func AttrUserGetAll

func AttrUserGetAll(db *sqlx.DB, userID string) []byte

func AttrUserSave

func AttrUserSave(db *sqlx.DB, userID string, data []byte)

func BanItemDel

func BanItemDel(db *sqlx.DB, id string) error

func BanItemList

func BanItemList(db *sqlx.DB, callback func(id string, banUpdatedAt int64, data []byte)) error

func BanItemSave

func BanItemSave(db *sqlx.DB, id string, updatedAt int64, banUpdatedAt int64, data []byte) error

func CensorAppend

func CensorAppend(db *sqlx.DB, msgType string, userID string, groupID string, content string, sensitiveWords interface{}, highestLevel int) bool

func CensorClearLevelCount

func CensorClearLevelCount(db *sqlx.DB, userID string, level censor.Level)

func CensorCount

func CensorCount(db *sqlx.DB, userID string) map[censor.Level]int

func DBCacheDelete

func DBCacheDelete() bool

func DBCheck

func DBCheck(dataDir string)

func DBVacuum

func DBVacuum()

func FlushWAL

func FlushWAL(db *sqlx.DB) error

func GroupInfoListGet

func GroupInfoListGet(db *sqlx.DB, callback func(id string, updatedAt int64, data []byte)) error

func GroupInfoSave

func GroupInfoSave(db *sqlx.DB, groupID string, updatedAt int64, data []byte) error

GroupInfoSave 保存群组信息

func GroupPlayerInfoSave

func GroupPlayerInfoSave(db *sqlx.DB, groupID string, playerID string, info *GroupPlayerInfoBase) error

func GroupPlayerNumGet

func GroupPlayerNumGet(db *sqlx.DB, groupID string) (int64, error)

GroupPlayerNumGet 查询指定群组中玩家数量

func LogAppend

func LogAppend(db *sqlx.DB, groupID string, logName string, logItem *LogOneItem) bool

LogAppend 向指定的log中添加一条信息

func LogDelete

func LogDelete(db *sqlx.DB, groupID string, logName string) bool

LogDelete 删除log

func LogEditByMsgID

func LogEditByMsgID(db *sqlx.DB, groupID, logName, newContent string, rawID interface{}) error

func LogGetIDByGroupIDAndName

func LogGetIDByGroupIDAndName(db *sqlx.DB, groupID string, logName string) (logID int64, err error)

LogGetIDByGroupIDAndName 获取ID

func LogGetInfo

func LogGetInfo(db *sqlx.DB) ([]int, error)

func LogGetList

func LogGetList(db *sqlx.DB, groupID string) ([]string, error)

LogGetList 获取列表

func LogGetUploadInfo

func LogGetUploadInfo(db *sqlx.DB, groupID string, logName string) (url string, uploadTime, updateTime int64, err error)

func LogLinesCountGet

func LogLinesCountGet(db *sqlx.DB, groupID string, logName string) (int64, bool)

LogLinesCountGet 获取日志行数

func LogMarkDeleteByMsgID

func LogMarkDeleteByMsgID(db *sqlx.DB, groupID string, logName string, rawID interface{}) error

LogMarkDeleteByMsgID 撤回删除

func LogSetUploadInfo

func LogSetUploadInfo(db *sqlx.DB, groupID string, logName string, url string) error

func SQLiteCensorDBInit

func SQLiteCensorDBInit(dataDir string) (censorDB *sqlx.DB, err error)

func SQLiteDBInit

func SQLiteDBInit(dataDir string) (dataDB *sqlx.DB, logsDB *sqlx.DB, err error)

func Vacuum

func Vacuum(db *sqlx.DB, path string) error

Types

type CensorLog

type CensorLog struct {
	ID           uint64 `json:"id"`
	MsgType      string `json:"msgType"`
	UserID       string `json:"userId"`
	GroupID      string `json:"groupId"`
	Content      string `json:"content"`
	HighestLevel int    `json:"highestLevel"`
	CreatedAt    int    `json:"createdAt"`
}

func CensorGetLogPage

func CensorGetLogPage(db *sqlx.DB, params QueryCensorLog) (int, []CensorLog, error)

type EndpointInfo

type EndpointInfo struct {
	UserID      string `db:"user_id"`
	CmdNum      int64  `db:"cmd_num"`
	CmdLastTime int64  `db:"cmd_last_time"`
	OnlineTime  int64  `db:"online_time"`
	UpdatedAt   int64  `db:"updated_at"`
}

func (*EndpointInfo) Query

func (e *EndpointInfo) Query(db *sqlx.DB) error

func (*EndpointInfo) Save

func (e *EndpointInfo) Save(db *sqlx.DB) error

type GroupPlayerInfoBase

type GroupPlayerInfoBase struct {
	Name                string        `yaml:"name" jsbind:"name"` // 玩家昵称
	UserID              string        `yaml:"userId" jsbind:"userId"`
	InGroup             bool          `yaml:"inGroup"`                                          // 是否在群内,有时一个人走了,信息还暂时残留
	LastCommandTime     int64         `yaml:"lastCommandTime" jsbind:"lastCommandTime"`         // 上次发送指令时间
	RateLimiter         *rate.Limiter `yaml:"-"`                                                // 限速器
	RateLimitWarned     bool          `yaml:"-"`                                                // 是否已经警告过限速
	AutoSetNameTemplate string        `yaml:"autoSetNameTemplate" jsbind:"autoSetNameTemplate"` // 名片模板

	// level int 权限
	DiceSideNum  int                  `yaml:"diceSideNum"` // 面数,为0时等同于d100
	Vars         *PlayerVariablesItem `yaml:"-"`           // 玩家的群内变量
	ValueMapTemp lockfree.HashMap     `yaml:"-"`           // 玩家的群内临时变量

	TempValueAlias *map[string][]string `yaml:"-"` // 群内临时变量别名 - 其实这个有点怪的,为什么在这里?

	UpdatedAtTime  int64 `yaml:"-" json:"-"`
	RecentUsedTime int64 `yaml:"-" json:"-"`
}

GroupPlayerInfoBase 群内玩家信息

func GroupPlayerInfoGet

func GroupPlayerInfoGet(db *sqlx.DB, groupID string, playerID string) *GroupPlayerInfoBase

type LogInfo

type LogInfo struct {
	ID        uint64 `json:"id" db:"id"`
	Name      string `json:"name" db:"name"`
	GroupID   string `json:"groupId" db:"groupId"`
	CreatedAt int64  `json:"createdAt" db:"created_at"`
	UpdatedAt int64  `json:"updatedAt" db:"updated_at"`
	Size      int    `json:"size" db:"size"`
}

func LogGetLogPage

func LogGetLogPage(db *sqlx.DB, param *QueryLogPage) (int, []*LogInfo, error)

LogGetLogPage 获取分页

func LogGetLogs deprecated

func LogGetLogs(db *sqlx.DB) ([]*LogInfo, error)

Deprecated: replaced by page

type LogOne

type LogOne struct {
	// Version int           `json:"version,omitempty"`
	Items []LogOneItem `json:"items"`
	Info  LogInfo      `json:"info"`
}

type LogOneItem

type LogOneItem struct {
	ID          uint64      `json:"id" db:"id"`
	Nickname    string      `json:"nickname" db:"nickname"`
	IMUserID    string      `json:"IMUserId" db:"im_userid"`
	Time        int64       `json:"time" db:"time"`
	Message     string      `json:"message" db:"message"`
	IsDice      bool        `json:"isDice" db:"is_dice"`
	CommandID   int64       `json:"commandId" db:"command_id"`
	CommandInfo interface{} `json:"commandInfo" db:"command_info"`
	RawMsgID    interface{} `json:"rawMsgId" db:"raw_msg_id"`

	UniformID string `json:"uniformId" db:"user_uniform_id"`
	Channel   string `json:"channel"`
}

func LogGetAllLines

func LogGetAllLines(db *sqlx.DB, groupID string, logName string) ([]*LogOneItem, error)

LogGetAllLines 获取log的所有行数据

func LogGetLinePage

func LogGetLinePage(db *sqlx.DB, param *QueryLogLinePage) ([]*LogOneItem, error)

LogGetLinePage 获取log的行分页

type PlayerVariablesItem

type PlayerVariablesItem struct {
	Loaded        bool             `yaml:"-"`
	ValueMap      lockfree.HashMap `yaml:"-"`
	LastWriteTime int64            `yaml:"lastUsedTime"`
}

type QueryCensorLog

type QueryCensorLog struct {
	PageNum  int    `query:"pageNum"`
	PageSize int    `query:"pageSize"`
	UserID   string `query:"userId"`
	Level    int    `query:"level"`
}

type QueryLogLinePage

type QueryLogLinePage struct {
	PageNum  int    `query:"pageNum"`
	PageSize int    `query:"pageSize"`
	GroupID  string `query:"groupId"`
	LogName  string `query:"logName"`
}

type QueryLogPage

type QueryLogPage struct {
	PageNum          int    `db:"page_num" query:"pageNum"`
	PageSize         int    `db:"page_siz" query:"pageSize"`
	Name             string `db:"name" query:"name"`
	GroupID          string `db:"group_id" query:"groupId"`
	CreatedTimeBegin string `db:"created_time_begin" query:"createdTimeBegin"`
	CreatedTimeEnd   string `db:"created_time_end" query:"createdTimeEnd"`
}

Jump to

Keyboard shortcuts

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