Esempio n. 1
0
func (j *Jobs) handleJobEnable(b core.Bot, m *slack.Message) error {
	messageWithoutMentions := util.TrimWhitespace(core.LessMentions(m.Text))
	pieces := strings.Split(messageWithoutMentions, " ")
	if len(pieces) > 1 {
		taskName := pieces[len(pieces)-1]
		b.JobManager().EnableJob(taskName)
		return b.Sayf(m.Channel, "enabled job `%s`", taskName)
	}
	return exception.New("unhandled response.")
}
Esempio n. 2
0
func (j *Jobs) handleJobsStatus(b core.Bot, m *slack.Message) error {
	statusText := "current job statuses:\n"
	for _, status := range b.JobManager().Status() {
		if len(status.RunningFor) != 0 {
			statusText = statusText + fmt.Sprintf(">`%s` - state: %s running for: %s\n", status.Name, status.State, status.RunningFor)
		} else {
			statusText = statusText + fmt.Sprintf(">`%s` - state: %s\n", status.Name, status.State)
		}
	}
	return b.Say(m.Channel, statusText)
}
Esempio n. 3
0
func (j *Jobs) handleJobRun(b core.Bot, m *slack.Message) error {
	messageWithoutMentions := util.TrimWhitespace(core.LessMentions(m.Text))
	pieces := strings.Split(messageWithoutMentions, " ")
	if len(pieces) > 1 {
		jobName := pieces[len(pieces)-1]
		b.JobManager().RunJob(jobName)
		return b.Sayf(m.Channel, "ran job `%s`", jobName)
	}

	b.JobManager().RunAllJobs()
	return b.Say(m.Channel, "ran all jobs")
}
Esempio n. 4
0
// Init does nothing right now.
func (j *Jobs) Init(b core.Bot) error {
	b.JobManager().LoadJob(jobs.NewClock(b))
	b.JobManager().DisableJob("clock")
	return nil
}