Esempio n. 1
0
func New(pc config.Config) plug.Plug {
	st := &state.Nick{
		Nick:  pc.Identity.Nick[0],
		Ident: pc.Identity.RealName,
		Name:  globals.Name(),
	}
	cf := &client.Config{
		Server:   pc.Connection.Addr,
		Pass:     pc.Identity.Password,
		Me:       st,
		NewNick:  nextNick(pc.Identity.Nick),
		Version:  globals.Version(),
		PingFreq: PING_FREQ,
		SplitLen: SPLIT_LEN,
		Timeout:  TIMEOUT,
		Recover:  logPanic,
		Flood:    true,
	}
	cl := client.Client(cf)
	p := &IRCPlug{
		config:  pc,
		client:  cl,
		endloop: make(chan bool),
		changes: make(chan plug.Change, CHANGE_CAPACITY),
	}
	cl.HandleFunc(client.CONNECTED, p.onConnected)
	cl.HandleFunc(client.DISCONNECTED, p.onDisconnected)
	cl.HandleFunc(client.PRIVMSG, p.onMessage)
	cl.HandleFunc(client.TOPIC, p.onTopic)
	return p
}
Esempio n. 2
0
func Run() {
	app := cli.NewApp()
	app.Name = globals.Name()
	app.Usage = "Extendable chat messages relay"
	app.Version = fmt.Sprintf("%s", globals.Version())
	app.Authors = []cli.Author{
		cli.Author{Name: "dubi", Email: "devnull@localhost"},
	}
	app.Flags = rootFlags
	app.Before = getLogLevel
	app.Commands = commands

	sigChan := make(chan os.Signal, 1)
	signal.Notify(sigChan)
	go signalingLoop(sigChan)

	err := app.Run(os.Args)
	if err != nil {
		log.Fatalf("Got an error initial run %+v", err)
	}
}