예제 #1
0
        static void FindSong(string src, Chat CurChat)
        {
            string next = FindRow(src, CurChat.Arr);

            if (next != null)
            {
                Say(next, CurChat);
                return;
            }
            else
            {
                WebClient wc   = new WebClient();
                string    goog = "http://www.google.com/search?q=" + src + " текст песни";
                goog.Replace(' ', '+');
                string s = wc.DownloadString(goog), temp;
                s = s.Substring(s.IndexOf("id=\"search\""));
                string[] urls = StringChanger.HTMLtoURLS(s);
                foreach (string url in urls)
                {
                    Console.WriteLine(url);
                    try
                    {
                        wc.Encoding = Encoding.UTF8;
                        temp        = wc.DownloadString(url);
                        if (!StringChanger.HasKirill(temp))
                        {
                            wc.Encoding = Encoding.Default;
                            temp        = wc.DownloadString(url);
                        }
                    }
                    catch (WebException e) { continue; }

                    string[] Song = StringChanger.HTMLtoText(temp);
                    CurChat.Arr = Song;
                    next        = FindRow(src, Song);
                    if (next != null)
                    {
                        Say(next, CurChat);
                        DB.SaveChat(CurChat, true);
                        return;
                    }
                }
            }

            Say(Answering("idk"), CurChat);
        }
예제 #2
0
        static void FindRhyme(string src, Chat CurChat)
        {
            src = StringChanger.ToLower(src);
            if (src.IndexOf(' ') > 0)
            {
                src = src.Substring(src.LastIndexOf(' '));
            }
            if (src.Length < 0)
            {
                return;
            }
            CurChat.index = 0;
            CurChat.Arr   = null;
            string    goog = "https://rifmus.net/rifma/" + src;
            WebClient wc   = new WebClient();

            wc.Encoding = Encoding.UTF8;
            int    x = -1;
            string s = "";

            try
            {
                s = wc.DownloadString(goog);
                x = s.IndexOf("multicolumn");
            }
            catch {}
            if (x < 0)
            {
                Say(Answering("none"), CurChat);
                return;
            }
            s           = s.Substring(x);
            x           = s.IndexOf("</div>");
            s           = s.Substring(0, x);
            CurChat.Arr = StringChanger.HTMLtoText(s);
            SayRhymes(CurChat);
        }