Exemple #1
0
func unignore(ctx *Context) {
	nick := strings.ToLower(strings.Fields(ctx.Text())[0])
	if nick == "" {
		return
	}
	conf.Ns(ignoreNs).Delete(nick)
	ctx.ReplyN("No longer ignoring '%s'.", nick)
}
Exemple #2
0
func ignore(ctx *Context) {
	nick := strings.ToLower(strings.Fields(ctx.Text())[0])
	if nick == "" {
		return
	}
	conf.Ns(ignoreNs).String(nick, "ignore")
	ctx.ReplyN("I'll ignore '%s'.", nick)
}
Exemple #3
0
func Init() {
	bot.Command(urbanDictionary, "ud", "ud <term>  -- "+
		"Look up <term> on UrbanDictionary.")

	mcConf = conf.Ns("mc")
	srv := mcConf.String(mcServer)
	if srv != "" {
		if st, err := pollServer(srv); err == nil {
			logging.Info("Starting MC poller for '%s'", srv)
			bot.Poll(st)
			bot.Handle(func(ctx *bot.Context) {
				st.Topic(ctx)
			}, "332")
		} else {
			logging.Error("Not starting MC poller: %v", err)
		}
	}
	bot.Command(mcSet, "mc set", "mc set <key> <value>  -- "+
		"Set minecraft server polling config vars.")
	// TODO(fluffle): Polling can only be en/disabled at reconnect.
	//	bot.Command(mcPoll, "mc poll", "mc poll start|stop  -- "+
	//		"Enable or disable minecraft server polling.")

	if *githubToken != "" {
		rc = reminders.Init()
		gh = githubClient()

		bot.Handle(githubWatcher, client.PRIVMSG)

		bot.Command(githubCreateIssue, "file bug:", "file bug: <title>. "+
			"<descriptive body>  -- Files a bug on GitHub. Abusers will be hurt.")
		bot.Command(githubCreateIssue, "file bug", "file bug <title>. "+
			"<descriptive body>  -- Files a bug on GitHub. Abusers will be hurt.")
		bot.Command(githubCreateIssue, "report bug", "report bug <title>. "+
			"<descriptive body>  -- Files a bug on GitHub. Abusers will be hurt.")
		bot.Command(githubUpdateIssue, "update bug #", "update bug #<number> "+
			"<comment>  -- Adds a comment to bug <number>. Abusers will be hurt.")
	}

	if push.Enabled() {
		pc = pushes.Init()
		bot.Command(pushEnable, "push enable", "push enable  -- "+
			"Start the OAuth flow to enable pushbullet notifications.")
		bot.Command(pushDisable, "push disable", "push disable  -- "+
			"Disable pushbullet notifications and delete tokens.")
		bot.Command(pushConfirm, "push auth", "push auth <pin>  -- "+
			"Confirm pushed PIN to finish pushbullet auth dance.")
		bot.Command(pushAddAlias, "push add alias", "push add alias  -- "+
			"Add a push alias for your nick.")
		bot.Command(pushDelAlias, "push del alias", "push del alias  -- "+
			"Delete a push alias for your nick.")

		http.HandleFunc("/oauth/auth", pushAuthHTTP)
		http.HandleFunc("/oauth/device", pushDeviceHTTP)
		http.HandleFunc("/oauth/success", pushSuccessHTTP)
		http.HandleFunc("/oauth/failure", pushFailureHTTP)
	}
}
Exemple #4
0
func disableMarkov(ctx *bot.Context) {
	key := strings.ToLower(ctx.Nick)
	conf.Ns(markovNs).Delete(key)
	if err := mc.ClearTag("user:"******"Failed to clear tag: %s", err)
		return
	}
	ctx.ReplyN("Sure, bro, I'll stop.")
}
Exemple #5
0
func context(conn *client.Conn, line *client.Line) *Context {
	ctx := &Context{conn: conn, Line: line.Copy(), rws: bot.rewriters}
	// This is a bit of a dirty hack; context() returns nil to ignore a line.
	// TODO(fluffle): Ignores based on masks (or more likely regex).
	if ctx.Nick != "" && conf.Ns(ignoreNs).String(strings.ToLower(ctx.Nick)) != "" {
		return nil
	}
	if ctx.Cmd != client.PRIVMSG {
		return ctx
	}
	ctx.Args[1], ctx.Addressed = util.RemovePrefixedNick(
		strings.TrimSpace(ctx.Args[1]), ctx.Me())
	// If we're being talked to in private, line.Args[0] will contain our Nick.
	// We should consider this as "addressing" us, and set Addressed = true
	if ctx.Args[0] == ctx.Me() {
		ctx.Addressed = true
	}
	return ctx
}
Exemple #6
0
func shouldMarkov(nick string) bool {
	return conf.Ns(markovNs).String(nick) != ""
}
Exemple #7
0
func enableMarkov(ctx *bot.Context) {
	conf.Ns(markovNs).String(strings.ToLower(ctx.Nick), "markov")
	ctx.ReplyN("I'll markov you like I markov'd your mum last night.")
}