private string GetModuleList(ulong guildId) { string finalStr = ((Program.Module) 0).ToString(); for (Program.Module i = (Program.Module) 1; i <= (Program.Module.Youtube - 1); i++) { if (i == Program.Module.Settings || i == Program.Module.Information) { continue; } finalStr += ", " + i.ToString(); } finalStr += " " + Base.Sentences.OrStr(guildId) + " " + Program.Module.Youtube.ToString(); return(finalStr); }
public async Task Status() { await p.DoAction(Context.User, Program.Module.Information); EmbedBuilder embed = new EmbedBuilder() { Title = Sentences.ServicesAvailability(Context.Guild) }; var textChan = Context.Channel as ITextChannel; if (textChan != null && !textChan.IsNsfw) { embed.WithFooter("Ask again in a NSFW channel for a more complete status."); } List <string> disabledModules = new List <string>(); for (Program.Module i = 0; i <= Enum.GetValues(typeof(Program.Module)).Cast <Program.Module>().Max(); i++) { if (!Program.p.db.IsAvailable(Context.Guild?.Id ?? 0, i)) { disabledModules.Add(i.ToString()); } } embed.Description = disabledModules.Count == 0 ? "All modules are enabled" : "Disabled modules:" + string.Join(", ", disabledModules); string[] toCheck = new[] { "opus.dll", "libsodium.dll", "ffmpeg.exe", "youtube-dl.exe", }; List <string> missingFiles = new List <string>(); foreach (string file in toCheck) { if (!File.Exists(file)) { missingFiles.Add(file); } } if (p.translationClient == null) { missingFiles.Add("Google Translate API Key"); } if (p.visionClient == null) { missingFiles.Add("Google Vision API Key"); } if (p.GitHubKey == null) { missingFiles.Add("GitHub API Key"); } if (p.kitsuAuth == null) { missingFiles.Add("Kitsu Logins"); } if (p.youtubeService == null) { missingFiles.Add("YouTube API Key"); } embed.AddField("Missing Files", missingFiles.Count == 0 ? "None" : string.Join(", ", missingFiles)); embed.AddField("Game Dictionnaries", ScoreManager.GetInformation(Context.Guild)); if (Context.Guild != null) { embed.AddField("Anime/Manga Subscription Channel", await p.db.GetMyChannelNameAnimeAsync(Context.Guild)); if (textChan.IsNsfw) { var doujinChan = await p.db.GetMyChannelNameDoujinshiAsync(Context.Guild); embed.AddField("Doujinshi Subscription Channel", doujinChan?.Mention ?? "None"); if (doujinChan != null) { var tags = Program.p.db.NHentaiSubscription.Where(x => x.Item1.Id == doujinChan.Id).ElementAt(0); embed.AddField("Doujinshi Subscription Tags", "Whitelist: " + tags.Item2.GetWhitelistTags() + Environment.NewLine + "Blacklist: " + tags.Item2.GetBlacklistTags()); } } } embed.AddField("Profile Count", Program.p.cm.GetProfileCount(), true); embed.AddField("Anime Subscription Count", Program.p.db.AnimeSubscription.Count(), true); if (textChan == null || textChan.IsNsfw) { embed.AddField("Doujinshi Subscription Count", Program.p.db.NHentaiSubscription.Count(), true); } embed.Color = Color.Blue; Dictionary <string, int> allTrads = new Dictionary <string, int>(); foreach (var elem in Program.p.allLanguages) { allTrads.Add(elem.Key, 0); } foreach (var s in Program.p.translations) { if (s.Value.Any(x => x.language == "en")) { foreach (var trad in s.Value) { allTrads[trad.language]++; } } } string finalLanguage = ""; int enRef = allTrads["en"]; foreach (var s in allTrads) { finalLanguage += CultureInfo.CurrentCulture.TextInfo.ToTitleCase(Program.p.allLanguages[s.Key][0]) + ": " + (s.Value * 100 / enRef) + "%" + Environment.NewLine; } embed.AddField(Sentences.TranslationsAvailability(Context.Guild), finalLanguage); await ReplyAsync("", false, embed.Build()); }
public async Task Status() { await p.DoAction(Context.User, Context.Guild.Id, Program.Module.Information); int yes = 0; int no = 0; EmbedBuilder embed = new EmbedBuilder() { Title = Sentences.ServicesAvailability(Context.Guild.Id) }; string description = ""; for (Program.Module i = 0; i < Program.Module.Youtube; i++) { description += "**" + i.ToString() + "**: " + ((Program.p.db.IsAvailable(Context.Guild.Id, i)) ? (Sentences.Enabled(Context.Guild.Id)) : (Sentences.Disabled(Context.Guild.Id))) + Environment.NewLine; } embed.Description = description; if (Program.p.db.IsAvailable(Context.Guild.Id, Program.Module.Radio)) { embed.AddField("Radio Module", "**Opus dll:** " + ((File.Exists("opus.dll") ? ("Yes") : ("No"))) + Environment.NewLine + "**Lib Sodium dll:** " + ((File.Exists("libsodium.dll") ? ("Yes") : ("No"))) + Environment.NewLine + "**Ffmpeg:** " + ((File.Exists("ffmpeg.exe") ? ("Yes") : ("No"))) + Environment.NewLine + "**youtube-dl:** " + ((File.Exists("youtube-dl.exe") ? ("Yes") : ("No"))) + Environment.NewLine + "**YouTube API key:** " + ((p.youtubeService != null ? ("Yes") : ("No")))); if (File.Exists("opus.dll") && File.Exists("libsodium.dll") && File.Exists("ffmpeg.exe") && p.youtubeService != null) { yes++; } else { no++; } } if (Program.p.db.IsAvailable(Context.Guild.Id, Program.Module.Game)) { embed.AddField("Game Module", ScoreManager.GetInformation(Context.Guild.Id, ref yes, ref no)); } if (Program.p.db.IsAvailable(Context.Guild.Id, Program.Module.Linguistic)) { embed.AddField("Linguistic Module - Translations", "**Google Translate API key:** " + ((p.translationClient != null ? ("Yes") : ("No"))) + Environment.NewLine + "**Google Vision API key:** " + ((p.visionClient != null ? ("Yes") : ("No")))); if (p.translationClient != null) { yes++; if (p.visionClient != null) { yes++; } else { no++; } } else { no += 2; } } embed.AddField("Information Module - Logs", "**GitHub API key:** " + (p.GitHubKey != null ? "Yes" : "No")); if (p.GitHubKey != null) { yes++; } else { no++; } embed.AddField("Anime/Manga Module - NSFW", "**Kitsu logins:** " + (p.kitsuAuth != null ? "Yes" : "No")); embed.AddField("Anime/Manga Module - Subscription", "**Subscription channel:** " + await p.db.GetMyChannelNameAsync(Context.Guild)); if (p.kitsuAuth != null) { yes++; } else { no++; } if (Program.p.db.IsAvailable(Context.Guild.Id, Program.Module.Youtube)) { embed.AddField("YouTube Module", "**YouTube API key:** " + ((p.youtubeService != null) ? ("Yes") : ("No"))); if (p.youtubeService != null) { yes++; } else { no++; } } if (yes + no == 0) { yes++; } int max = yes + no; embed.Color = new Color(no * 255 / max, yes * 255 / max, 0); Dictionary <string, int> allTrads = new Dictionary <string, int>(); foreach (var elem in Program.p.allLanguages) { allTrads.Add(elem.Key, 0); } foreach (var s in Program.p.translations) { if (s.Value.Any(x => x.language == "en")) { foreach (var trad in s.Value) { allTrads[trad.language]++; } } } string finalLanguage = ""; int enRef = allTrads["en"]; foreach (var s in allTrads) { finalLanguage += CultureInfo.CurrentCulture.TextInfo.ToTitleCase(Program.p.allLanguages[s.Key][0]) + ": " + (s.Value * 100 / enRef) + "%" + Environment.NewLine; } embed.AddField(Sentences.TranslationsAvailability(Context.Guild.Id), finalLanguage); await ReplyAsync("", false, embed.Build()); }
private async Task ManageModule(IMessageChannel chan, string[] args, int enable) { await p.DoAction(Context.User, Context.Guild.Id, Program.Module.Settings); if (!CanModify(Context.User, Context.Guild.OwnerId)) { await ReplyAsync(Base.Sentences.OnlyOwnerStr(Context.Guild.Id, Context.Guild.OwnerId)); return; } if (args.Length == 0) { await chan.SendMessageAsync(Sentences.ModuleManagementHelp(Context.Guild.Id) + " " + GetModuleList(Context.Guild.Id)); return; } Program.Module?module = null; string name = Utilities.AddArgs(args).Replace(" ", ""); if (name == "all") // Enable/Disable all modules at once { if (enable == 1 && Program.p.db.AreAllAvailable(Context.Guild.Id)) { await chan.SendMessageAsync(Sentences.AllModulesAlreadyEnabled(Context.Guild.Id)); } else if (enable == 0 && Program.p.db.AreNoneAvailable(Context.Guild.Id)) { await chan.SendMessageAsync(Sentences.AllModulesAlreadyDisabled(Context.Guild.Id)); } else { for (Program.Module i = 0; i <= Program.Module.Youtube; i++) { // We can't disable Settings and Information module // We however can enable them, just in case if (enable == 0 && (i == Program.Module.Settings || i == Program.Module.Information)) { continue; } await Program.p.db.SetAvailability(Context.Guild.Id, i, enable); } if (enable == 1) { await chan.SendMessageAsync(Sentences.AllModulesEnabled(Context.Guild.Id)); } else { await chan.SendMessageAsync(Sentences.AllModulesDisabled(Context.Guild.Id)); } } return; } for (Program.Module i = 0; i <= Program.Module.Youtube; i++) { if (i == Program.Module.Settings || i == Program.Module.Information) { continue; } if (i.ToString().ToLower() == name.ToLower()) { module = i; break; } } if (module == null) { await chan.SendMessageAsync(Sentences.ModuleManagementInvalid(Context.Guild.Id) + " " + GetModuleList(Context.Guild.Id)); return; } bool availability = Program.p.db.IsAvailable(Context.Guild.Id, module.Value); if (availability && enable == 1) { await chan.SendMessageAsync(Sentences.ModuleAlreadyEnabled(Context.Guild.Id, module.ToString())); } else if (!availability && enable == 0) { await chan.SendMessageAsync(Sentences.ModuleAlreadyDisabled(Context.Guild.Id, module.ToString())); } else { await Program.p.db.SetAvailability(Context.Guild.Id, module.Value, enable); if (enable == 1) { await chan.SendMessageAsync(Sentences.ModuleEnabled(Context.Guild.Id, module.ToString())); } else { await chan.SendMessageAsync(Sentences.ModuleDisabled(Context.Guild.Id, module.ToString())); } } }