//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(); }
public PublisherService(DiscordSocketClient client, DatabaseService databaseService) { _client = client; _databaseService = databaseService; _verificationCodes = new Dictionary <uint, string>(); }
private async Task MainAsync() { DeserializeSettings(); _client = new DiscordSocketClient(new DiscordSocketConfig { LogLevel = LogSeverity.Verbose, AlwaysDownloadUsers = true, MessageCacheSize = 50 }); _commandService = new CommandService(new CommandServiceConfig { CaseSensitiveCommands = false, DefaultRunMode = RunMode.Async }); _loggingService = new LoggingService(_client, _settings); _databaseService = new DatabaseService(_loggingService, _settings); _publisherService = new PublisherService(_client, _databaseService, _settings); _animeService = new AnimeService(_client, _loggingService, _settings); _feedService = new FeedService(_client, _settings); _updateService = new UpdateService(_client, _loggingService, _publisherService, _databaseService, _animeService, _settings, _feedService); _userService = new UserService(_client, _databaseService, _loggingService, _updateService, _settings, _userSettings); _audioService = new AudioService(_loggingService, _client, _settings); _casinoService = new CasinoService(_loggingService, _updateService, _databaseService, _settings); _currencyService = new CurrencyService(); _serviceCollection = new ServiceCollection(); _serviceCollection.AddSingleton(_loggingService); _serviceCollection.AddSingleton(_databaseService); _serviceCollection.AddSingleton(_userService); //_serviceCollection.AddSingleton(_work); //TODO: rework work service _serviceCollection.AddSingleton(_publisherService); _serviceCollection.AddSingleton(_updateService); _serviceCollection.AddSingleton(_audioService); _serviceCollection.AddSingleton(_animeService); _serviceCollection.AddSingleton(_casinoService); _serviceCollection.AddSingleton(_settings); _serviceCollection.AddSingleton(_rules); _serviceCollection.AddSingleton(_payWork); _serviceCollection.AddSingleton(_userSettings); _serviceCollection.AddSingleton(_currencyService); _services = _serviceCollection.BuildServiceProvider(); await InstallCommands(); _client.Log += Logger; // await InitCommands(); await _client.LoginAsync(TokenType.Bot, _settings.Token); await _client.StartAsync(); _client.Ready += () => { Console.WriteLine("Bot is connected"); //_audio.Music(); return(Task.CompletedTask); }; await Task.Delay(-1); }