Ejemplo n.º 1
0
        internal static string GetCityInfo(string city, string target)
        {
            if ((!city.Equals("呼市郊区")) && (!city.Equals("津市")) && (!city.Equals("沙市")))
            {
                city = city.Replace("省", "");
                city = city.Replace("市", "");
            }
            city = city.Replace(" ", "");
            city = city.Replace("\r", "");
            city = city.Replace("\n", "");

            target = target.Replace(" ", "");
            target = target.Replace("\r", "");
            target = target.Replace("\n", "");
            string ans = "";

            string url  = "https://ruiruiqq.hxlxz.com/weather.php?city=" + city + "&type=forecast";
            string temp = HTTP.HttpGet(url);

            if (temp.Equals("NoCity"))
            {
                return("未查询到指定城市 " + city + " 的信息");
            }

            JsonWeatherModel weather = (JsonWeatherModel)JsonConvert.DeserializeObject(temp, typeof(JsonWeatherModel));

            ans  = "城市 " + weather.c.c3 + "(" + weather.c.c2 + ") 的信息如下:" + Environment.NewLine;
            ans += "所在省市:" + weather.c.c7 + "省" + weather.c.c5 + "市" + "(" + weather.c.c6 + " " + weather.c.c4 + ")" + Environment.NewLine;
            ans += "区号:" + weather.c.c11 + ",邮编:" + weather.c.c12 + "。城市级别:" + weather.c.c10 + "级城市" + Environment.NewLine;
            ans += "经度:" + weather.c.c13 + ",纬度:" + weather.c.c14 + ",海拔:" + weather.c.c15 + "。雷达站" + weather.c.c16;
            return(ans);
        }
Ejemplo n.º 2
0
        public static string GetRealQQ(string uin)
        {
            for (int i = 0; i < realQQIndex; i++)
            {
                if (realQQ[i, 0] == uin && (!realQQ[i, 1].Equals("")))
                {
                    return(realQQ[i, 1]);
                }
            }
            string url = "http://s.web2.qq.com/api/get_friend_uin2?tuin=" + uin + "&type=1&vfwebqq=" + vfwebqq + "&t=" + GetTimeStamp();

            string dat = HTTP.HttpGet(url);

            if (dat == "{\"retcode\":100101}")
            {
                return(GetRealQQ(uin));
            }
            dat = dat.Replace("{\"retcode\":0,\"result\":{\"uiuin\":\"\",\"account\":", "");
            dat = dat.Replace("}", "");
            dat = dat.Replace("\"uin\":", "");
            dat = dat.Replace("\r", "");
            dat = dat.Replace("\n", "");
            string[] tmp = dat.Split(',');

            realQQ[realQQIndex, 0] = uin;
            realQQ[realQQIndex, 1] = tmp[0];
            realQQIndex++;
            return(tmp[0]);
        }
Ejemplo n.º 3
0
        public static string GetExchangeRate(string p1, string p2)
        {
            string url = "https://query.yahooapis.com/v1/public/yql?q=select%20id,Rate%20from%20yahoo.finance.xchange%20where%20pair%20in%20%28%22";

            url += p1 + p2 + "%22%29&env=store://datatables.org/alltableswithkeys&format=json";
            string temp = HTTP.HttpGet(url, 100000, null, "");
            JsonYahooExchangeRateModel ExchangeRateYahoo = (JsonYahooExchangeRateModel)JsonConvert.DeserializeObject(temp, typeof(JsonYahooExchangeRateModel));

            if (!ExchangeRateYahoo.query.results.rate.Rate.Equals("N/A"))
            {
                return("根据Yahoo!的信息," + ExchangeRateYahoo.query.results.rate.id + "在UTC" + ExchangeRateYahoo.query.created + "的汇率是:" + ExchangeRateYahoo.query.results.rate.Rate + "。");
            }
            url  = "https://www.cryptonator.com/api/ticker/" + p1 + "-" + p2;
            temp = HTTP.HttpGet(url);
            JsonExchangeRateModel ExchangeRate = (JsonExchangeRateModel)JsonConvert.DeserializeObject(temp, typeof(JsonExchangeRateModel));

            if (ExchangeRate.success == true)
            {
                return("根据cryptonator的信息," + p1 + "-" + p2 + "的汇率:" + ExchangeRate.ticker.price);
            }
            else
            {
                return("Error:" + ExchangeRate.error);
            }
        }
