Ejemplo n.º 1
0
        public static string GetTuLin(string msg, string QQNum = "NULL")
        {
            //string url = "http://www.tuling123.com/openapi/api";
            //string msg1 = "";
            //for (int i = 0; i < msg.Length; i++)
            //{
            //    msg1 += "&#x" + ((int)msg[i]).ToString("x").ToUpper() + ";";
            //}
            //string postdata = "{\"key\":\"#{key}\",\"info\":\"#{info}\",\"userid\":\"#{userid}\"}".Replace("#{key}", TuLinKey).Replace("#{info}", msg1).Replace("#{userid}", QQNum);
            //string temp = HTTP.Post(url, postdata);
            string         url    = "http://www.tuling123.com/openapi/api?key=#{key}&info=#{info}&userid=#{userid}".Replace("#{key}", TuLinKey).Replace("#{info}", msg).Replace("#{userid}", QQNum);
            string         temp   = HTTP.Get(url);
            JsonTuLinModel dat    = (JsonTuLinModel)JsonConvert.DeserializeObject(temp, typeof(JsonTuLinModel));
            string         MsgGet = "";

            if (dat.code == 100000)
            {
                if (dat.text.Equals(msg) || dat.text.Contains("听不懂"))
                {
                    return("");
                }
                MsgGet = dat.text;
                RuiRui.AIStudy(msg, MsgGet, "TuLin");
            }
            else if (dat.code == 302000)
            {
                for (int i = 0; i < dat.list.Count; i++)
                {
                    MsgGet += dat.list[i].source + ":" + dat.list[i].article + Environment.NewLine;
                }
            }
            else if (dat.code == 308000)
            {
                MsgGet = dat.list[0].name + ":" + dat.list[0].info;
            }
            else
            {
                return("");
            }
            for (int i = 0; i < RuiRui.Badwords.Length; i++)
            {
                if (MsgGet.Contains(RuiRui.Badwords[i]))
                {
                    return("");
                }
            }
            return(MsgGet);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取讨论组列表并保存
        /// </summary>
        internal static void Info_DisscussList()
        {
            string            url      = "http://s.web2.qq.com/api/get_discus_list?clientid=53999199&psessionid=#{psessionid}&vfwebqq=#{vfwebqq}&t=#{t}".Replace("#{psessionid}", psessionid).Replace("#{vfwebqq}", vfwebqq).Replace("#{t}", AID_TimeStamp());
            string            dat      = HTTP.Get(url, "http://d1.web2.qq.com/proxy.html?v=20151105001&callback=1&id=2");
            JsonDisscussModel disscuss = (JsonDisscussModel)JsonConvert.DeserializeObject(dat, typeof(JsonDisscussModel));

            for (int i = 0; i < disscuss.result.dnamelist.Count; i++)
            {
                if (!DisscussList.ContainsKey(disscuss.result.dnamelist[i].did))
                {
                    DisscussList.Add(disscuss.result.dnamelist[i].did, new DiscussInfo());
                }
                DisscussList[disscuss.result.dnamelist[i].did].name = disscuss.result.dnamelist[i].name;
                Info_DisscussInfo(disscuss.result.dnamelist[i].did);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 根据uin获取真实QQ号
        /// </summary>
        /// <param name="uin"></param>
        /// <returns></returns>
        internal static string Info_RealQQ(string uin)
        {
            if (RealQQNum.ContainsKey(uin))
            {
                return(RealQQNum[uin]);
            }

            string url  = "http://s.web2.qq.com/api/get_friend_uin2?tuin=#{uin}&type=1&vfwebqq=#{vfwebqq}&t=#{t}".Replace("#{uin}", uin).Replace("#{vfwebqq}", vfwebqq).Replace("#{t}", AID_TimeStamp());
            string dat  = HTTP.Get(url);
            string temp = dat.Split('\"')[10].Split(',')[0].Replace(":", "");

            if (temp != "" && !RealQQNum.ContainsKey(uin))
            {
                RealQQNum.Add(uin, temp);
                return(temp);
            }
            else
            {
                return("");
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 获取群列表并保存
        /// </summary>
        internal static void Info_GroupList()
        {
            string url      = "http://s.web2.qq.com/api/get_group_name_list_mask2";
            string sendData = string.Format("r={{\"vfwebqq\":\"{0}\",\"hash\":\"{1}\"}}", vfwebqq, hash);
            string dat      = HTTP.Post(url, sendData, "http://d1.web2.qq.com/proxy.html?v=20151105001&callback=1&id=2");

            JsonGroupModel group = (JsonGroupModel)JsonConvert.DeserializeObject(dat, typeof(JsonGroupModel));

            for (int i = 0; i < group.result.gnamelist.Count; i++)
            {
                if (!GroupList.ContainsKey(group.result.gnamelist[i].gid))
                {
                    GroupList.Add(group.result.gnamelist[i].gid, new GroupInfo());
                }
                GroupList[group.result.gnamelist[i].gid].name = group.result.gnamelist[i].name;
                GroupList[group.result.gnamelist[i].gid].code = group.result.gnamelist[i].code;
                Info_GroupInfo(group.result.gnamelist[i].gid);
                RuiRui.GetGroupSetting(group.result.gnamelist[i].gid);
            }
            Program.MainForm.ReNewListBoxGroup();
        }
Ejemplo n.º 5
0
        public static string GetTuLin(string msg, string QQNum = "NULL")
        {
            string         url    = "http://www.tuling123.com/openapi/api?key=#{key}&info=#{info}&userid=#{userid}".Replace("#{key}", TuLinKey).Replace("#{info}", msg).Replace("#{userid}", QQNum);
            string         temp   = HTTP.Get(url);
            JsonTuLinModel dat    = (JsonTuLinModel)JsonConvert.DeserializeObject(temp, typeof(JsonTuLinModel));
            string         MsgGet = "";

            if (dat.code == 100000)
            {
                if (dat.text.Equals(msg) || dat.text.Contains("听不懂"))
                {
                    return("");
                }
                MsgGet = dat.text;
                RuiRui.AIStudy(msg, MsgGet, "TuLin");
            }
            else if (dat.code == 302000)
            {
                for (int i = 0; i < dat.list.Count; i++)
                {
                    MsgGet += dat.list[i].source + ":" + dat.list[i].article + Environment.NewLine;
                }
            }
            else if (dat.code == 308000)
            {
                MsgGet = dat.list[0].name + ":" + dat.list[0].info;
            }
            else
            {
                return("");
            }
            for (int i = 0; i < RuiRui.Badwords.Length; i++)
            {
                if (MsgGet.Contains(RuiRui.Badwords[i]))
                {
                    return("");
                }
            }
            return(MsgGet);
        }
Ejemplo n.º 6
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.Get(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.º 7
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.Get(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.Get(url);
                for (int i = 0; i < RuiRui.Badwords.Length; i++)
                {
                    if (temp.Contains(RuiRui.Badwords[i]) || keyword.Contains(RuiRui.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.Get(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.º 8
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.Get(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.Get(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.º 9
0
 private void buttonLogIn_Click(object sender, EventArgs e)
 {
     SmartQQ.Login();
     HTTP.Get("https://ruiruiqq.hxlxz.com/infreport.php?qq=" + SmartQQ.QQNum + "&adminqq=" + RuiRui.MasterQQ);
 }
Ejemplo n.º 10
0
        /// <summary>
        /// 发送消息
        /// </summary>
        /// <param name="type">接受者类型:0,用户;1,群;2,讨论组</param>
        /// <param name="id">用户:uid;群:qid;讨论组:did</param>
        /// <param name="messageToSend">要发送的消息</param>
        /// <returns></returns>
        internal static bool Message_Send(int type, string id, string messageToSend, bool auto = true)
        {
            if (auto)
            {
                if (type == 0)
                {
                    Program.MainForm.AddAndReNewTextBoxFriendChat(id, ("自动回复:" + Environment.NewLine + messageToSend));
                }
                else if (type == 1)
                {
                    Program.MainForm.AddAndReNewTextBoxGroupChat(id, ("自动回复:" + Environment.NewLine + messageToSend));
                }
                else if (type == 2)
                {
                    Program.MainForm.AddAndReNewTextBoxDiscussChat(id, ("自动回复:" + Environment.NewLine + messageToSend));
                }
            }
            Program.MainForm.listBoxLog.Items.Add(type + ":" + id + ":" + messageToSend);
            if (messageToSend.Equals("") || id.Equals(""))
            {
                return(false);
            }

            string[] tmp = messageToSend.Split("{}".ToCharArray());
            messageToSend = "";
            for (int i = 0; i < tmp.Length; i++)
            {
                if (!tmp[i].Trim().StartsWith("..[face") || !tmp[i].Trim().EndsWith("].."))
                {
                    messageToSend += "\\\"" + tmp[i] + "\\\",";
                }
                else
                {
                    messageToSend += tmp[i].Replace("..[face", "[\\\"face\\\",").Replace("]..", "],");
                }
            }
            messageToSend = messageToSend.Remove(messageToSend.LastIndexOf(','));
            messageToSend = messageToSend.Replace("\r\n", "\n").Replace("\n\r", "\n").Replace("\r", "\n").Replace("\n", Environment.NewLine);
            try
            {
                string to_groupuin_did, url;
                switch (type)
                {
                case 0:
                    to_groupuin_did = "to";
                    url             = "http://d1.web2.qq.com/channel/send_buddy_msg2";
                    break;

                case 1:
                    to_groupuin_did = "group_uin";
                    url             = "http://d1.web2.qq.com/channel/send_qun_msg2";
                    break;

                case 2:
                    to_groupuin_did = "did";
                    url             = "http://d1.web2.qq.com/channel/send_discu_msg2";
                    break;

                default:
                    return(false);
                }
                string postData = "{\"#{type}\":#{id},\"content\":\"[#{msg},[\\\"font\\\",{\\\"name\\\":\\\"宋体\\\",\\\"size\\\":10,\\\"style\\\":[0,0,0],\\\"color\\\":\\\"000000\\\"}]]\",\"face\":#{face},\"clientid\":53999199,\"msg_id\":#{msg_id},\"psessionid\":\"#{psessionid}\"}";
                postData = "r=" + HttpUtility.UrlEncode(postData.Replace("#{type}", to_groupuin_did).Replace("#{id}", id).Replace("#{msg}", messageToSend).Replace("#{face}", SelfInfo.face.ToString()).Replace("#{msg_id}", rand.Next(10000000, 99999999).ToString()).Replace("#{psessionid}", psessionid));

                string dat = HTTP.Post(url, postData, "http://d1.web2.qq.com/proxy.html?v=20151105001&callback=1&id=2");

                return(dat.Equals("{\"errCode\":0,\"msg\":\"send ok\"}"));
            }
            catch (Exception)
            {
                return(false);
            }
        }