Пример #1
0
        protected override string GetProcessSuccessfulMessage(PermissionRequest request, Room chatRoom)
        {
            var msg = new MessageBuilder();

            msg.AppendPing(chatRoom.GetUser(request.RequestingUserId));
            msg.AppendText($"has been added to the {request.RequestedPermissionGroup} group.");
            return(msg.ToString());
        }
Пример #2
0
        public override void RunAction(Message incomingChatMessage, Room chatRoom)
        {
            using (var db = new DatabaseContext())
            {
                var days      = ConfigurationAccessor.PingReviewersDaysBackThreshold;
                var startDate = DateTimeOffset.UtcNow.Date.AddDays(-days);

                var reviewsInTimeFrame = db.ReviewedItems
                                         .Where(x => x.ReviewedOn.Date >= startDate)
                                         .ToList();

                if (!reviewsInTimeFrame.Any())
                {
                    chatRoom.PostReplyOrThrow(incomingChatMessage, $"No one has a completed review session in the last {days} days");
                    return;
                }

                var allProfileIds = reviewsInTimeFrame
                                    .Select(x => x.ReviewerId)
                                    .Distinct()
                                    .Except(new[] { incomingChatMessage.Author.ID }) //exclude yourself
                                    .ToList();

                var pingableProfileIds = (from profileId in allProfileIds
                                          join pingableUser in chatRoom.PingableUsers on profileId equals pingableUser.ID
                                          select profileId)
                                         .ToList();

                if (!pingableProfileIds.Any())
                {
                    chatRoom.PostReplyOrThrow(incomingChatMessage, "There is no one to ping.");
                    return;
                }

                var msg = new MessageBuilder();

                var messageFromIncomingChatMessage = GetRegexMatchingObject()
                                                     .Match(incomingChatMessage.Content)
                                                     .Groups[1]
                                                     .Value;

                msg.AppendText(messageFromIncomingChatMessage + " ");

                foreach (var profileId in pingableProfileIds)
                {
                    msg.AppendPing(chatRoom.GetUser(profileId));
                }

                chatRoom.PostMessageOrThrow(msg);
            }
        }
Пример #3
0
        public void ProcessMessage(Message msg, ref Room rm)
        {
            var cmdsMsg = new MessageBuilder(MultiLineMessageType.Code, false);

            cmdsMsg.AppendPing(msg.Author);

            foreach (var cmd in commands)
            {
                cmdsMsg.AppendText("\n" + cmd.Usage + " - " + cmd.Description);
            }

            cmdsMsg.AppendText("\n" + Usage + " - " + Description);

            rm.PostMessageLight(cmdsMsg);
        }