private Activity CreateRandomFarewell(Activity message, out Farewell farewell) { var f = Farewell.Random(); farewell = f; return(f.ToActivity(message)); }
public void TestNotResponding() { Farewell dialogUnit = new Farewell(); DialogContext context = new DialogContext(); DialogUnitTestUtils.TestNotResponding(dialogUnit, context, "Как дела?"); }
public void TestResponding() { Farewell dialogUnit = new Farewell(); DialogContext context = new DialogContext(); DialogUnitTestUtils.TestResponding(dialogUnit, context, "Пока!", "Пока!"); context.Upsert(new ClientName("Иван")); DialogUnitTestUtils.TestResponding(dialogUnit, context, "Пока!", "Пока, Иван!"); }
public static void Main() { Hello h = new Hello("stranger"); GoodBye g = new GoodBye("my friend"); Farewell f = new Farewell("you fool"); h.speak(); g.speak(); f.speak(); }
private void OnLeaveHandler(Person person) { Console.WriteLine(); Console.WriteLine($"[{person.Name} ушел домой.]"); greetAll -= person.SayHello; byeAll -= person.SayGoodbye; byeAll?.Invoke(person); }
private void OnCameHandler(Person person, ComeTimeEventArgs comeTime) { Console.WriteLine(); Console.WriteLine($"[На работу пришел {person.Name}.]"); greetAll?.Invoke(person, comeTime); greetAll += person.SayHello; byeAll += person.SayGoodbye; }
/// <summary> /// POST: api/Messages /// Receive a message from a user and reply to it /// </summary> public async Task <HttpResponseMessage> Post([FromBody] Activity activity) { if (activity.Type == ActivityTypes.Message) { ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl)); if (this.TextIsHello(activity.Text)) { var message = activity; Activity reply = message.CreateReply($"Hey Dirk, we want to whish you all the best for your upcomming challanges."); await connector.Conversations.ReplyToActivityAsync(reply); reply = message.CreateReply($"I am a wish box containing lots of messages from all your soon to be former coworkers. You can go through all wishes step by step, get random wishes or you type a name to get a specific wish. We hope you like it."); await connector.Conversations.ReplyToActivityAsync(reply); var followup = this.CreateSuccessor(activity, null); await connector.Conversations.ReplyToActivityAsync(followup); } else { Farewell f = null; Activity farewell = null; var words = activity.Text.Split(' '); foreach (var x in words) { farewell = CreateFarewell(x, activity, out f); if (farewell != null) { break; } } if (farewell == null) { farewell = this.CreateRandomFarewell(activity, out f); } await connector.Conversations.ReplyToActivityAsync(farewell); var followup = this.CreateSuccessor(activity, f); await connector.Conversations.ReplyToActivityAsync(followup); } } else { await HandleSystemMessage(activity); } var response = Request.CreateResponse(HttpStatusCode.OK); return(response); }
public void TestInitiating() { Farewell dialogUnit = new Farewell(); DialogContext context = new DialogContext(); DialogUnitTestUtils.TestInitiating(dialogUnit, context, "Пока!", "До свидания!"); context.Upsert(new ClientName("Иван")); DialogUnitTestUtils.TestInitiating(dialogUnit, context, "Пока, Иван!", "пока"); context.Upsert(new ClientName(null)); DialogUnitTestUtils.TestInitiating(dialogUnit, context, "Пока!", "пока!"); }
private Activity CreateFarewell(String name, Activity message, out Farewell farewell) { Farewell.ClearCache(); var f = Farewell.All.FirstOrDefault(x => x.Name.ToLower().Contains(name.ToLower())); if (f == null) { farewell = null; return(null); } farewell = f; return(f.ToActivity(message)); }
public static void Main() { Console.WriteLine("Enter your name, please"); string name = Console.ReadLine(); Greeting welcoming = new Greeting(); welcoming.GreetingMethod(name); Console.WriteLine("This is Main Program string."); Farewell bye = new Farewell(); bye.FarewellMethod(); Console.ReadKey(); }
private Activity CreateSuccessor(Activity activity, Farewell f) { var card = activity.CreateReply(); List <CardAction> cardButtons = new List <CardAction>(); if (f != null) { CardAction nextButton = new CardAction() { Value = f.Next().Name, Type = "imBack", Title = String.Format("Next: {0}", f.Next().Name) }; cardButtons.Add(nextButton); } CardAction randomButton = new CardAction() { Value = "Random", Type = "imBack", Title = "Random" }; cardButtons.Add(randomButton); var buttonCard = new HeroCard(); buttonCard.Text = f != null ? "Next, random or type a name." : "Random or type a name."; buttonCard.Buttons = cardButtons; var cardAttachment = buttonCard.ToAttachment(); card.Attachments = new List <Microsoft.Bot.Connector.Attachment>() { cardAttachment }; return(card); }