Ejemplo n.º 4
0
        public static string CheckStatu()
        {
            string url  = "https://ssl.ptlogin2.qq.com/ptqrlogin?webqq_type=10&remember_uin=1&login2qq=1&aid=501004106&u1=http%3A%2F%2Fw.qq.com%2Fproxy.html%3Flogin2qq%3D1%26webqq_type%3D10&ptredirect=0&ptlang=2052&daid=164&from_ui=1&pttype=1&dumy=&fp=loginerroralert&action=0-0-18099&mibao_css=m_webqq&t=1&g=1&js_type=0&js_ver=10135&login_sig=&pt_randsalt=0";
            string temp = HTTP.HttpGet(url);

            string[] tmp = temp.Split('\'');
            return(tmp[1] + tmp[5]);
        }
Ejemplo n.º 5
0
        public static void GetVfwebqq()
        {
            string url  = "http://s.web2.qq.com/api/getvfwebqq?ptwebqq=" + ptwebqq + "&clientid=53999199&psessionid=&t=" + GetTimeStamp();
            string temp = HTTP.HttpGet(url);

            string[] tmp = temp.Split('\"');
            vfwebqq = tmp [7];
        }
Ejemplo n.º 6
0
        public static string GetGroupSig(string id, string uin, string service_type)
        {
            string url  = "http://d1.web2.qq.com/channel/get_c2cmsg_sig2?id=" + id + "&to_uin=" + uin + "&clientid=" + ClientID + "&psessionid=" + psessionid + "&service_type=" + service_type + "&t=" + GetTimeStamp();
            string temp = HTTP.HttpGet(url);

            string[] tmp = temp.Split('\"');
            return(tmp[9]);
        }
Ejemplo n.º 7
0
        public static JsonFriendInfModel GetFriendInf(string uin)
        {
            string url = "http://s.web2.qq.com/api/get_friend_info2?tuin=" + uin + "&vfwebqq=" + vfwebqq + "&clientid=" + ClientID + "&psessionid=" + psessionid + "&t=" + GetTimeStamp();

            string             dat = HTTP.HttpGet(url);
            JsonFriendInfModel ans = (JsonFriendInfModel)JsonConvert.DeserializeObject(dat, typeof(JsonFriendInfModel));

            return(ans);
        }
Ejemplo n.º 8
0
        public static JsonGroupInfoModel GetGroupInfo(string gcode)
        {
            string url = "http://s.web2.qq.com/api/get_group_info_ext2?gcode=" + gcode + "&vfwebqq=" + vfwebqq + "&t=" + GetTimeStamp();
            string dat = HTTP.HttpGet(url);

            JsonGroupInfoModel ans = (JsonGroupInfoModel)JsonConvert.DeserializeObject(dat, typeof(JsonGroupInfoModel));

            return(ans);
        }
Ejemplo n.º 9
0
        public static void GetDissInfo(string did, int index)
        {
            string            url  = "http://d1.web2.qq.com/channel/get_discu_info?did=" + did + "&vfwebqq=" + vfwebqq + "&clientid=" + ClientID + "&psessionid=" + psessionid + "&t=" + GetTimeStamp();
            string            temp = HTTP.HttpGet(url);
            JsonDissgussModel inf  = (JsonDissgussModel)JsonConvert.DeserializeObject(temp, typeof(JsonDissgussModel));

            Program.formlogin.discussInfo[index].did    = inf.result.info.did;
            Program.formlogin.discussInfo[index].dname  = inf.result.info.discu_name;
            Program.formlogin.discussInfo[index].downer = inf.result.info.discu_owner;
            Program.formlogin.discussInfo[index].inf    = inf;
        }
