public static async Task HandleAdded(PopUpNews popUpNews) { // Localize the embed description Dictionary <Language, string> localizedDescriptions = Localizer.LocalizeToAllLanguages("popup_news.description", Nintendo.SmashUltimate.Bcat.Container.LanguageOrder); // Create a new Dictionary for localized descriptions with the URL Dictionary <Language, string> localizedDescriptionsWithUrl = new Dictionary <Language, string>(); // Loop over every localized description foreach (KeyValuePair <Language, string> pair in localizedDescriptions) { // Format the URL in the description localizedDescriptionsWithUrl.Add(pair.Key, string.Format(pair.Value, popUpNews.ContentText[pair.Key], $"https://smash.oatmealdome.me/popup_news/{popUpNews.Id}/{pair.Key.GetCode()}/")); } // Create localized Embeds Dictionary <Language, Embed> localizedEmbeds = new LocalizedEmbedBuilder(Nintendo.SmashUltimate.Bcat.Container.LanguageOrder) .WithTitle(popUpNews.TitleText) .WithDescription(localizedDescriptionsWithUrl) .AddField("popup_news.start_time", Localizer.LocalizeDateTimeToAllLanguages(popUpNews.StartDateTime)) .AddField("popup_news.end_time", Localizer.LocalizeDateTimeToAllLanguages(popUpNews.EndDateTime)) .WithImageUrl($"https://cdn.oatmealdome.me/smash/popup_news/{popUpNews.Id}/image.jpg") .Build(); // Send the notifications await DiscordBot.SendNotificationAsync("**[News]**", localizedEmbeds); }
public static void HandleAdded(PopUpNews popUpNews) { // Check if this is an event pop-up news and is not the initial pop-up if (popUpNews.IsPopUpForEvent && !popUpNews.Id.StartsWith("01")) { // Skip return; } // Get the tweet header string tweetHeader = Localizer.Localize("twitter.popupnews.header", Language.EnglishUS); // Get the tweet URL component string tweetUrl = string.Format(Localizer.Localize("twitter.popupnews.url", Language.EnglishUS), $"https://smash.oatmealdome.me/popup_news/{popUpNews.Id}/en-US/"); // Send the tweet TwitterManager.GetAccount("SSBUBot").Tweet(tweetHeader, popUpNews.TitleText[Language.EnglishUS], tweetUrl, popUpNews.Image); }
public static async Task <bool> ScheduleArchival(Container container, DateTime dateTime) { // Check if this is an event PopUpNews PopUpNews popUpNews = container as PopUpNews; if (popUpNews != null && popUpNews.IsPopUpForEvent) { // Skip return(false); } // Create the job name string jobName = container.GetType().Name + container.Id; // Get the Url string url = container.GetFormattedUrl(); if (url.Length == 0) { // Skip return(false); } // Create the JobDataMap JobDataMap dataMap = new JobDataMap(); dataMap.Put(ContainerArchivalJob.ARCHIVAL_DATA_PREFIX, FileTypeExtensions.GetNamePrefixFromType(FileTypeExtensions.GetTypeFromContainer(container))); dataMap.Put(ContainerArchivalJob.ARCHIVAL_DATA_ID, container.Id); dataMap.Put(ContainerArchivalJob.ARCHIVAL_DATA_URL, url); // Schedule the job for this Container await QuartzScheduler.ScheduleJob <ContainerArchivalJob>(jobName, dateTime, dataMap); await DiscordBot.LoggingChannel.SendMessageAsync($"**[ArchivalHandler]** Scheduled archival job for {container.GetType().Name} ({container.Id})"); return(true); }
public async Task Execute(string id = null, string languageString = null) { // Get the language Language language = DiscordUtil.GetDefaultLanguage(Context.Guild, languageString); // Check for no ID if (id == null) { await ListCommand.ListContainers(FileType.PopUpNews, language, Context); return; } // Get the PopUpNews with this ID PopUpNews popUpNews = ContainerCache.GetPopUpNewsWithId(id); // Check if this exists if (popUpNews == null) { throw new LocalizedException("popup_news.not_found"); } // Localize the description string localizedDescription = string.Format(Localizer.Localize("popup_news.description", language), popUpNews.ContentText[language], $"https://smash.oatmealdome.me/popup_news/{popUpNews.Id}/{language.GetCode()}/"); // Construct the Embed Embed embed = new EmbedBuilder() .WithTitle(popUpNews.TitleText[language]) .WithDescription(localizedDescription) .AddField(Localizer.Localize("popup_news.start_time", language), Localizer.LocalizeDateTime(popUpNews.StartDateTime, language), true) .AddField(Localizer.Localize("popup_news.end_time", language), Localizer.LocalizeDateTime(popUpNews.EndDateTime, language), true) .WithImageUrl($"https://cdn.oatmealdome.me/smash/popup_news/{popUpNews.Id}/image.jpg") .Build(); await Context.Channel.SendMessageAsync(embed : embed); }