Example #1
0
 public void Search(List <MPlace> dataPlaces, BotService.BotWithDatabase bot, string name, string message)
 {
     compare = new MyStringCompare();
     if (name != nameBot)
     {
         bool flag = true;
         foreach (MPlace item in this.dataPlaces)
         {
             double cp = 0;
             foreach (Ask i in item.askList)
             {
                 cp = compare.Compare(i.Text, message);
                 if (cp > 60.0)
                 {
                     List <Models.MessageText> listMessage = new List <Models.MessageText>();
                     foreach (Answer anwser in item.answerlist)
                     {
                         listMessage.Add(new Models.MessageText {
                             name = nameBot, text = anwser.Text, photoUrl = photoBot
                         });
                         break;
                     }
                     bot.BotSendMessageText(listMessage[0]);
                     flag = !flag;
                     break;
                 }
             }
         }
         if (flag)
         {
             bot.BotSendListMessageText
             (
                 new List <Models.MessageText>
             {
                 new Models.MessageText {
                     name = nameBot, photoUrl = photoBot, text = "bot not understand!"
                 },
                 new Models.MessageText {
                     name = nameBot, photoUrl = photoBot, text = "I'm Sorry!"
                 }
             }
             );
         }
     }
     else
     {
     }
 }
Example #2
0
        public List <Answer> Reply(string message)
        {
            //message = "Biết AEON MALL Bình Dương Canary không ?";
            dataPlaces = dataPlacesService.ReturnData();
            string URL = "https://fifo-88857.firebaseio.com/messages/.json";

            BotService.BotWithDatabase bot = new BotService.BotWithDatabase(URL);
            //bot.BotSendMessageText(new Models.MessageText { name = "bot", message = message, photoUrl = photoBot });
            foreach (MPlace item in dataPlaces)
            {
                foreach (Ask i in item.askList)
                {
                    if (i.Text == message)
                    {
                        //List<Models.MessageText> listMessage = new List<Models.MessageText>();
                        //foreach (Answer anwser in item.answerlist)
                        //{
                        //    listMessage.Add(new Models.MessageText { name = "Bot", text = anwser.Text, photoUrl = photoBot });
                        //}
                        bot.BotSendMessageText(new MessageText {
                            text = item.answerlist[0].Text, name = "Bot", photoUrl = photoBot
                        });
                    }
                }
            }
            bot.BotSendListMessageText
            (
                new List <Models.MessageText>
            {
                new Models.MessageText {
                    name = nameBot, photoUrl = photoBot, text = "bot not understand!"
                },
                new Models.MessageText {
                    name = nameBot, photoUrl = photoBot, text = "I'm Sorry!"
                }
            }
            );
            return(null);
        }