Пример #1
0
func (m *RSSModule) Init(c *irc.Conn, config json.RawMessage) {
	db.AutoMigrate(&RSSLastSeen{})

	err := json.Unmarshal(config, &m.config)
	if err != nil {
		panic(err)
	}

	c.HandleFunc(irc.CONNECTED, func(conn *irc.Conn, line *irc.Line) {
		// Wait a bit to lets things settle.  This should be rewritten
		// to check for channel memebership
		<-time.After(30 * time.Second)
		for _, feed := range m.config.Feeds {
			if feed.URL == "" {
				log.WithFields(logrus.Fields{
					"feed": feed,
				}).Error("RSS: Feed has no URL")
			}

			timeout := feed.Timeout
			if timeout < 1 {
				if m.config.Timeout < 1 {
					log.WithFields(logrus.Fields{
						"feed": feed,
					}).Error("RSS: Feed has no timeout or global timeout")
				}
				timeout = m.config.Timeout
			}

			go pollFeed(c, feed, timeout)
		}
	})
}
Пример #2
0
func addWhoHandlers(irc *client.Conn) {
	if !flag.Parsed() {
		flag.Parse()
	}

	irc.HandleFunc("352", whoHandler)
	irc.HandleFunc("315", whoHandler)
	return
}
Пример #3
0
func addNickHandlers(irc *client.Conn) {
	if !flag.Parsed() {
		flag.Parse()
	}

	irc.HandleFunc("QUIT", dropIdentifiedCache)
	irc.HandleFunc("307", isIdentified)
	irc.HandleFunc("330", isIdentified)
	irc.HandleFunc("318", isIdentified)
}