Documentation ¶
Index ¶
- type Command
- type Scheduler
- func (s *Scheduler) AwaitResumeTrigger() *Command
- func (s *Scheduler) Close() error
- func (s *Scheduler) PrioritySchedule(cmd *Command)
- func (s *Scheduler) Resume()
- func (s *Scheduler) ResumeWithCommand(cmd *Command)
- func (s *Scheduler) ResumeWithCommandOrPrioritySchedule(cmd *Command)
- func (s *Scheduler) Schedule(cmd *Command)
- func (s *Scheduler) Start() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Command ¶
type Command struct { Value string // If not an empty string, this is what will be logged to the logger when // sending the command. The format will be "%v: %v", log, content. Log string // The interval at which the command should be rescheduled. Set to 0 to // disable. Interval time.Duration // If AwaitResume is true, the scheduler will wait for a resume call before // executing the next command. AwaitResume bool RescheduleAsPriority bool // Next is a pointer to the command that will be rescheduled if interval is // not 0. If this is nil this command itself will be rescheduled. Using this // feature might be useful when you want to create a chain of commands that // work together but have, for example, different values for Command.Value. Next *Command // The amount of times to reschedule the command in total. Set to 0 to // reschedule indefinitely. To run a command once, the interval should be // set to 0, not the amount. Amount uint // If this function returns false, the command will not be sent but will be // rescheduled. It does not count as an execution of the command and as such // it will not count towards the amount if it is set. It will also not // reschedule Next if this is set to a different command. CondFunc func() bool // contains filtered or unexported fields }
type Scheduler ¶
type Scheduler struct { Client *discord.Client Logger *logrus.Logger ChannelID string Typing *config.Typing MessageDelay *config.MessageDelay AwaitResumeTimeout time.Duration FatalHandler func(err error) // contains filtered or unexported fields }
func (*Scheduler) AwaitResumeTrigger ¶
AwaitResumeTrigger returns the value of the command that caused the await resume state. An empty string will be returned if the scheduler is not awaiting a resume at the time this method is called.
func (*Scheduler) PrioritySchedule ¶
func (*Scheduler) Resume ¶
func (s *Scheduler) Resume()
Resume makes a scheduler continue after being paused by a command with an AwaitResume value of true. Will block until scheduler has received the resume call.
func (*Scheduler) ResumeWithCommand ¶
ResumeWithCommand is the same as Resume but executes the passed command immediately after resuming.
func (*Scheduler) ResumeWithCommandOrPrioritySchedule ¶
ResumeWithCommandOrPrioritySchedule is the same as ResumeWithCommand, but if the scheduler is not awaiting a resume, it will schedule the command in the priority queue instead.