func decidePlugin(val string, ctx *bot.Context) string { f := func(s string) string { if options := splitDelimitedString(s); len(options) > 0 { return strings.TrimSpace(options[rand.Intn(len(options))]) } return "<plugin error>" } return util.ApplyPluginFunction(val, "decide", f) }
func decidePlugin(val string, line *base.Line) string { f := func(s string) string { if options := splitDelimitedString(s); len(options) > 0 { return strings.TrimSpace(options[util.RNG.Intn(len(options))]) } return "<plugin error>" } return util.ApplyPluginFunction(val, "decide", f) }
func insultPlugin(in string, ctx *bot.Context) string { f := func(string) string { source := mc.Source("tag:insult") if insult, err := chain.Sentence(source); err == nil { return insult } return "<plugin error>" } return util.ApplyPluginFunction(in, "insult", f) }
func quotePlugin(in string, ctx *bot.Context) string { f := func(s string) string { var quote *quotes.Quote if s == "" { quote = qc.GetPseudoRand("") } else if s[0] == '#' { if qid, err := strconv.Atoi(s[1:]); err == nil { quote = qc.GetByQID(qid) } } else { quote = qc.GetPseudoRand(s) } if quote == nil { return "<plugin error>" } return quote.Quote } return util.ApplyPluginFunction(in, "quote", f) }
func randPlugin(val string, ctx *bot.Context) string { f := func(s string) string { return randomFloatAsString(s) } return util.ApplyPluginFunction(val, "rand", f) }
func randPlugin(val string, line *base.Line) string { f := func(s string) string { return randomFloatAsString(s, util.RNG) } return util.ApplyPluginFunction(val, "rand", f) }