Exemplo n.º 1
0
func NewBot(filename string) *Server {
	s := &Server{
		chdst:         make(chan string, 32),
		chmsg:         make(chan message, 32),
		syslogHandler: &syslogHandler{syslog.NewBaseHandler(5, func(m *syslog.Message) bool { return true }, false)},
		regex:         make(map[*regexp.Regexp]string),
		targets:       make(map[string]bool),
		topics:        make(map[string]*regexp.Regexp),
	}
	s.load(filename)
	for _, target := range s.config.Hosts {
		s.targets[target] = true
	}
	for expr, target := range s.config.Regex {
		s.targets[target] = true
		if r, err := regexp.Compile(expr); err == nil {
			s.regex[r] = target
		} else {
			panic(err)
		}
	}
	if s.config.Overflow < 1 {
		s.config.Overflow = 100
	}
	go s.readLoop()
	go s.writeLoop(s.setupIRC())
	return s
}
Exemplo n.º 2
0
func newHandler() *handler {
	h := handler{syslog.NewBaseHandler(1000, nil, false)}
	go h.mainLoop()
	return &h
}
Exemplo n.º 3
0
func newHandler() *handler {
	h := handler{syslog.NewBaseHandler(5, func(m *syslog.Message) bool { return true }, false)}
	go h.mainLoop()
	return &h
}
Exemplo n.º 4
0
func newHandler() *handler {
	h := handler{syslog.NewBaseHandler(5, filter, false)}
	go h.mainLoop() // BaseHandler needs some gorutine that reads from its queue
	return &h
}