public void DoesNotPrintEmailToSlackIfSlackChannelIsNull()
        {
            var escalationMessageBody = MessageParsingTests.EscalationMessageText;
            var email = new Email("a-subject", escalationMessageBody, EmailParser.GetSlackFormattedSummary(escalationMessageBody), "asdf", DateTime.Now,
                                  new List <string> {
                "*****@*****.**"
            }, true);

            var processor = new CompareTeamEmails(null, new Mock <ILabelPrinter>().Object);

            processor.Accept(email);
            CollectionAssert.IsEmpty(processor.ProcessTimerTick().Responses);
        }
        public void IgnoresEmailsToOtherInboxes()
        {
            var email = new Email("a-subject", "html body", "slack body", "asdf", DateTime.Now,
                                  new List <string> {
                "*****@*****.**"
            }, true);
            var processor = new CompareTeamEmails("email-channel", new Mock <ILabelPrinter>().Object);

            processor.Accept(email);
            var result = processor.ProcessTimerTick();

            CollectionAssert.IsEmpty(result.Responses);
        }
        public void IgnoresFollowupEmails()
        {
            var isFirstEmailInConversation = false;
            var email = new Email("a-subject", "html body", "slack body", "asdf", DateTime.Now,
                                  new List <string> {
                "*****@*****.**"
            }, isFirstEmailInConversation);
            var processor = new CompareTeamEmails("email-channel", new Mock <ILabelPrinter>().Object);

            processor.Accept(email);
            var result = processor.ProcessTimerTick();

            CollectionAssert.IsEmpty(result.Responses);
        }
        public void PrintsMessageForEmailToSupportInbox()
        {
            var email = new Email("a-subject", "html body", "slack body", "asdf", DateTime.Now,
                                  new List <string> {
                "*****@*****.**"
            }, true);
            var processor = new CompareTeamEmails("email-channel", new Mock <ILabelPrinter>().Object);

            processor.Accept(email);
            var result = processor.ProcessTimerTick().Responses.Single();

            Assert.AreEqual("email-channel", result.Channel);
            Assert.AreEqual("New email sent to [email protected]\n**a-subject**\nslack body",
                            result.Message);
        }
        public void PrintsSpecialMessageForZendeskEscalationEmails()
        {
            var escalationMessageBody = MessageParsingTests.EscalationMessageText;
            var email = new Email("a-subject", escalationMessageBody, EmailParser.GetSlackFormattedSummary(escalationMessageBody), "asdf", DateTime.Now,
                                  new List <string> {
                "*****@*****.**"
            }, true);
            var processor = new CompareTeamEmails("email-channel", new Mock <ILabelPrinter>().Object);

            processor.Accept(email);
            var result = processor.ProcessTimerTick().Responses.Single();

            Assert.AreEqual("email-channel", result.Channel);
            Assert.AreEqual("New support escalation for ZD#41572\n**a-subject**\n*Rob Clenshaw* (Support)\nMay 28, 14:57 \nHe\'s not happy :(\nIs there anything we can do?\n*Ticket #* 41572 \n*Status* On-hold \n*Requester* A Customer  \n*CCs* - \n*Group* SQL \n*Assignee* Rob Clenshaw \n*Priority* Normal \n*Type* Incident \n*Channel* By mail \n&nbsp;\n<http://www.zendesk.com|Zendesk>. Message-Id:NJGVB39A_55671ee12ddf9_a3103fe9d48cd3382809a3_sprutTicket-Id:41572Account-Subdomain:redgatesupport",
                            result.Message);
        }
예제 #6
0
        public static async Task MainAsync(Configuration configuration, CancellationToken cancel)
        {
            var persistence      = new JsonFileKeyValueStore(new FileInfo(configuration.Get("db-file-location")));
            var gamesPersistence = new JsonFileKeyValueStore(new FileInfo(configuration.Get("games-db-location")));

            var slackApi = new SlackApi(configuration.Get("slack-api-key"));

            var slackRtm = await(ReconnectingSlackRealTimeMessaging.CreateAsync(
                                     async() => await slackApi.StartRtm()));
            var aliasList = GetAliasList(slackRtm.InstanceInfo.Users);

            var commandParser = new SlackCommandParser("scbot", slackRtm.InstanceInfo.BotId);

            var webClient = new WebClient();

            var features = new FeatureMessageProcessor(commandParser,
                                                       NoteProcessor.Create(commandParser, persistence),
                                                       //ZendeskTicketTracker.Create(commandParser, persistence, configuration),
                                                       RecordReplayTraceManagement.Create(commandParser),
                                                       SeatingPlans.Create(commandParser, webClient),
                                                       Webcams.Create(commandParser, configuration),
                                                       Silly.Create(commandParser, webClient),
                                                       Installers.Create(commandParser, webClient),
                                                       Polls.Create(commandParser),
                                                       RollBuildNumbers.Create(commandParser, configuration),
                                                       ReviewFactory.Create(commandParser, webClient, configuration),
                                                       LabelPrinting.Create(commandParser, webClient, configuration),
                                                       Jira.Create(commandParser),
                                                       CompareTeamEmails.Create(commandParser, configuration),
                                                       GamesProcessor.Create(commandParser, gamesPersistence, aliasList)
                                                       );

            var pasteBin = new HasteServerPasteBin(webClient, configuration.Get("haste-server-url"));

            var newChannelNotificationsChannel = configuration.GetWithDefault("new-channels-notification-channel", null);
            var newChannelProcessor            = GetNewChannelProcessor(newChannelNotificationsChannel);

            var bot = new Bot(
                new ErrorReportingMessageProcessor(
                    new ConcattingMessageProcessor(features),
                    pasteBin),
                newChannelProcessor);

            var handler = new SlackMessageHandler(bot, slackRtm.InstanceInfo.BotId);

            MainLoop(slackRtm, handler, slackApi, cancel);
        }