Пример #1
0
func (self *ModManager) run(event string, line *irc.Line) {
	self.mut.RLock()
	defer self.mut.RUnlock()

	for _, mod := range self.modules {
		// Module should check if enabled, not handlers
		go mod.Handle(module.Event(event), line.Text(), line)
	}
}
Пример #2
0
func (ei *EndpointIRC) message(c *irc.Conn, l *irc.Line) {
	var messageTarget MessageTarget
	if l.Public() {
		messageTarget = ei.GetChannel(l.Target())
	} else {
		messageTarget = ei.GetUser(l.Target())
	}
	ei.handler(l.Text(), ei.GetUser(l.Nick), l.Target(), messageTarget)
}
Пример #3
0
// Implement client.Handler so commandSet can Handle things directly.
func (cs *commandSet) Handle(conn *client.Conn, line *client.Line) {
	// This is a dirty hack to treat factoid additions as a special
	// case, since they may begin with command string prefixes.
	ctx := context(conn, line)
	if ctx == nil || util.IsFactoidAddition(line.Text()) {
		return
	}
	if r, ln := cs.match(ctx.Text()); ctx.Addressed && r != nil {
		// Cut command off, trim and compress spaces.
		ctx.Args[1] = strings.Join(strings.Fields(ctx.Args[1][ln:]), " ")
		r.Run(ctx)
	}
}
Пример #4
0
func (ib *IrcBot) parsePacket(conn *irc.Conn, line *irc.Line) *models.Packet {
	result := ib.regex.FindStringSubmatch(line.Text())
	if result == nil {
		return nil
	}

	fileName := cleanFileName(result[3])
	packet := models.NewPacket(result[1], result[2], fileName, line.Nick, line.Target(), ib.server.Name, line.Time)

	//save packet
	if packet != nil {
		ib.dataService.SavePacket(packet)
	}

	return packet
}
Пример #5
0
// Handle privmsgs
func handle_privmsg(conn *irc.Conn, line *irc.Line) {
	text := line.Text()
	args := strings.Split(text, " ")
	//var url_regex = regexp.MustCompile(`\Ahttps?://([[:alnum:]][a-zA-Z0-9-]{1,61}[[:alnum:]]\.?){2,3}((%[0-9A-Fa-f]{2}|[-_.!~*';/?#:@&=+$,A-Za-z0-9])+)?\z`)
	var url_regex = regexp.MustCompile(`\b(([\w-]+://?|www[.])[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|/)))`)

	// handle a prefixed command
	if strings.Index(text, RC.CmdPrefix) == 0 {
		handle_command(conn, line, args)
	} else if len(url_regex.FindString(text)) > 0 {
		s := GetScanner()
		s.Handle(conn, line, text)
	}
	// Handle mocking
	if RC.Mocking[line.Nick] {
		SendMessage(conn, "Hey, everybody! "+line.Nick+" said something!", nil)
		SendMessage(conn, line.Nick+": "+line.Text(), nil)
		SendMessage(conn, "Great job, "+line.Nick+"! ╭(ᐛ)و", nil)
	}
}
Пример #6
0
func (ib *IrcBot) handleNotice(conn *irc.Conn, line *irc.Line) {
	log.Printf("[NOTICE] %v", line.Text())
	ib.logToConsole("[NOTICE] " + line.Text())
}
Пример #7
0
func (ib *IrcBot) log372(conn *irc.Conn, line *irc.Line) {
	ib.logToConsole(line.Text())
}