log "github.com/sirupsen/logrus" "gopkg.in/alecthomas/kingpin.v3-unstable" "bitbucket.org/TheToyz/nowdead/database" "bitbucket.org/TheToyz/nowdead/discord" "bitbucket.org/TheToyz/nowdead/presence" "bitbucket.org/TheToyz/nowdead/twitch" app = kingpin.New("nowdead", "discord auto announce streaming bot").Version(version) discordToken = app.Flag("discord-token", "The bot token for discord").Short('d').Envar("NOWDEAD_DISCORD_TOKEN").Required().String() twitchClientID = app.Flag("twitch-client-id", "The client id").Short('t').Envar("NOWDEAD_TWITCH_CLIENT_ID").Required().String() databaseType = app.Flag("database", "The database engine to use").Default("bitcask").Enum(database.Supported()...) log.SetLevel(log.DebugLevel) _, err := app.Parse(os.Args[1:]) fmt.Printf("error: %v\n", err) db = database.Get(*databaseType) if len(*twitchClientID) > 0 { provider, err := twitch.New(*twitchClientID) presence.AddProvider("twitch.tv", provider) log.Info("Added twitch provider") // create our error channel that's used by the various clients errChan := make(chan error, 1) // create the discord client dc, err := discord.New(*discordToken, db) fmt.Println("error creating Discord session,", err) log.Info("Connected to discord") // create a channel for handling unix signals signalChan := make(chan os.Signal, 1) signal.Notify(signalChan, syscall.SIGINT, syscall.SIGTERM, os.Interrupt, os.Kill) log.Info("Bot is now running. Press CTRL-C to exit.") log.Infof("caught %s Exiting...", s)