本文整理汇总了Golang中github.com/wcharczuk/jarvis/jarvis/core.Bot.Sayf方法的典型用法代码示例。如果您正苦于以下问题:Golang Bot.Sayf方法的具体用法?Golang Bot.Sayf怎么用?Golang Bot.Sayf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/wcharczuk/jarvis/jarvis/core.Bot
的用法示例。
在下文中一共展示了Bot.Sayf方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: handlePassiveCatchAll
func (c *Core) handlePassiveCatchAll(b core.Bot, m *slack.Message) error {
message := util.TrimWhitespace(core.LessMentions(m.Text))
if optionValue, hasOption := b.Configuration()[ConfigOptionPassiveCatchAll]; hasOption && optionValue == "true" {
if core.IsAngry(message) {
user := b.FindUser(m.User)
response := []string{"slow down %s", "maybe calm down %s", "%s you should really relax", "chill %s", "it's ok %s, let it out"}
return b.Sayf(m.Channel, core.Random(response), strings.ToLower(user.Profile.FirstName))
}
}
return nil
}
示例3: handleConfigGet
func (c *Config) handleConfigGet(b core.Bot, m *slack.Message) error {
messageWithoutMentions := util.TrimWhitespace(core.LessMentions(m.Text))
parts := core.ExtractSubMatches(messageWithoutMentions, "^config:(.+)")
if len(parts) < 2 {
return exception.Newf("malformed message for `%s`", ActionConfigGet)
}
key := parts[1]
value := b.Configuration()[key]
return b.Sayf(m.Channel, "> %s: `%s` = %s", ActionConfigGet, key, value)
}
示例4: 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")
}
示例5: handleConfigSet
func (c *Config) handleConfigSet(b core.Bot, m *slack.Message) error {
messageWithoutMentions := util.TrimWhitespace(core.LessMentions(m.Text))
parts := core.ExtractSubMatches(messageWithoutMentions, "^config:(.+) (.+)")
if len(parts) < 3 {
return exception.Newf("malformed message for `%s`", ActionConfigSet)
}
key := parts[1]
value := parts[2]
setting := value
if core.LikeAny(value, "true", "yes", "on", "1") {
setting = "true"
} else if core.LikeAny(value, "false", "off", "0") {
setting = "false"
}
b.Configuration()[key] = setting
return b.Sayf(m.Channel, "> %s: `%s` = %s", ActionConfigSet, key, setting)
}
示例6: handleStockPrice
func (s *Stocks) handleStockPrice(b core.Bot, m *slack.Message) error {
messageWithoutMentions := util.TrimWhitespace(core.LessMentions(m.Text))
pieces := core.ExtractSubMatches(messageWithoutMentions, "^stock:price (.*)")
if len(pieces) < 2 {
return exception.Newf("invalid input for %s", ActionStockPrice)
}
rawTicker := pieces[1]
tickers := []string{}
if strings.Contains(rawTicker, ",") {
tickers = strings.Split(rawTicker, ",")
} else {
tickers = []string{rawTicker}
}
stockInfo, err := external.StockPrice(tickers)
if err != nil {
return err
}
if len(stockInfo) == 0 {
return b.Sayf(m.Channel, "No stock information returned for: `%s`", strings.Join(tickers, ", "))
}
return s.announceStocks(b, m.Channel, stockInfo)
}
示例7: handleUnloadModule
func (c *Config) handleUnloadModule(b core.Bot, m *slack.Message) error {
messageWithoutMentions := util.TrimWhitespace(core.LessMentions(m.Text))
parts := core.ExtractSubMatches(messageWithoutMentions, "^module:unload (.+)")
if len(parts) < 2 {
return exception.Newf("malformed message for `%s`", ActionModuleUnload)
}
key := parts[1]
if !b.LoadedModules().Contains(key) {
return b.Sayf(m.Channel, "Module `%s` isn't loaded.", key)
}
if !b.RegisteredModules().Contains(key) {
return b.Sayf(m.Channel, "Module `%s` isn't registered.", key)
}
b.UnloadModule(key)
return b.Sayf(m.Channel, "Unloaded Module `%s`.", key)
}
示例8: handleUnknown
func (c *Core) handleUnknown(b core.Bot, m *slack.Message) error {
return b.Sayf(m.Channel, "I don't know how to respond to this\n>%s", m.Text)
}
示例9: handleSalutation
func (c *Core) handleSalutation(b core.Bot, m *slack.Message) error {
user := b.FindUser(m.User)
salutation := []string{"hey %s", "hi %s", "hello %s", "ohayo gozaimasu %s", "salut %s", "bonjour %s", "yo %s", "sup %s"}
return b.Sayf(m.Channel, core.Random(salutation), strings.ToLower(user.Profile.FirstName))
}