Ejemplo n.º 1
0
        public PokecordCatcher()
        {
            UpdateConfiguration("config.json");
            State = Util.ReadConfiguration <State>("state.data");

            Client = new DiscordSocketClient(new DiscordSocketConfig
            {
#if DEBUG
                LogLevel = LogSeverity.Debug,
#else
                LogLevel = LogSeverity.Info,
#endif
                WebSocketProvider = Discord.Net.Providers.WS4Net.WS4NetProvider.Instance,
            });

            ResponseGrabber = new ResponseGrabber(Client);

            if (Configuration.EnableLogging)
            {
                Logger.StartLogging();
            }

            Client.Log += Log;

            Commands = new CommandService(this);
            Catcher  = new CatcherService(this, "poke.json");
            Spammer  = new SpammerService(this);
        }
Ejemplo n.º 2
0
        public PokecordCatcher(Dictionary <string, byte[]> pokemonHashes)
        {
            pokemon = new PokemonComparer(pokemonHashes);

            Configuration = JsonConvert.DeserializeObject <Configuration>(File.ReadAllText("config.json"));

            if (File.Exists("state.data"))
            {
                State = JsonConvert.DeserializeObject <State>(File.ReadAllText("state.data"));
            }
            else
            {
                State = new State
                {
                    WhitelistGuilds  = false,
                    WhitelistPokemon = false
                };
                File.WriteAllText("state.data", JsonConvert.SerializeObject(State));
            }

            Client = new DiscordSocketClient(new DiscordSocketConfig
            {
#if DEBUG
                LogLevel = LogSeverity.Verbose,
#else
                LogLevel = LogSeverity.Info,
#endif
                WebSocketProvider = Discord.Net.Providers.WS4Net.WS4NetProvider.Instance,
            });

            responseGrabber = new ResponseGrabber(Client);

            if (Configuration.EnableLogging)
            {
                Logger.StartLogging();
            }

            Client.Log             += Log;
            Client.MessageReceived += async x => Task.Run(async() => await OnMessage(x));
        }