public override void RunAction(ChatExchangeDotNet.Message incomingChatMessage, ChatExchangeDotNet.Room chatRoom) { // Get the stats var sa = new CloseQueueStatsAccessor(); var stats = sa.GetOverallQueueStats(); var statsMessage = new[] { $"{stats.NeedReview} need review", $"{stats.ReviewsToday} reviews today", $"{stats.ReviewsAllTime} reviews all-time", } .ToCSV(Environment.NewLine); // Get the next 3 tags var tags = SedeAccessor.GetTags(chatRoom, ConfigurationAccessor.LoginEmail, ConfigurationAccessor.LoginPassword); if (tags == null) { chatRoom.PostReplyOrThrow(incomingChatMessage, "My attempt to get tag data returned no information. This could be due to the site being down or blocked for me, or a programming error. Try again in a few minutes, or tell the developer if this happens often."); return; } var topTags = tags .Take(3) .Select(x => $"[tag:{x.Key}]"); var combinedTags = topTags.ToCSV(", "); var tagsMessage = $"The tags to work on are: {combinedTags}."; chatRoom.PostMessageOrThrow(statsMessage); chatRoom.PostMessageOrThrow(tagsMessage); }
public override void RunAction(ChatExchangeDotNet.Message incomingChatMessage, ChatExchangeDotNet.Room chatRoom) { // First, get the number in the command var tagsToFetchArgument = GetRegexMatchingObject() .Match(incomingChatMessage.Content) .Groups[1] .Value .Parse <int?>(); int tagsToFetch; var maxTagsToFetch = ConfigurationAccessor.MaxFetchTags; if (tagsToFetchArgument != null) { if (tagsToFetchArgument <= 0) { chatRoom.PostReplyOrThrow(incomingChatMessage, "I can't fetch zero tags or a negative number of tags! Please use a number between 1 and {0}." .FormatInline(maxTagsToFetch)); return; } if (tagsToFetchArgument > maxTagsToFetch) { chatRoom.PostReplyOrThrow(incomingChatMessage, "Sorry, that's too many tags for me. Please choose a number between 1 and {0}" .FormatInline(maxTagsToFetch)); return; } tagsToFetch = tagsToFetchArgument.Value; } else { tagsToFetch = ConfigurationAccessor.DefaultNextTagCount; } var tags = SedeAccessor.GetTags(chatRoom, ConfigurationAccessor.LoginEmail, ConfigurationAccessor.LoginPassword); if (tags == null) { chatRoom.PostReplyOrThrow(incomingChatMessage, "My attempt to get tag data returned no information. This could be due to the site being down or blocked for me, or a programming error. Try again in a few minutes, or tell the developer if this happens often."); return; } var tagString = tags .Take(tagsToFetch) .Select(x => $"[tag:{x.Key}] {x.Value}") .ToCSV(", "); var message = $"The next {tagsToFetch} tags are: {tagString}"; chatRoom.PostReplyOrThrow(incomingChatMessage, message); }
public override void RunAction(ChatExchangeDotNet.Message incomingChatMessage, ChatExchangeDotNet.Room chatRoom) { SedeAccessor.InvalidateCache(); var dataData = SedeAccessor.GetTags(chatRoom, ConfigurationAccessor.LoginEmail, ConfigurationAccessor.LoginPassword); if (dataData == null) { chatRoom.PostReplyOrThrow(incomingChatMessage, "My attempt to get tag data returned no information. This could be due to the site being down or blocked for me, or a programming error. Try again in a few minutes, or tell the developer if this happens often."); return; } chatRoom.PostReplyOrThrow(incomingChatMessage, "Tag data has been refreshed."); }
public override void RunAction(ChatExchangeDotNet.Message incomingChatMessage, ChatExchangeDotNet.Room chatRoom) { var tags = SedeAccessor.GetTags(chatRoom, ConfigurationAccessor.LoginEmail, ConfigurationAccessor.LoginPassword); if (tags == null) { chatRoom.PostReplyOrThrow(incomingChatMessage, "My attempt to get tag data returned no information. This could be due to the site being down or blocked for me, or a programming error. Try again in a few minutes, or tell the developer if this happens often."); return; } string dataMessage; if (tags != null) { dataMessage = $"The current tag is [tag:{tags.First().Key}] with {tags.First().Value} known review items."; } else { dataMessage = "I couldn't find any tags! Either the query is empty or something bad happened."; } chatRoom.PostReplyOrThrow(incomingChatMessage, dataMessage); }