Example #1
0
        public override void RunAction(ChatExchangeDotNet.Message incommingChatMessage, ChatExchangeDotNet.Room chatRoom, InstallationSettings roomSettings)
        {
            // Get the stats
            var sa = new CloseQueueStatsAccessor();
            var statsMessage = sa.GetOverallQueueStats();

            // Get the next 3 tags
            var tags = SedeAccessor.GetTags(chatRoom, roomSettings.Email, roomSettings.Password);

            if (tags == null)
            {
                chatRoom.PostReplyOrThrow(incommingChatMessage, "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:{0}]".FormatInline(x.Key));

            var combinedTags = topTags.ToCSV(", ");

            var tagsMessage = "The tags to work on are: {0}.".FormatInline(combinedTags);

            chatRoom.PostMessageOrThrow(statsMessage);
            chatRoom.PostMessageOrThrow(tagsMessage);
        }
Example #2
0
        public override void RunAction(ChatExchangeDotNet.Message incommingChatMessage, ChatExchangeDotNet.Room chatRoom, InstallationSettings roomSettings)
        {
            var da = new DatabaseAccessor(roomSettings.DatabaseConnectionString);

            var recipientChatProfileIds = da.GetPingReviewersRecipientList(incommingChatMessage.Author.ID, roomSettings.PingReviewersDaysBackThreshold);

            if (!recipientChatProfileIds.Any())
            {
                chatRoom.PostReplyOrThrow(incommingChatMessage, "No one has a completed review session in the last {0} days"
                    .FormatInline(roomSettings.PingReviewersDaysBackThreshold));
                return;
            }

            var userNames = recipientChatProfileIds
                .Select(x => chatRoom.GetUser(x).Name)
                .Select(x => "@" + x.Replace(" ", ""));

            var combinedUserNames = userNames.ToCSV(" ");

            var messageFromIncommingChatMessage = GetRegexMatchingObject()
                .Match(GetMessageContentsReadyForRegexParsing(incommingChatMessage))
                .Groups[1]
                .Value;

            var outboundMessage = "{0} {1}".FormatInline(messageFromIncommingChatMessage, combinedUserNames);
            chatRoom.PostMessageOrThrow(outboundMessage);
        }
Example #3
0
        public override void RunAction(ChatExchangeDotNet.Message incommingChatMessage, ChatExchangeDotNet.Room chatRoom, InstallationSettings roomSettings)
        {
            var sa = new CloseQueueStatsAccessor();
            var message = sa.GetOverallQueueStats();

            chatRoom.PostMessageOrThrow(message);
        }
Example #4
0
        public override void RunAction(ChatExchangeDotNet.Message incommingChatMessage, ChatExchangeDotNet.Room chatRoom, InstallationSettings roomSettings)
        {
            var elapsedTime = DateTime.Now - ChatBotStats.LoginDate;

            Assembly assembly = Assembly.GetExecutingAssembly();
            FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location);
            string version = fvi.FileVersion;

            var message = "SOCVR ChatBot version {0}, running for {1}."
                .FormatInline(version, elapsedTime.ToUserFriendlyString());

            chatRoom.PostMessageOrThrow(message);
        }
        public override void RunAction(ChatExchangeDotNet.Message incommingChatMessage, ChatExchangeDotNet.Room chatRoom, InstallationSettings roomSettings)
        {
            var runningCommands = RunningChatbotActionsManager.GetRunningChatbotActions();
            var now = DateTimeOffset.Now;

            var tableMessage = runningCommands
                .Select(x => new
                {
                    Command = x.ChatbotActionName,
                    ForUser = "******".FormatInline(x.RunningForUserName, x.RunningForUserId),
                    Started = (now - x.StartTs).ToUserFriendlyString() + " ago",
                })
                .ToStringTable(new[] { "Command", "For User", "Started" },
                    x => x.Command,
                    x => x.ForUser,
                    x => x.Started);

            chatRoom.PostReplyOrThrow(incommingChatMessage, "The following is a list of commands that I'm currently running:");
            chatRoom.PostMessageOrThrow(tableMessage);
        }
        public override void RunAction(ChatExchangeDotNet.Message incommingChatMessage, ChatExchangeDotNet.Room chatRoom, InstallationSettings roomSettings)
        {
            var da = new DatabaseAccessor(roomSettings.DatabaseConnectionString);
            var completedTags = da.GetUserCompletedTags(incommingChatMessage.Author.ID);

            if (!completedTags.Any())
            {
                chatRoom.PostReplyOrThrow(incommingChatMessage, "I don't have any completed tags by you on record. When you run out of items in your filter paste the message into chat here and I'll record it.");
                return;
            }

            var headerMessage = "Showing all tags cleared by you that I have on record:";
            var dataMessage = completedTags
                .ToStringTable(new string[] { "Tag Name", "Times Cleared", "Last Cleared" },
                    x => x.TagName,
                    x => x.TimesCleared,
                    x => x.LastTimeCleared.ToUniversalTime().ToString("yyyy-MM-dd HH:mm:ss 'UTC'"));

            chatRoom.PostReplyOrThrow(incommingChatMessage, headerMessage);
            chatRoom.PostMessageOrThrow(dataMessage);
        }
Example #7
0
        public override void RunAction(ChatExchangeDotNet.Message incommingChatMessage, ChatExchangeDotNet.Room chatRoom, InstallationSettings roomSettings)
        {
            var thresholdInCommand =  GetRegexMatchingObject()
                .Match(GetMessageContentsReadyForRegexParsing(incommingChatMessage))
                .Groups[1]
                .Value
                .Parse<int?>();

            if (thresholdInCommand != null && thresholdInCommand <= 0)
            {
                chatRoom.PostReplyOrThrow(incommingChatMessage, "Minimum person threshold must be greater or equal to 1.");
                return;
            }

            var defaultThreshold = roomSettings.DefaultCompletedTagsPeopleThreshold;

            var peopleThreshold = thresholdInCommand ?? defaultThreshold; // Take the one in the command, or the default if the command one is not given.
            var usingDefault = thresholdInCommand == null;

            var da = new DatabaseAccessor(roomSettings.DatabaseConnectionString);
            var completedTagsData = da.GetCompletedTags(peopleThreshold, 10); //10 is hard coded for now, could be changed later

            var headerMessage = "Showing the latest 10 tags that have been cleared by at least {0} {1}."
                .FormatInline(peopleThreshold, peopleThreshold != 1 ? "people" : "person");

            if (usingDefault)
            {
                headerMessage += " To give a different threshold number, use the command `{0}`."
                    .FormatInline(ChatbotActionRegister.GetChatBotActionUsage<CompletedTags>());
            }

            string dataMessage;

            if (completedTagsData.Any())
            {
                dataMessage = completedTagsData
                    .ToStringTable(new[] { "Tag Name", "Count", "Latest Time Cleared" },
                        (x) => x.TagName,
                        (x) => x.PeopleWhoCompletedTag,
                        (x) => x.LastEntryTs.ToUniversalTime().ToString("yyyy-MM-dd HH:mm:ss 'UTC'"));
            }
            else
            {
                dataMessage = "    There are no entries that match that request!";
            }

            chatRoom.PostReplyOrThrow(incommingChatMessage, headerMessage);
            chatRoom.PostMessageOrThrow(dataMessage);
        }