Beispiel #1
0
func init() {
	adapter.Register("campfire", func(b adapter.Brain) adapter.Adapter {
		account := os.Getenv("VICTOR_CAMPFIRE_ACCOUNT")
		token := os.Getenv("VICTOR_CAMPFIRE_TOKEN")
		roomList := os.Getenv("VICTOR_CAMPFIRE_ROOMS")

		if account == "" || token == "" || roomList == "" {
			log.Println("The following environment variables are required:")
			log.Println("VICTOR_CAMPFIRE_ACCOUNT, VICTOR_CAMPFIRE_TOKEN, VICTOR_CAMPFIRE_ROOMS")
			os.Exit(1)
		}

		brain = b
		client = campfire.NewClient(account, token)
		roomIdStrings := strings.Split(roomList, ",")

		for _, id := range roomIdStrings {
			j, err := strconv.Atoi(id)

			if err != nil {
				log.Fatalf("room is not numeric: %s\n", id)
			}

			roomIds = append(roomIds, j)
		}

		return adapter.AdapterFunc(Listen)
	})
}
Beispiel #2
0
func init() {
	adapter.Register("shell", func(adapter.Brain) adapter.Adapter {
		return adapter.AdapterFunc(Listen)
	})
}