job

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2023 License: GPL-3.0 Imports: 22 Imported by: 3

Documentation

Overview

Package job 定时指令触发器

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(j *Job) (err error)

Add 添加任务

func Delete

func Delete(req *DeleteReq) (err error)

Delete 删除任务

Types

type AnswerType

type AnswerType uint8

AnswerType 回答类型, jobType=3使用的参数, 1=文本消息, 2=注入消息

const (
	// TextMsg 文本消息
	TextMsg AnswerType = iota + 1
	// InjectMsg 注入消息
	InjectMsg
)

type DeleteReq

type DeleteReq struct {
	IDList []string `json:"idList" form:"idList"` // 任务id
	SelfID int64    `json:"selfId" form:"selfId"` // 机器人qq
}

DeleteReq 删除任务的入参

@Description	删除任务的入参

type FullMatchType

type FullMatchType uint8

FullMatchType 指令别名类型, jobType=1使用的参数, 1=无状态消息, 2=主人消息

const (
	// NoStateMsg 无状态消息
	NoStateMsg FullMatchType = iota + 1
	// SuperMsg 主人消息
	SuperMsg
)

type Job

type Job struct {
	ID            string        `json:"id"`            // 任务id
	SelfID        int64         `json:"selfId"`        // 机器人id
	JobType       Type          `json:"jobType"`       // 任务类型,1-指令别名,2-定时任务,3-你问我答
	Matcher       string        `json:"matcher"`       // 当jobType=1时 为指令别名,当jobType=2时 为cron表达式,当jobType=3时 为正则表达式
	Handler       string        `json:"handler"`       // 执行内容
	FullMatchType FullMatchType `json:"fullMatchType"` // 指令别名类型, jobType=1使用的参数, 1=无状态消息, 2=主人消息
	QuestionType  QuestionType  `json:"questionType"`  // 问题类型, jobType=3使用的参数, 1=单独问, 2=所有人问
	AnswerType    AnswerType    `json:"answerType"`    // 回答类型, jobType=3使用的参数, 1=文本消息, 2=注入消息
	GroupID       int64         `json:"groupId"`       // 群聊id, jobType=2,3使用的参数, jobType=2且私聊, group_id=0
	UserID        int64         `json:"userId"`        // 用户id, jobType=2,3使用的参数, 当jobType=3, QuestionType=2,userId=0
}

Job 添加任务的入参

@Description	添加任务的入参

func List

func List() (jobList []Job, err error)

List 任务列表

type QuestionType

type QuestionType uint8

QuestionType 问题类型, jobType=3使用的参数, 1=单独问, 2=所有人问

const (
	// OneQuestion 单独问
	OneQuestion QuestionType = iota + 1
	// AllQuestion 所有人问
	AllQuestion
)

type Type

type Type uint8

Type 任务类型,1=指令别名,2=定时任务,3=你问我答

const (
	// FullMatchJob 指令别名
	FullMatchJob Type = iota + 1
	// CronJob 定时任务
	CronJob
	// RegexpJob 你问我答
	RegexpJob
)

Jump to

Keyboard shortcuts

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