user

package
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Tokens = make(map[string]User)
	Uids   = make(map[string]string)
)
View Source
var ErrNotListeningList = errors.New("不是一个好的监听列表")

监听列表获取错误

Functions

func CreateTestUser

func CreateTestUser()

func Done

func Done(uid string)

清理

func GetRandomToken

func GetRandomToken(uid string) (auth, token string)

获取随机 Token

func SetDB

func SetDB(r *gorm.DB) *gorm.DB

func SetDialector

func SetDialector(dialector gorm.Dialector) *gorm.DB

func SetOid

func SetOid(oid string)

func SetSqlite

func SetSqlite(file string) *gorm.DB

Types

type ApiData

type ApiData struct {
	Code int       `json:"code"`
	Data []Replies `json:"data"`
}

type Job

type Job struct {
	// 数据库内序号
	ID      int64 `gorm:"primaryKey;autoIncrement" json:"-"`
	UserUid string
	Patten  string `form:"patten" json:"patten" yaml:"patten"`
	request.Job
}

回调任务封装

func GetJobsByRegexp

func GetJobsByRegexp(platform, uid string) []Job

正则匹配任务

func (Job) Match

func (j Job) Match(s string) bool

匹配

type Listening

type Listening []string

监听列表的读取实现

func (*Listening) Scan

func (l *Listening) Scan(val any) error

func (Listening) Value

func (l Listening) Value() (driver.Value, error)

type Replies

type Replies struct {
	Member struct {
		Mid   string `json:"mid"`
		Uname string `json:"uname"`
	} `json:"member"`
	Content struct {
		Message string `json:"message"`
	} `json:"content"`
}

func GetReplies

func GetReplies() ([]Replies, error)

返回最近回复

type User

type User struct {
	Uid        string  `gorm:"primaryKey" json:"uid"`
	Token      string  `json:"-"`
	Permission float64 `json:"permission"`
	Jobs       []Job   `gorm:"references:Uid" form:"jobs" json:"-"`
	Listening  `form:"listening" json:"-"`
}

用户

func Get

func Get(auth string) User

func (*User) LevelUP

func (u *User) LevelUP()

升级

func (*User) Make

func (u *User) Make(uid string) *User

构造函数

func (User) MatchReplies

func (u User) MatchReplies() (bool, error)

检查回复

func (*User) Query

func (u *User) Query(token string) *User

根据 uid 查询

func (*User) Scan

func (u *User) Scan(val any) error

func (User) Value

func (u User) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

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