/// <summary> /// Build and post the Discord message for Void Traders /// </summary> private void PostVoidTraderMessage() { var finalMessage = new StringBuilder(); var messagesToNotify = new List <string>(); finalMessage.Append(WarframeEventExtensions.FormatMessage($"VOID TRADER{(_voidTraderMessagePostQueue.Count == 0 ? " HAS LEFT" : string.Empty)}", MessageMarkdownLanguageIdPreset.ActiveEvent, string.Empty, MessageFormat.Bold)); //Core content of the Discord message without any formatting var coreMessageContent = new StringBuilder(); foreach (var message in _voidTraderMessagePostQueue) { coreMessageContent.AppendLine(WarframeEventExtensions.DiscordMessage(message.WarframeEvent as dynamic, false) + Environment.NewLine); } finalMessage.Append(WarframeEventExtensions.FormatMessage(coreMessageContent.ToString(), preset: MessageMarkdownLanguageIdPreset.ActiveEvent, formatType: MessageFormat.CodeBlocks)); if (_traderMessage == null) { _traderMessage = SendMessageToChannel(finalMessage.ToString(), _voidTraderChannelId); } else { EditEventMessage(finalMessage.ToString(), _traderMessage); foreach (var item in messagesToNotify) { NotifyClient(item, _voidTraderChannelId); } } _voidTraderMessagePostQueue.Clear(); }
public string BuildAlertInformation(IReadOnlyList <WarframeAlert> alerts) { var finalMessage = new StringBuilder(); var messagesToNotify = new List <string>(); if (alerts.Count == 0) { finalMessage.Append(WarframeEventExtensions.FormatMessage("NO ACTIVE ALERTS", preset: MessageMarkdownLanguageIdPreset.ActiveEvent, formatType: MessageFormat.CodeBlocks)); } alerts = alerts.OrderBy(s => s.GetMinutesRemaining(false)).ToList(); foreach (var alert in alerts) { var coreMessageContent = new StringBuilder(); coreMessageContent.AppendLine(WarframeEventExtensions.DiscordMessage(alert as dynamic, false)); var messageMarkdownPreset = MessageMarkdownLanguageIdPreset.ActiveEvent; if (alert.IsNew()) { coreMessageContent.Append("( new )"); messagesToNotify.Add(WarframeEventExtensions.DiscordMessage(alert as dynamic, true)); messageMarkdownPreset = MessageMarkdownLanguageIdPreset.NewEvent; } finalMessage.Append(WarframeEventExtensions.FormatMessage(coreMessageContent.ToString(), preset: messageMarkdownPreset, formatType: MessageFormat.CodeBlocks)); } return(finalMessage.ToString()); }
/// <summary> /// Build and post the Discord message for Void Fissures /// </summary> private void PostVoidFissureMessage() { var finalMessage = new StringBuilder(); var messagesToNotify = new List <string>(); if (_voidFissureMessagePostQueue.Count == 0) { finalMessage.Append(WarframeEventExtensions.FormatMessage("NO VOID FISSURES", preset: MessageMarkdownLanguageIdPreset.ActiveEvent, formatType: MessageFormat.CodeBlocks)); } _voidFissureMessagePostQueue = _voidFissureMessagePostQueue .OrderBy(s => s.WarframeEvent.GetFissureIndex()) .ThenBy(s => s.WarframeEvent.GetMinutesRemaining(false)).ToList(); foreach (var message in _voidFissureMessagePostQueue) { //Core content of the Discord message without any formatting var coreMessageContent = new StringBuilder(); coreMessageContent.AppendLine(WarframeEventExtensions.DiscordMessage(message.WarframeEvent as dynamic, false)); var markdownPreset = MessageMarkdownLanguageIdPreset.ActiveEvent; if (message.NotifyClient) { coreMessageContent.Append("( new )"); messagesToNotify.Add(WarframeEventExtensions.DiscordMessage(message.WarframeEvent as dynamic, false)); markdownPreset = MessageMarkdownLanguageIdPreset.NewEvent; } finalMessage.Append(WarframeEventExtensions.FormatMessage(coreMessageContent.ToString(), preset: markdownPreset, formatType: MessageFormat.CodeBlocks)); } if (_fissureMessage == null) { _fissureMessage = SendMessageToChannel(finalMessage.ToString(), _fissureChannelId); } else { EditEventMessage(finalMessage.ToString(), _fissureMessage); foreach (var item in messagesToNotify) { NotifyClient(item, _fissureChannelId); } } _voidFissureMessagePostQueue.Clear(); }
private void PostOstronBountyCycleMessage() { var finalMessage = new StringBuilder(); var messagesToNotify = new List <string>(); finalMessage.Append(WarframeEventExtensions.FormatMessage("OSTRON BOUNTIES", preset: MessageMarkdownLanguageIdPreset.ActiveEvent, formatType: MessageFormat.Bold)); foreach (var message in _ostronBountyCyclePostQueue) { //Core content of the Discord message without any formatting var coreMessageContent = new StringBuilder(); coreMessageContent.AppendLine(WarframeEventExtensions.DiscordMessage(message.WarframeEvent as dynamic, false)); finalMessage.Append(WarframeEventExtensions.FormatMessage(coreMessageContent.ToString(), preset: MessageMarkdownLanguageIdPreset.ActiveEvent, formatType: MessageFormat.CodeBlocks)); } if (_ostronBountyMessagePostQueue.Count > 0) { foreach (var message in _ostronBountyMessagePostQueue) { var bountiesMessage = new StringBuilder().AppendLine(WarframeEventExtensions.DiscordMessage(message.WarframeEvent as dynamic, false)); finalMessage.Append(WarframeEventExtensions.FormatMessage(bountiesMessage.ToString(), preset: MessageMarkdownLanguageIdPreset.ActiveEvent, formatType: MessageFormat.CodeBlocks)); } } var t = finalMessage.ToString(); var p = t.Length; if (_ostronBountyInformationMessage == null) { _ostronBountyInformationMessage = SendMessageToChannel(finalMessage.ToString(), _earthChannelId); } else { EditEventMessage(finalMessage.ToString(), _ostronBountyInformationMessage); foreach (var item in messagesToNotify) { NotifyClient(item, _earthChannelId); } } _ostronBountyMessagePostQueue.Clear(); _ostronBountyCyclePostQueue.Clear(); }
private void PostAcolyteMessage() { //Ignore the acolytes section if there aren't any if (_acolyteMessagePostQueue.Count() == 0) { return; } var finalMessage = new StringBuilder(); var messagesToNotify = new List <string>(); foreach (var message in _acolyteMessagePostQueue) { var coreMessageContent = new StringBuilder(); coreMessageContent.AppendLine(WarframeEventExtensions.DiscordMessage(message.WarframeEvent as dynamic, false)); var markdownPreset = MessageMarkdownLanguageIdPreset.ActiveEvent; if (message.NotifyClient) { coreMessageContent.Append("( new )"); messagesToNotify.Add(WarframeEventExtensions.DiscordMessage(message.WarframeEvent as dynamic, true)); markdownPreset = MessageMarkdownLanguageIdPreset.NewEvent; } finalMessage.Append(WarframeEventExtensions.FormatMessage(coreMessageContent.ToString(), preset: markdownPreset, formatType: MessageFormat.CodeBlocks)); } if (_acolyteMessage == null) { _acolyteMessage = SendMessageToChannel(finalMessage.ToString(), _acolyteChannelId); } else { EditEventMessage(finalMessage.ToString(), _acolyteMessage); foreach (var item in messagesToNotify) { NotifyClient(item, _acolyteChannelId); } } _acolyteMessagePostQueue.Clear(); }
/// <summary> /// Build and post the Discord message for sorties /// </summary> private void PostSortieMessage() { var finalMessage = new StringBuilder(); var messagesToNotify = new List <string>(); if (_sortieMessagePostQueue.Count == 0) { finalMessage.Append(WarframeEventExtensions.FormatMessage("NO SORTIES", preset: MessageMarkdownLanguageIdPreset.ActiveEvent, formatType: MessageFormat.CodeBlocks)); } foreach (var message in _sortieMessagePostQueue) { //Core content of the Discord message without any formatting var coreMessageContent = new StringBuilder(); coreMessageContent.AppendLine(WarframeEventExtensions.DiscordMessage(message.WarframeEvent as dynamic, false)); if (message.NotifyClient) { messagesToNotify.Add(WarframeEventExtensions.DiscordMessage(message.WarframeEvent as dynamic, true)); } finalMessage.Append(WarframeEventExtensions.FormatMessage(coreMessageContent.ToString(), preset: MessageMarkdownLanguageIdPreset.ActiveEvent, formatType: MessageFormat.CodeBlocks)); } if (_sortieMessage == null) { _sortieMessage = SendMessageToChannel(finalMessage.ToString(), _sortieChannelId); } else { EditEventMessage(finalMessage.ToString(), _sortieMessage); foreach (var item in messagesToNotify) { NotifyClient(item, _sortieChannelId); } } _sortieMessagePostQueue.Clear(); }
/// <summary> /// Build and post the Discord message for invasions /// </summary> private void PostInvasionMessage() { var finalMessagesToPost = new List <StringBuilder>(); var messagesToNotify = new List <string>(); //Messages will append to this builder until the length reaches the MESSAGE_CHAR_LIMIT value //Due to the potential length of an invasion message, it may need to be broken down into smaller messages. Hence - entryForFinalMessage var entryForFinalMessage = new StringBuilder(); finalMessagesToPost.Add(entryForFinalMessage); if (_invasionMessagePostQueue.Count == 0) { entryForFinalMessage.Append(WarframeEventExtensions.FormatMessage("NO ACTIVE INVASIONS", preset: MessageMarkdownLanguageIdPreset.ActiveEvent, formatType: MessageFormat.CodeBlocks)); } _invasionMessagePostQueue = _invasionMessagePostQueue .OrderByDescending(s => Math.Abs(s.WarframeEvent.Progress)).ToList(); foreach (var message in _invasionMessagePostQueue) { //Core content of the Discord message without any formatting var coreMessageContentEntry = new StringBuilder(); coreMessageContentEntry.AppendLine(WarframeEventExtensions.DiscordMessage(message.WarframeEvent as dynamic, false)); MessageMarkdownLanguageIdPreset markdownPreset = MessageMarkdownLanguageIdPreset.ActiveEvent; if (message.NotifyClient) { messagesToNotify.Add(WarframeEventExtensions.DiscordMessage(message.WarframeEvent as dynamic, true)); coreMessageContentEntry.Append("( new )"); markdownPreset = MessageMarkdownLanguageIdPreset.NewEvent; } //Create a new entry in the post queue if the character length of the current message hits the character limit if (entryForFinalMessage.Length + coreMessageContentEntry.Length < MESSAGE_CHAR_LIMIT) { entryForFinalMessage.Append(WarframeEventExtensions.FormatMessage(coreMessageContentEntry.ToString(), preset: markdownPreset, formatType: MessageFormat.CodeBlocks)); } else { entryForFinalMessage.Append(coreMessageContentEntry.ToString()); finalMessagesToPost.Add(entryForFinalMessage); } } //Project Construction Information var constructionMessage = new StringBuilder(); if (_invasionConstructionMessagePostQueue.Count > 0) { foreach (var message in _invasionConstructionMessagePostQueue) { constructionMessage.Append(WarframeEventExtensions.DiscordMessage(message.WarframeEvent as dynamic, false)); } entryForFinalMessage.Append(WarframeEventExtensions.FormatMessage(constructionMessage.ToString(), preset: MessageMarkdownLanguageIdPreset.ActiveEvent, formatType: MessageFormat.CodeBlocks)); } if (_invasionMessages.Count > 0) { foreach (var item in messagesToNotify) { NotifyClient(item, _invasionChannelId); } } for (var i = 0; i < finalMessagesToPost.Count; ++i) { //If invasion messages already exist if (i < _invasionMessages.Count) { EditEventMessage(finalMessagesToPost.ElementAt(i).ToString(), _invasionMessages.ElementAt(i)); } else //When we run out of available invasion messages to edit { _invasionMessages.Add(SendMessageToChannel(finalMessagesToPost.ElementAt(i).ToString(), _invasionChannelId)); } } //Get rid of any extra messages which have been created as a result of long character counts in Discord messages if (_invasionMessages.Count > finalMessagesToPost.Count) { var range = _invasionMessages.GetRange(finalMessagesToPost.Count, _invasionMessages.Count - finalMessagesToPost.Count); range.ForEach(msg => DeleteMessage(msg)); _invasionMessages.RemoveRange(finalMessagesToPost.Count, _invasionMessages.Count - finalMessagesToPost.Count); } #if DEBUG foreach (var i in finalMessagesToPost) { Log(i.Length + " characters long"); } #endif _invasionMessagePostQueue.Clear(); _invasionConstructionMessagePostQueue.Clear(); }