cron

package
v3.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2017 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPlugin

func NewPlugin(cron Context) plugins.BotMessagePlugin

Types

type ActionType

type ActionType string
const (
	AddAction       ActionType = "add"
	RandomAddAction ActionType = "random"
	DelAction       ActionType = "del"
	DeleteAction    ActionType = "delete"
	StopAction      ActionType = "stop"
	ListAction      ActionType = "list"
	RefreshAction   ActionType = "refresh"
	HelpAction      ActionType = "help"
)

type Command

type Command struct {
	Trigger  string // cron
	Action   ActionType
	CronSpec string
	Args     []string
	CronID   string
}

func (Command) Key

func (c Command) Key() string

func (Command) Message

func (c Command) Message() string

func (*Command) Scan

func (c *Command) Scan(command string) error

Scan cron add */1 * * * * * hogehoge -> cronCommand

func (Command) String

func (c Command) String() string

type Context

type Context interface {
	AddCommand(channel string, c Command) string
	DelCommand(channel string, c Command) string
	ListCommand(channel string, c Command) string
	HelpCommand(channel string, c Command) string
	Refresh(messageSender plugins.MessageSender, channel string)
	AllRefresh(messageSender plugins.MessageSender)
	Close()
}

func NewContext

func NewContext(repository Repository) (Context, error)

NewContext create cron context

type Repository

type Repository interface {
	Load() (map[string]TaskMap, error)
	Save(cronTaskMap map[string]TaskMap) error
	Close() error
}

func NewInMemoryRepository

func NewInMemoryRepository() Repository

NewInMemoryRepository create in memory repository

func NewRedisRepository

func NewRedisRepository(addr, password string, db int64, redisKeyFmt string) Repository

NewRedisRepository create redis repository

type Task

type Task struct {
	Active  bool
	Command Command
}

type TaskMap

type TaskMap map[string]Task

func (TaskMap) AddTask

func (c TaskMap) AddTask(key string, task Task)

Jump to

Keyboard shortcuts

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