Пример #1
0
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)
}
Пример #2
0
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)
}
Пример #3
0
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)
}
Пример #4
0
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)
}
Пример #5
0
func randPlugin(val string, ctx *bot.Context) string {
	f := func(s string) string {
		return randomFloatAsString(s)
	}
	return util.ApplyPluginFunction(val, "rand", f)
}
Пример #6
0
func randPlugin(val string, line *base.Line) string {
	f := func(s string) string {
		return randomFloatAsString(s, util.RNG)
	}
	return util.ApplyPluginFunction(val, "rand", f)
}