func randomCmd(ctx *bot.Context) { if len(ctx.Text()) == 0 { ctx.ReplyN("Be who? Your mum?") return } whom := strings.ToLower(strings.Fields(ctx.Text())[0]) if whom == strings.ToLower(ctx.Me()) { ctx.ReplyN("Ha, you're funny. No, wait. Retarded... I meant retarded.") return } if !shouldMarkov(whom) { if whom == strings.ToLower(ctx.Nick) { ctx.ReplyN("You're not recording markov data. " + "Use 'markov me' to enable collection.") } else { ctx.ReplyN("Not recording markov data for %s.", ctx.Text()) } return } source := mc.Source("user:"******"%s would say: %s", ctx.Text(), out) } else { ctx.ReplyN("markov error: %v", err) } }
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 insult(ctx *bot.Context) { source := mc.Source("tag:insult") whom, lc := ctx.Text(), strings.ToLower(ctx.Text()) if lc == strings.ToLower(ctx.Me()) || lc == "yourself" { ctx.ReplyN("Ha, you're funny. No, wait. Retarded... I meant retarded.") return } if lc == "me" { whom = ctx.Nick } if out, err := chain.Sentence(source); err == nil { if len(whom) > 0 { ctx.Reply("%s: %s", whom, out) } else { ctx.Reply("%s", out) } } else { ctx.ReplyN("markov error: %v", err) } }