Example #1
0
        public List <String> getMessages(String message)
        {
            string prepared = BotHelper.prepareString(message);

            if (answers.ContainsKey(prepared))
            {
                List <string> all    = answers[prepared];
                List <string> result = new List <string>();
                //будем возвращать только максимум 30;
                int MAX_COUNT = 30;
                if (all.Count < MAX_COUNT)
                {
                    return(all);
                }
                for (int i = 0; i < MAX_COUNT; i++)
                {
                    result.Add(all[i]);
                }
                return(result);
            }
            else
            {
                return(new List <string>());
            }
        }
Example #2
0
        public void loadAction()
        {
            lines = FileParser.getAnswer();
            foreach (string s in lines)
            {
                string[] words = s.Split(new string[] { "\\" }, StringSplitOptions.RemoveEmptyEntries);
                if (words.Length != 2)
                {
                    continue;
                }
                string w1 = BotHelper.prepareString(words[0]);

                string w2 = words[1];
                if (answers.ContainsKey(w1))
                {
                    answers[w1].Add(w2);
                }
                else
                {
                    answers.Add(w1, new List <string>()
                    {
                        w2
                    });
                }
            }
        }
Example #3
0
 public List <String> getMessages(String message)
 {
     if (answers.ContainsKey(BotHelper.prepareString(message)))
     {
         return(answers[message]);
     }
     else
     {
         return(new List <string>());
     }
 }
Example #4
0
        public void loadAction()
        {
            lines = FileParser.getAnswer();
            List <string> lines2 = FileParser.getMyAnswer();

            foreach (string s in lines2)
            {
                lines.Add(s);
            }
            foreach (string s in lines)
            {
                string[] words = s.Split(new string[] { "\\" }, StringSplitOptions.RemoveEmptyEntries);
                if (words.Length != 2)
                {
                    continue;
                }
                string w1 = BotHelper.prepareString(words[0]);

                string w2 = words[1];
                addM1M2(w1, w2);
            }
        }