예제 #1
0
        public Task SendAsync(Destination destination, BotResponse botResponse, SkypeSender skypeSender = null)
        {
            if (_isMocked)
            {
                Console.WriteLine($"{destination.Messenger.ToString()}, {destination.ChannelId}, {destination.UserId}: {botResponse.Text}");
                Console.WriteLine("-------------------------------------------------------");
                return(Task.CompletedTask);
            }

            switch (destination.Messenger)
            {
            case Messenger.Slack:
                return(_slackClient.PostMessageAsync(destination.ChannelId, botResponse.Text));

            case Messenger.Telegram:
                return(_telegramClient != null?_telegramClient.SendTextMessageAsync(destination.ChannelId, botResponse.Text) : Task.CompletedTask);

            case Messenger.Skype:
                if (skypeSender == null)
                {
                    // todo: log warning: skypeSender is null
                    return(Task.CompletedTask);
                }
                return(Task.Run(() => skypeSender.Write(destination.ChannelId, botResponse.Text)));

            default:
                // todo: log warning: unsupported messenger
                return(Task.CompletedTask);
            }
        }
예제 #2
0
        static void DecoratorExample()
        {
            var emailSender = new EmailSender();

            emailSender.Send("*****@*****.**", "Hello world!");

            var skypeSender = new SkypeSender(emailSender)
            {
                NickName = "Jack"
            };

            skypeSender.Send("*****@*****.**", "Hello world!");

            var facebookSender = new FacebookSender(skypeSender);

            facebookSender.Send("*****@*****.**", "Hello world!");
        }
예제 #3
0
 public RepostCommandHandler(MessageSender messageSender, AppConfig appConfig, SkypeSender skypeSender)
 {
     _messageSender = messageSender;
     _skypeSender   = skypeSender;
     _appConfig     = appConfig;
 }
예제 #4
0
 public static void StartService(TestContext context)
 {
     _skype = new SkypeSender(SkypeLogin, SkypePassword);
 }