Ejemplo n.º 10
0
        public static string GetWeather(string city, string target)
        {
            if ((!city.Equals("呼市郊区")) && (!city.Equals("津市")) && (!city.Equals("沙市")))
            {
                city = city.Replace("省", "");
                city = city.Replace("市", "");
            }
            city = city.Replace(" ", "");
            city = city.Replace("\r", "");
            city = city.Replace("\n", "");

            target = target.Replace(" ", "");
            target = target.Replace("\r", "");
            target = target.Replace("\n", "");
            string ans = "";
            string url, temp;

            if (target.Equals("雅虎"))
            {
                url  = "https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20%28select%20woeid%20from%20geo.places%281%29%20where%20text=\"" + city + "\") and%20u=%22c%22&format=json";
                temp = HTTP.HttpGet(url);
                JsonYahooWeatherModel weather = (JsonYahooWeatherModel)JsonConvert.DeserializeObject(temp, typeof(JsonYahooWeatherModel));
                if (weather.query.results == null)
                {
                    return("未查询到指定城市 " + city + " 的天气信息");
                }
                else
                {
                    ans = weather.query.results.channel.description + "(请核对城市名是否正确)";
                    for (int i = 0; i < weather.query.results.channel.item.forecast.Count; i++)
                    {
                        ans = ans + Environment.NewLine + "周" + getYahooWeak(weather.query.results.channel.item.forecast[i].day) + ":" + getYahooWeatherCode(weather.query.results.channel.item.forecast[i].code) + ",最高气温:" + weather.query.results.channel.item.forecast[i].high + "摄氏度,最低气温:" + weather.query.results.channel.item.forecast[i].low + "摄氏度";
                    }
                    return(ans);
                }
            }
            if (target.Equals("指数"))
            {
                target = "index";
            }
            else
            {
                target = "forecast";
            }
            url  = "https://ruiruiqq.hxlxz.com/weather.php?city=" + city + "&type=" + target;
            temp = HTTP.HttpGet(url);
            if (temp.Equals("NoCity"))
            {
                return(GetWeather(city, "雅虎"));
            }

            if (target.Equals("forecast"))
            {
                JsonWeatherModel weather = (JsonWeatherModel)JsonConvert.DeserializeObject(temp, typeof(JsonWeatherModel));
                ans = "根据中国天气网于" + weather.f.f0 + "发布的气象预报," + weather.c.c3 + "的气象信息如下:" + Environment.NewLine;
                if (weather.f.f1[0].fa != null && !weather.f.f1[0].fa.Equals(""))
                {
                    ans = ans + "今天白天:" + SloveWeather(weather.f.f1[0].fa) + "," + weather.f.f1[0].fc + "摄氏度," + SloveWind(weather.f.f1[0].fe) + SloveWindPower(weather.f.f1[0].fg) + "。";
                }
                else
                {
                    ans = ans + "今天";
                }
                ans = ans + "晚上:" + SloveWeather(weather.f.f1[0].fb) + "," + weather.f.f1[0].fd + "摄氏度," + SloveWind(weather.f.f1[0].ff) + SloveWindPower(weather.f.f1[0].fh) + "。日出日落时间:" + weather.f.f1[0].fi + Environment.NewLine;
                ans = ans + "明天白天:" + SloveWeather(weather.f.f1[1].fa) + "," + weather.f.f1[1].fc + "摄氏度," + SloveWind(weather.f.f1[1].fe) + SloveWindPower(weather.f.f1[1].fg) + "。";
                ans = ans + "晚上:" + SloveWeather(weather.f.f1[1].fb) + "," + weather.f.f1[1].fd + "摄氏度," + SloveWind(weather.f.f1[1].ff) + SloveWindPower(weather.f.f1[1].fh) + "。日出日落时间:" + weather.f.f1[1].fi + Environment.NewLine;
                ans = ans + "后天白天:" + SloveWeather(weather.f.f1[2].fa) + "," + weather.f.f1[2].fc + "摄氏度," + SloveWind(weather.f.f1[2].fe) + SloveWindPower(weather.f.f1[2].fg) + "。";
                ans = ans + "晚上:" + SloveWeather(weather.f.f1[2].fb) + "," + weather.f.f1[2].fd + "摄氏度," + SloveWind(weather.f.f1[2].ff) + SloveWindPower(weather.f.f1[2].fh) + "。日出日落时间:" + weather.f.f1[2].fi;
            }
            else if (target.Equals("index"))
            {
                JsonWeatherIndexModel WeatherIndex = (JsonWeatherIndexModel)JsonConvert.DeserializeObject(temp, typeof(JsonWeatherIndexModel));
                ans = "根据中国天气网发布的气象预报," + city + "的气象信息如下:" + Environment.NewLine;
                ans = ans + WeatherIndex.i[0].i2 + ":" + WeatherIndex.i[0].i4 + ";" + WeatherIndex.i[0].i5 + Environment.NewLine;
                ans = ans + WeatherIndex.i[1].i2 + ":" + WeatherIndex.i[1].i4 + ";" + WeatherIndex.i[1].i5 + Environment.NewLine;
                ans = ans + WeatherIndex.i[2].i2 + ":" + WeatherIndex.i[2].i4 + ";" + WeatherIndex.i[2].i5;
            }
            return(ans);
        }
