Esempio n. 1
0
func backoffConnect(conn *irc.Conn, o *Options) {
	for i := 0; true; i++ {
		wait := backoffDuration(i)
		time.Sleep(wait)

		err := conn.Connect()
		if err == nil {
			// The connection was successful.
			break
		}

		log.Printf("Connection to %s failed: %s [%dms]", o.Server, err,
			int64(wait/time.Millisecond))
	}
}
Esempio n. 2
0
func (s InBandSource) Connect(c *irc.Conn) (err error) {
	if c.Connected {
		return nil
	}

	c.AddHandler(irc.CONNECTED, func(c *irc.Conn, line *irc.Line) {
		c.Join(s.Host().Channel)
	})

	if err := c.Connect(s.Host().Server); err != nil {
		return err
	}

	return nil
}