Exemple #1
0
Fichier : main.go Projet : Ell/bot
func (logger *Logger) handleMessages() {
	for msg := range logger.messages {
		coreMsg, err := core.ParseMessage(msg)
		if err != nil {
			panic(err)
		}

		ircMsg := irc.ParseMessage(coreMsg.Message)

		if ircMsg.Command != irc.PING {
			go logger.logRaw(ircMsg, coreMsg.Server)

			if ircMsg.Command == irc.PRIVMSG {
				go logger.logMessage(ircMsg, coreMsg.Server)
			}
		}

		fmt.Printf("%+v\n", ircMsg.String())
	}
}
Exemple #2
0
Fichier : main.go Projet : Ell/bot
func (handler *Handler) handleMessage(msg string) {
	coreMsg, err := core.ParseMessage(msg)
	if err != nil {
		panic(err)
	}

	ircMsg := irc.ParseMessage(coreMsg.Message)
	server := coreMsg.Server

	callbacks, ok := handler.Callbacks[ircMsg.Command]

	if !ok {
		return
	}

	for _, c := range callbacks {
		go c.Run(handler.Sender, ircMsg, server)
	}

	fmt.Printf("%+v\n", coreMsg.Message)
}