Ejemplo n.º 1
0
        static async Task MainAsync(string[] args)
        {
            //magic to prevent OperationNotSupportedException
            var proxy = WebRequest.DefaultWebProxy;

            WebRequest.DefaultWebProxy = null;
            KomoLogger logger = new KomoLogger();

            try
            {
                config = new JsonParser().Config;
            }
            catch (Exception e) { logger.Fatal("Loading configuration", e); Console.ReadKey(); return; }

            ServiceContainer.Container.RegisterType <ITwitchService, TwitchService>(new InjectionConstructor(config.twitchClientID, config.twitchAccessToken, config.twitchChannelsToMonitor));
            ServiceContainer.Container.RegisterType <IWoWService, WoWService>(new InjectionConstructor(config.blizzardCharInfoEndpoint, config.blizzardOauthAccessTokenEndpoint, config.blizzardOauthCheckTokenEndpoint,
                                                                                                       config.client_id, config.client_secret));
            ServiceContainer.Container.RegisterType <ILeagueService, LeagueService>(new InjectionConstructor(config.lolApiKey));
            ServiceContainer.Container.RegisterType <ICoronaService, CoronaService>(new InjectionConstructor(config.coronaUrl));


            DiscordClient client = new DiscordClient(new DiscordConfiguration()
            {
                TokenType             = TokenType.Bot,
                Token                 = config.DiscordAPIKey,
                UseInternalLogHandler = true,
                LogLevel              = LogLevel.Debug,
            });


            commands = client.UseCommandsNext(new CommandsNextConfiguration
            {
                StringPrefix      = "!",
                EnableDms         = true,
                CaseSensitive     = false,
                EnableDefaultHelp = true,
            });
            commands.RegisterCommands <Commands>();

            logger.Debug("Connecting...");
            await client.ConnectAsync();

            logger.Debug("Connected, waiting for client initialization.");
            await Task.Delay(5000);

            logger.Debug("Starting initialization.");
            await Initialize(client, config);

            logger.Debug("Initialized");
            await Task.Delay(-1);
        }
Ejemplo n.º 2
0
        static async Task MainAsync(string[] args)
        {
            KomoLogger logger = new KomoLogger();

            try
            {
                config = new JsonParser().Config;
            }
            catch (Exception e) { logger.Fatal("Loading configuration", e); }

            gameStartedDictionary = new Dictionary <DiscordMember, DateTime>();

            DiscordClient client = new DiscordClient(new DiscordConfiguration()
            {
                TokenType             = TokenType.Bot,
                Token                 = config.DiscordAPIKey,
                UseInternalLogHandler = true,
                LogLevel              = LogLevel.Debug,
            });

            WireUpEvents(client);

            voiceClient = client.UseVoiceNext();

            commands = client.UseCommandsNext(new CommandsNextConfiguration
            {
                StringPrefix      = "!",
                EnableDms         = true,
                CaseSensitive     = false,
                EnableDefaultHelp = true,
            });
            commands.RegisterCommands <Commands>();

            await client.ConnectAsync();

            await Task.Delay(5000);

            await Initialize(client, config);

            await Task.Delay(-1);
        }