Beispiel #1
0
func SendNotification(target, message string) {
	if !connection.Connected() {
		if err := connect(); err != nil {
			logger.GenericLogger(fmt.Sprintf("%s/ana-irc.log", config.LogDir), fmt.Sprintf("%v\n", err))
		}
	}
	connection.Notice(target, message)
	logger.GenericLogger(fmt.Sprintf("%s/ana-irc.log", config.LogDir),
		fmt.Sprintf("Target: %s, message: %s\n", target, message))
}
Beispiel #2
0
func init() {
	file, err := os.Open("config.json")

	if err != nil {
		logger.GenericLogger(fmt.Sprintf("%s/ana-irc.log", config.LogDir), fmt.Sprintf("%v\n", err))
		panic(err)
	}
	defer file.Close()

	decoder := json.NewDecoder(file)
	config = &Config{}
	decoder.Decode(&config)

	err = connect()
	if err != nil {
		logger.GenericLogger(fmt.Sprintf("%s/ana-irc.log", config.LogDir), fmt.Sprintf("%v\n", err))
		panic(err)
	}
}
Beispiel #3
0
func connect() error {
	connection := irclib.IRC(config.BotNick, config.BotUser)
	err := connection.Connect(config.Server)

	if err != nil {
		logger.GenericLogger(fmt.Sprintf("%s/ana-irc.log", config.LogDir), fmt.Sprintf("%v\n", err))
		return err
	}
	return nil
}