Пример #1
0
 static Settings()
 {
     _assignableRoles = SettingsHandler.LoadValueStringArray("allRoles/roles", JsonFile.Settings).ToList();
 }
Пример #2
0
        //TODO: Add custom commands for user after (30karma ?/limited to 3 ?)

        public UserService(DatabaseService databaseService, LoggingService loggingService, UpdateService updateService)
        {
            rand                    = new Random();
            _databaseService        = databaseService;
            _loggingService         = loggingService;
            _updateService          = updateService;
            _mutedUsers             = new Dictionary <ulong, DateTime>();
            _xpCooldown             = new Dictionary <ulong, DateTime>();
            _canEditThanks          = new HashSet <ulong>(32);
            _thanksCooldown         = new Dictionary <ulong, DateTime>();
            _thanksReminderCooldown = new Dictionary <ulong, DateTime>();
            _codeReminderCooldown   = new Dictionary <ulong, DateTime>();

            _noXpChannels = new List <ulong>
            {
                Settings.GetBotCommandsChannel(),
                    Settings.GetCasinoChannel(),
                    Settings.GetMusicCommandsChannel()
            };

            /*
             * Init font for the profile card
             */
            _fontCollection = new FontCollection();
            _defaultFont    = _fontCollection
                              .Install(SettingsHandler.LoadValueString("serverRootPath", JsonFile.Settings) +
                                       "/fonts/OpenSans-Regular.ttf")
                              .CreateFont(16);
            _nameFont = _fontCollection
                        .Install(SettingsHandler.LoadValueString("serverRootPath", JsonFile.Settings) + "/fonts/Consolas.ttf")
                        .CreateFont(22);
            _levelFont = _fontCollection
                         .Install(SettingsHandler.LoadValueString("serverRootPath", JsonFile.Settings) + "/fonts/Consolas.ttf")
                         .CreateFont(59);
            _levelFontSmall = _fontCollection
                              .Install(SettingsHandler.LoadValueString("serverRootPath", JsonFile.Settings) + "/fonts/Consolas.ttf")
                              .CreateFont(45);

            _subtitlesBlackFont = _fontCollection
                                  .Install(SettingsHandler.LoadValueString("serverRootPath", JsonFile.Settings) + "/fonts/OpenSansEmoji.ttf")
                                  .CreateFont(80);
            _subtitlesWhiteFont = _fontCollection
                                  .Install(SettingsHandler.LoadValueString("serverRootPath", JsonFile.Settings) + "/fonts/OpenSansEmoji.ttf")
                                  .CreateFont(75);

            /*
             * Init XP
             */
            _xpMinPerMessage = SettingsHandler.LoadValueInt("xpMinPerMessage", JsonFile.UserSettings);
            _xpMaxPerMessage = SettingsHandler.LoadValueInt("xpMaxPerMessage", JsonFile.UserSettings);
            _xpMinCooldown   = SettingsHandler.LoadValueInt("xpMinCooldown", JsonFile.UserSettings);
            _xpMaxCooldown   = SettingsHandler.LoadValueInt("xpMaxCooldown", JsonFile.UserSettings);

            /*
             * Init thanks
             */
            StringBuilder sbThanks = new StringBuilder();

            string[] thx = SettingsHandler.LoadValueStringArray("thanks", JsonFile.UserSettings);
            sbThanks.Append("(?i)\\b(");
            for (int i = 0; i < thx.Length; i++)
            {
                sbThanks.Append(thx[i]).Append("|");
            }

            sbThanks.Length--; //Efficiently remove the final pipe that gets added in final loop, simplifying loop
            sbThanks.Append(")\\b");
            _thanksRegex                = sbThanks.ToString();
            _thanksCooldownTime         = SettingsHandler.LoadValueInt("thanksCooldown", JsonFile.UserSettings);
            _thanksReminderCooldownTime = SettingsHandler.LoadValueInt("thanksReminderCooldown", JsonFile.UserSettings);
            _thanksMinJoinTime          = SettingsHandler.LoadValueInt("thanksMinJoinTime", JsonFile.UserSettings);

            /*
             * Init Code analysis
             */
            _codeReminderCooldownTime      = SettingsHandler.LoadValueInt("codeReminderCooldown", JsonFile.UserSettings);
            _codeReminderFormattingExample = (
                @"\`\`\`cs" + Environment.NewLine +
                "Write your code on new line here." + Environment.NewLine +
                @"\`\`\`" + Environment.NewLine + Environment.NewLine +
                "Simple as that! If you'd like me to stop reminding you about this, simply type \"!disablecodetips\"");

            LoadData();
            UpdateLoop();
        }