Ejemplo n.º 1
0
func Handle(c *sirc.IConn, m *irc.Message) (abort bool) {
	matches := handleRE.FindStringSubmatch(m.Trailing)
	if len(matches) == 0 {
		return
	}

	factoidkey := strings.ToLower(matches[1])

	state.Lock()
	defer state.Unlock()
	if factoid, factoidkey, ok := getfactoidByKey(factoidkey); ok {
		abort = true
		if factoidUsedRecently(factoidkey) {
			return
		}
		if len(matches[2]) > 0 { // someone is being sent a factoid
			c.PrivMsg(m, matches[2], ": ", factoid)
		} else { // otherwise just print the factoid
			c.PrivMsg(m, factoid)
		}

		return
	}

	return
}