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); } }
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!"); }
public RepostCommandHandler(MessageSender messageSender, AppConfig appConfig, SkypeSender skypeSender) { _messageSender = messageSender; _skypeSender = skypeSender; _appConfig = appConfig; }
public static void StartService(TestContext context) { _skype = new SkypeSender(SkypeLogin, SkypePassword); }