예제 #1
0
        internal static void Main(string[] args)
        {
            Console.WriteLine("Loading keystore");
            KeyManager = new KeyManager("keystore.json");
            if (!KeyManager.HasKey("pgmain"))
            {
                KeyManager.AddKey("pgmain", 256);
            }
            Console.WriteLine("Keystore loaded");

            MainAsync(args).GetAwaiter().GetResult();
        }
예제 #2
0
    void Update()
    {
        if (wantToChange)
        {
            key = Input.inputString; //Asign variable Key as the current Input

            if (Input.anyKey && wantToChange)
            {
                processedKey = key.ToLower(); //Lowercase the string

                foreach (string character in alowedKeys)
                {
                    if (character == processedKey)
                    {
                        //If the Key is inside the AllowedKeys then it's valid
                        validKey = true;
                    }
                }

                //check if two keys have not been pressed or that it's invalid
                if (processedKey.Length > 1 || !validKey)
                {
                    processedKey = "#";
                }
                else if (processedKey == " ")   //Check if the key is a space
                {
                    processedKey = "space";
                }

                textMeshComponent.SetText(processedKey); //Set the text to the name of the key

                wantToChange = false;

                if (validKey)
                {
                    keyManagerScript.AddKey(processedKey, id); //Add key to the Key Manager
                }
            }
        }
    }
예제 #3
0
        private void SettingsForm_KeyDown(object sender, KeyEventArgs e)
        {
            if (!string.IsNullOrEmpty(hotkeyControlActive))
            {
                Label lbl = (Label)tblPanelHotkeys.Controls[hotkeyControlActive];

                // Remove the previous bind from the manager
                _keyManager.RemoveKey((string)lbl.Tag);

                // Add the new one
                _keyManager.AddKey((string)lbl.Tag, e.KeyValue, e.KeyCode.ToString());

                // Assign the hotkey to the selected pair
                lbl.Text = e.KeyCode.ToString();

                hotkeyControlActive = string.Empty;
            }
        }
예제 #4
0
        private static async Task Order66()
        {
            KeyManager = new KeyManager("keystore.json");
            if (!KeyManager.HasKey("pgmain"))
            {
                KeyManager.AddKey("pgmain", 256);
            }

            var l = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);

            GuildEmoji = new DeviGuildEmojiMap(new Dictionary <string, string>());

            var stx = Path.Combine(l, "devi.json");
            var emx = Path.Combine(l, "emoji.json");
            var dgx = Path.Combine(l, "donger.json");

            if (File.Exists(stx) && File.Exists(emx) && File.Exists(dgx))
            {
                stx      = File.ReadAllText(stx, new UTF8Encoding(false));
                Settings = JsonConvert.DeserializeObject <DeviSettingStore>(stx);
            }
            else
            {
                throw new FileNotFoundException("Unable to load configuration file (devi.json)!");
            }

            DatabaseClient = new DeviDatabaseClient(Settings.DatabaseSettings, KeyManager);
            await DatabaseClient.PreconfigureAsync();

            if (File.Exists(emx))
            {
                emx = File.ReadAllText(emx, new UTF8Encoding(false));
                var edict = JsonConvert.DeserializeObject <Dictionary <string, string> >(emx);
                EmojiMap = new DeviEmojiMap(edict);
            }
            else
            {
                EmojiMap = new DeviEmojiMap(new Dictionary <string, string>());
            }

            if (File.Exists(dgx))
            {
                dgx     = File.ReadAllText(dgx, new UTF8Encoding(false));
                Dongers = JsonConvert.DeserializeObject <DeviDongerMap>(dgx);
                Dongers.HookAliases();
            }
            else
            {
                Dongers = new DeviDongerMap()
                {
                    Dongers = new Dictionary <string, string>(),
                    Aliases = new Dictionary <string, List <string> >()
                };
            }

            Utilities = new DeviUtilities();
            Http      = new HttpClient();

            var discord = new DiscordClient(new DiscordConfig()
            {
                LogLevel           = LogLevel.Debug,
                Token              = Settings.Token,
                TokenType          = TokenType.User,
                MessageCacheSize   = Settings.CacheSize,
                AutomaticGuildSync = false
            });

            DeviClient = discord;

            var depb = new DependencyCollectionBuilder();
            var deps = depb.AddInstance(Settings)
                       .AddInstance(EmojiMap)
                       .AddInstance(Dongers)
                       .AddInstance(GuildEmoji)
                       .AddInstance(DatabaseClient)
                       .AddInstance(Utilities)
                       .AddInstance(Http)
                       .AddInstance(Settings.CryptoSettings)
                       .AddInstance(KeyManager)
                       .Add <CryptonatorApiClient>()
                       .Add <NanopoolApiClient>()
                       .Build();

            CommandsNextUtilities.RegisterConverter(new CryptoCurrencyCodeConverter());

            var commands = discord.UseCommandsNext(new CommandsNextConfiguration
            {
                StringPrefix        = Settings.Prefix,
                SelfBot             = true,
                EnableDefaultHelp   = false,
                EnableMentionPrefix = false,
                Dependencies        = deps
            });

            DeviCommands = commands;
            DeviCommands.CommandErrored += DeviCommands_CommandErrored;
            DeviCommands.RegisterCommands <DeviCommandModule>();
            DeviCommands.RegisterCommands <DeviLogManagementModule>();
            DeviCommands.RegisterCommands <DeviCryptomarketCommands>();

            DeviMessageTracker = new List <DiscordMessage>();

            discord.GuildAvailable      += Discord_GuildAvailable;
            discord.MessageCreated      += Discord_MessageReceived;
            discord.MessageUpdated      += Discord_MessageUpdate;
            discord.MessageDeleted      += Discord_MessageDelete;
            discord.MessagesBulkDeleted += Discord_MessageBulkDelete;
            discord.Ready += Discord_Ready;
            discord.DebugLogger.LogMessageReceived += Discord_Log;
            discord.MessageReactionAdded           += Discord_ReactionAdded;
            discord.MessageReactionRemoved         += Discord_ReactionRemoved;
            discord.ClientErrored += Discord_ClientError;

            await discord.ConnectAsync();

            await Task.Delay(-1);
        }