예제 #1
0
        private void AddAnaliticsPharase(TelegramBotClient botClient, Message _message, Settings settings)
        {
            DataBase db      = Singleton.GetInstance().Context;
            Channel  channel = db.GetChannel(_message);

            String clean = "";

            String analiticsText = "";

            foreach (System.String word in _message.Text.Split(" "))
            {
                clean += word.Trim(new System.Char[] { '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '-', '_', '=', '+', '|', '\\', ']', '}', '[', '{', '\'', '\"', ';', ':', '/', '?', '.', '>', '<', ',', ' ' }) + " ";
            }
            AnaliticsPhraseAllChat[] analiticsPhraseAllChats = db.GetAnaliticsPhraseAllChats();
            if (analiticsPhraseAllChats.Length != 0)
            {
                if (_message.Chat.Type == Telegram.Bot.Types.Enums.ChatType.Private)
                {
                    foreach (AnaliticsPhraseAllChat text in analiticsPhraseAllChats)
                    {
                        if (CalculateFuzzyEqualValue(clean.ToLower(), text.NameId, settings) >= settings.ProcentMessage)
                        {
                            AnaliticsPhrase[]            analyticsText = db.GetAnaliticsPharse(text.NameId);
                            IQueryable <AnaliticsPhrase> temp          = analyticsText.OrderByDescending(p => p.Count).AsQueryable();
                            foreach (AnaliticsPhrase item in temp)
                            {
                                analiticsText += "\nГруппа: " + item.channel.ChannelName + ";\nФраза: " + text.NameId + ";\nКоличество использования: " + item.Count + "\n";
                            }
                            break;
                        }
                    }
                }
            }

            if (analiticsText.Length != 0)
            {
                analitics += analiticsText;
            }
            else
            {
                analitics += "\nПо Вашему запросу нет совподений.";
            }
            SendMessage(botClient, _message);
        }