本文整理汇总了Golang中github.com/wcharczuk/jarvis/jarvis/core.Bot.JobManager方法的典型用法代码示例。如果您正苦于以下问题:Golang Bot.JobManager方法的具体用法?Golang Bot.JobManager怎么用?Golang Bot.JobManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/wcharczuk/jarvis/jarvis/core.Bot
的用法示例。
在下文中一共展示了Bot.JobManager方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: handleJobEnable
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.")
}
示例2: handleJobsStatus
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)
}
示例3: handleJobRun
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")
}
示例4: Init
// 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
}