Ejemplo n.º 11
0
        public static string GetStock(string p1, string p2 = "")
        {
            string url = "";

            p1 = p1.Replace(" ", "");
            p1 = p1.Replace("\r", "");
            p1 = p1.Replace("\n", "");
            if (!p2.Equals(""))
            {
                p2 = p2.Replace(" ", "");
                p2 = p2.Replace("\r", "");
                p2 = p2.Replace("\n", "");
            }
            switch (p1)
            {
            case ("上证指数"): url = "http://hq.sinajs.cn/list=s_sh000001"; break;

            case ("深证综指"): url = "http://hq.sinajs.cn/list=s_sz399106"; break;

            case ("中小板指数"): url = "http://hq.sinajs.cn/list=s_sz399005"; break;

            case ("创业板指数"): url = "http://hq.sinajs.cn/list=s_sz399006"; break;

            case ("深证成指"): url = "http://hq.sinajs.cn/list=s_sz399001"; break;

            case ("中小板综指"): url = "http://hq.sinajs.cn/list=s_sz399101"; break;

            case ("创业板综指"): url = "http://hq.sinajs.cn/list=s_sz399102"; break;

            default:
            {
                if (p1.ToCharArray()[0] == '6')
                {
                    url = "http://hq.sinajs.cn/list=s_sh" + p1;
                }
                else if (p1.ToCharArray()[0] == '0' || p1.ToCharArray()[0] == '3')
                {
                    url = "http://hq.sinajs.cn/list=s_sz" + p1;
                }
                else if (p1.Equals("上海") || p1.Equals("沪市") || p1.Equals("上证"))
                {
                    url = "http://hq.sinajs.cn/list=s_sh" + p2;
                }
                else if (p1.Equals("深圳") || p1.Equals("深市") || p1.Equals("深证") || p1.Equals("创业板") || p1.Equals("中小板"))
                {
                    url = "http://hq.sinajs.cn/list=s_sz" + p2;
                }
                else
                {
                    return("参数错误");
                }
                break;
            }
            }
            string dat = HTTP.HttpGet(url, 100000, Encoding.GetEncoding("GB2312"));

            string[] tmp = dat.Split('\"');
            tmp = tmp[1].Split(',');
            if (tmp.Length == 1)
            {
                return("参数错误");
            }
            string ans = "根据新浪财经的信息," + tmp[0] + ":现价," + tmp[1] + ";涨跌" + tmp[2] + "," + tmp[3] + "%;成交量," + tmp[4] + "手," + tmp[5] + "万元。";

            return(ans);
        }
Ejemplo n.º 12
0
        public static string GetWiki(string keyword, string aim = "")
        {
            if (aim.Equals("互动百科") || aim.Equals("互动"))
            {
                string url  = "http://www.baike.com/wiki/" + keyword;
                string temp = HTTP.HttpGet(url);
                if (temp.Contains("尚未收录"))
                {
                    return("没有找到这个词条哦~");
                }
                temp = temp.Replace("<meta content=\"", "&");
                temp = temp.Replace("\" name=\"description\">", "&");
                string[] tmp = temp.Split('&');
                if (!tmp[1].Equals(""))
                {
                    return(tmp[1] + Environment.NewLine + "详情请查看http://www.baike.com/wiki/" + HttpUtility.UrlEncode(keyword));
                }
                else
                {
                    return("");
                }
            }
            else if (aim.Equals("维基百科") || aim.Equals("维基"))
            {
                string url  = "https://zh.wikipedia.org/w/api.php?action=query&prop=extracts&format=json&exsentences=2&exintro=&explaintext=&exsectionformat=plain&exvariant=zh&titles=" + keyword;
                string temp = HTTP.HttpGet(url);
                for (int i = 0; i < Program.formlogin.Badwords.Length; i++)
                {
                    if (temp.Contains(Program.formlogin.Badwords[i]) || keyword.Contains(Program.formlogin.Badwords[i]))
                    {
                        return("这个Wiki被河蟹吃掉了 QAQ");
                    }
                }
                JsonWikipediaModel     temp1 = (JsonWikipediaModel)JsonConvert.DeserializeObject(temp, typeof(JsonWikipediaModel));
                string[]               tmp   = temp1.query.pages.ToString().Split("{}".ToCharArray());
                JsonWikipediaPageModel pages = (JsonWikipediaPageModel)JsonConvert.DeserializeObject("{" + tmp[2] + "}", typeof(JsonWikipediaPageModel));

                if (pages.extract != null)
                {
                    return(pages.extract + Environment.NewLine + "详情请查看https://zh.wikipedia.org/wiki/" + HttpUtility.UrlEncode(keyword));
                }
                else
                {
                    return("没有找到这个Wiki哦~");
                }
            }
            else if (aim.Equals("百度百科") || aim.Equals("百度"))
            {
                string url  = "http://wapbaike.baidu.com/item/" + keyword;
                string temp = HTTP.HttpGet(url);

                if (temp.Contains("您所访问的页面不存在"))
                {
                    return("没有找到这个词条哦~");
                }
                if (temp.Contains("百科名片"))
                {
                    temp = temp.Replace("&quot;", "");
                    temp = temp.Replace("&", "");
                    temp = temp.Replace("百科名片", "&");
                    string[] tmp = temp.Split('&');

                    temp = tmp[1];
                    temp = temp.Replace("<p>", "&");
                    temp = temp.Replace("</p>", "&");
                    tmp  = temp.Split('&');

                    temp = tmp[1].Replace("</a>", "");
                    temp = temp.Replace("<b>", "");
                    temp = temp.Replace("</b>", "");
                    temp = temp.Replace("<i>", "");
                    temp = temp.Replace("</i>", "");

                    temp = temp.Replace("<a", "&");
                    temp = temp.Replace("\">", "&");
                    tmp  = temp.Split('&');

                    temp = "";
                    for (int i = 0; i < tmp.Length; i += 2)
                    {
                        if ((!tmp[i].Contains("card-info")) && (!tmp[i].Contains("div class")))
                        {
                            temp += tmp[i];
                        }
                    }
                    if (!temp.Equals(""))
                    {
                        return(temp + Environment.NewLine + "详情请查看http://wapbaike.baidu.com/item/" + HttpUtility.UrlEncode(keyword));
                    }
                    else
                    {
                        return("词条 " + keyword + " 请查看http://wapbaike.baidu.com/item/" + HttpUtility.UrlEncode(keyword));
                    }
                }
                else
                {
                    return("没有找到这个词条哦~");
                }
            }
            else
            {
                string temp1 = GetWiki(keyword, "百度");
                if (temp1.Contains("查看"))
                {
                    return(temp1 + " --百度百科");
                }

                temp1 = GetWiki(keyword, "互动");
                if (temp1.Contains("查看"))
                {
                    return(temp1 + " --互动百科");
                }

                temp1 = GetWiki(keyword, "维基");
                if (temp1.Contains("查看"))
                {
                    return(temp1 + " --维基百科");
                }

                else
                {
                    return("没有找到这个词条哦~");
                }
            }
        }
