Exemplo n.º 1
0
func ud_privmsg(bot *bot.Sp0rkle, line *base.Line) {
	ud := bot.GetDriver(driverName).(*urlDriver)

	// If we're not being addressed directly, short-circuit to scan.
	if !line.Addressed {
		ud_scan(bot, ud, line)
		return
	}

	nl := line.Copy()
	switch {
	case util.StripAnyPrefix(&nl.Args[1],
		[]string{"url find ", "urlfind ", "url search ", "urlsearch "}):
		ud_find(bot, ud, nl)
	case util.HasAnyPrefix(nl.Args[1], []string{"random url", "randurl"}):
		nl.Args[1] = ""
		ud_find(bot, ud, nl)
	case util.StripAnyPrefix(&nl.Args[1],
		[]string{"shorten that", "shorten"}):
		ud_shorten(bot, ud, nl)
	case util.StripAnyPrefix(&nl.Args[1],
		[]string{"cache that", "save that", "cache ", "save "}):
		ud_cache(bot, ud, nl)
	default:
		ud_scan(bot, ud, line)
	}
}
Exemplo n.º 2
0
func sd_privmsg(bot *bot.Sp0rkle, line *base.Line) {
	if !line.Addressed {
		return
	}
	sd := bot.GetDriver(driverName).(*seenDriver)
	switch {
	case strings.HasPrefix(line.Args[1], "seen "):
		sd_seen_lookup(bot, sd, line)
	case strings.HasPrefix(line.Args[1], "lines"):
		sd_lines_lookup(bot, sd, line)
	case util.HasAnyPrefix(line.Args[1], []string{"topten", "top10"}):
		sd_topten(bot, sd, line)
	}
}
Exemplo n.º 3
0
func fd_privmsg(bot *bot.Sp0rkle, line *base.Line) {
	fd := bot.GetDriver(driverName).(*factoidDriver)

	// If we're not being addressed directly, short-circuit to lookup.
	if !line.Addressed {
		fd_lookup(bot, fd, line)
		return
	}

	nl := line.Copy()
	// Test for various possible courses of action.
	switch {
	// Factoid add: 'key := value' or 'key :is value'
	case util.ContainsAny(nl.Args[1], []string{":=", ":is"}):
		fd_add(bot, fd, nl)

	// Factoid delete: 'forget|delete that' => deletes fd.lastseen[chan]
	case util.HasAnyPrefix(nl.Args[1], []string{"forget that", "delete that"}):
		fd_delete(bot, fd, nl)

	// Factoid replace: 'replace that with' => updates fd.lastseen[chan]
	case util.StripAnyPrefix(&nl.Args[1], []string{"replace that with "}):
		fd_replace(bot, fd, nl)

	// Factoid chance: 'chance of that is' => sets chance of fd.lastseen[chan]
	case util.StripAnyPrefix(&nl.Args[1], []string{"chance of that is "}):
		fd_chance(bot, fd, nl)

	// Factoid literal: 'literal key' => info about factoid
	case util.StripAnyPrefix(&nl.Args[1], []string{"literal "}):
		fd_literal(bot, fd, nl)

	// Factoid search: 'fact search regexp' => list of possible key matches
	case util.StripAnyPrefix(&nl.Args[1], []string{"fact search "}):
		fd_search(bot, fd, nl)

	// Factoid info: 'fact info key' => some information about key
	case util.StripAnyPrefix(&nl.Args[1], []string{"fact info "}):
		fd_info(bot, fd, nl)

	// If we get to here, none of the other FD command possibilities
	// have matched, so try a lookup...
	default:
		fd_lookup(bot, fd, nl)
	}
}