Ejemplo n.º 13
0
        public static string GetTranslate(string str)
        {
            string lang    = "";
            int    strLen  = str.Length;
            int    bytLeng = System.Text.Encoding.UTF8.GetBytes(str).Length;

            if (strLen < bytLeng)
            {
                lang = "en";
            }
            if (lang.Equals(""))
            {
                lang = "zh-CN";
            }

            string messagetosend = "原文:" + str;

            string url = "https://translate.google.com/translate_a/single?client=t&sl=auto&tl=";

            url = url + lang + "&hl=zh-CN&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&dt=at&ie=UTF-8&oe=UTF-8&ssel=3&tsel=3&kc=0&tk=346111|219373&q=" + str;
            string temp = HTTP.HttpGet(url, 2000, Encoding.UTF8, "");

            string[] tmp = temp.Split('\"');
            if (tmp.Length != 0 && tmp[1] != null)
            {
                messagetosend = messagetosend + Environment.NewLine + "谷歌翻译:" + tmp[1];
            }
            else
            {
                messagetosend = messagetosend + Environment.NewLine + "谷歌翻译:异常";
            }

            url  = " http://fanyi.youdao.com/openapi.do?keyfrom=" + Program.formlogin.YoudaoKeyform + "&key=" + Program.formlogin.YoudaoKey + "&type=data&doctype=json&version=1.1&q=" + str;
            temp = HTTP.HttpGet(url);
            JsonYoudaoTranslateModel dat = (JsonYoudaoTranslateModel)JsonConvert.DeserializeObject(temp, typeof(JsonYoudaoTranslateModel));

            if (dat.errorcode == 0)
            {
                if (dat.translation[0] != null)
                {
                    messagetosend = messagetosend + Environment.NewLine + "有道翻译:" + dat.translation[0];
                }
                else
                {
                    messagetosend = messagetosend + Environment.NewLine + "有道翻译:异常";
                }
            }
            else if (dat.errorcode == 20)
            {
                messagetosend = messagetosend + Environment.NewLine + "有道翻译:不支持或文本过长";
            }
            else if (dat.errorcode == 50)
            {
                messagetosend = messagetosend + Environment.NewLine + "有道翻译:有道API密钥错误";
            }

            for (int i = 0; i < Program.formlogin.Badwords.Length; i++)
            {
                if (messagetosend.Contains(Program.formlogin.Badwords[i]))
                {
                    messagetosend = messagetosend.Replace(Program.formlogin.Badwords[i], "***");
                }
            }
            return(messagetosend);
        }