Beispiel #1
0
 public void setgourpmembers(string value)
 {
     if (!isset)
     {
         Regex  mininfo   = new Regex("(\"minfo\":\\[)(?<members>.+?)(\\],)");
         string temp      = mininfo.Match(value).Groups["members"].Value;
         Regex  minmember = new Regex("({\"uin\":)(?<uin>.+?)(,\"nick\":)(?<nick>.+?)(\"})");
         foreach (Match item in minmember.Matches(temp))
         {
             Friend f = new Friend();
             f.uin  = item.Groups["uin"].Value;
             f.name = Converts.ConvertUnicodeStringToChinese(item.Groups["nick"].Value.Substring(1));
             members.Add(f.uin, f);
         }
         Regex membercard = new Regex("(\"cards\":\\[)(?<members>.+?)(\\]}})");
         temp = membercard.Match(value).Groups["members"].Value;
         Regex member = new Regex("({\"muin\":)(?<muin>.+?)(,\"card\":\")(?<card>.+?)(\"})");
         foreach (Match item in member.Matches(temp))
         {
             members[item.Groups["muin"].Value].card = Converts.ConvertUnicodeStringToChinese(item.Groups["card"].Value);
         }
         Regex status = new Regex("(\"stats\":\\[)(?<stats>.+?)(\\],)");
         temp = status.Match(value).Groups["stats"].Value;
         Regex memberstatus = new Regex("({\"uin\":)(?<uin>.+?)(,\"stat\":)(?<stat>.+?)(})");
         foreach (Match item in memberstatus.Matches(temp))
         {
             members[item.Groups["uin"].Value].stat = item.Groups["stat"].Value;
         }
         isset = true;
     }
 }
Beispiel #2
0
        public void setmyinfo(string uin, string value)
        {
            Regex nick = new Regex("(nick\":)(?<nick>.+?)(\",\")");
            Regex face = new Regex("(face\":)(?<face>.+?)(,\")");

            myself.uin  = uin;
            myself.name = Converts.ConvertUnicodeStringToChinese(nick.Match(value).Groups["nick"].Value.Substring(1));
            myself.face = Convert.ToInt32(face.Match(value).Groups["face"].Value);
        }
Beispiel #3
0
        public string sendmessage(string text, string touin)
        {
            string result;

            text = Converts.StrConvUrlEncoding(text, "UTF-8");
            string postdate = String.Format("r=%7B%22to%22%3A{0}%2C%22face%22%3A0%2C%22content%22%3A%22%5B%5C%22{1}%5C%22%2C%5B%5C%22font%5C%22%2C%7B%5C%22name%5C%22%3A%5C%22Arial%5C%22%2C%5C%22size%5C%22%3A%5C%2210%5C%22%2C%5C%22style%5C%22%3A%5B0%2C0%2C0%5D%2C%5C%22color%5C%22%3A%5C%22000000%5C%22%7D%5D%5D%22%2C%22msg_id%22%3A{2}%2C%22clientid%22%3A%22{3}%22%2C%22psessionid%22%3A%22{4}%22%7D", touin, text, messagecount++, cliendid, psessionid);

            result = HttpHelper.GetHtml("http://d.web2.qq.com/channel/send_msg2", postdate, true, cc);
            return(result);
        }
Beispiel #4
0
        public string sendgroupmessage(string text, string touin)
        {
            string result;

            text = Converts.StrConvUrlEncoding(text, "UTF-8");
            string groupuin = Main.thefriendlist.QQGroups[touin].gid;
            string postdate = String.Format("r=%7B%22group_uin%22%3A{0}%2C%22content%22%3A%22%5B%5C%22{1}%5C%22%2C%5B%5C%22font%5C%22%2C%7B%5C%22name%5C%22%3A%5C%22%E5%AE%8B%E4%BD%93%5C%22%2C%5C%22size%5C%22%3A%5C%2210%5C%22%2C%5C%22style%5C%22%3A%5B0%2C0%2C0%5D%2C%5C%22color%5C%22%3A%5C%22000000%5C%22%7D%5D%5D%22%2C%22msg_id%22%3A{2}%2C%22clientid%22%3A%22{3}%22%2C%22psessionid%22%3A%22{4}%22%7D", groupuin, text, messagecount++, cliendid, psessionid);

            result = HttpHelper.GetHtml("http://d.web2.qq.com/channel/send_group_msg2", postdate, true, cc);
            return(result);
        }
Beispiel #5
0
        public static Dictionary <string, QQGroup> GetGroupList(string result)
        {
            Dictionary <string, QQGroup> QQGroups = new Dictionary <string, QQGroup>();
            Regex qgourp = new Regex("(\"gid\":)(?<gid>[0-9]{5,11}?)(,\"code\":)(?<code>[0-9]{5,11}?)(,\"flag\":)(?<flag>[0-9]{1,11}?)(,\"name\":\")(?<name>.+?)(\"})");

            foreach (Match item in qgourp.Matches(result))
            {
                QQGroup qg = new QQGroup();
                qg.gid  = item.Groups["gid"].Value;
                qg.code = item.Groups["code"].Value;
                qg.flag = item.Groups["flag"].Value;
                qg.name = Converts.ConvertUnicodeStringToChinese(item.Groups["name"].Value);
                QQGroups.Add(qg.code, qg);
            }
            return(QQGroups);
        }
Beispiel #6
0
        public static Friendlist GetFriendsList(string result)
        {
            Friendlist TheFriendlist = new Friendlist();
            Regex      group         = new Regex("({\"index\":)(?<index>[0-9]{1,2}?)(,\"name\":\")(?<name>.+?)(\"})");
            Group      g0            = new Group();

            g0.name       = "在线";
            g0.groupindex = 0;
            TheFriendlist.Groups.Add("100", g0);
            Group g1 = new Group();

            g1.name       = "我的好友";
            g1.groupindex = 1;
            TheFriendlist.Groups.Add("0", g1);
            int i = 2;

            foreach (Match item in group.Matches(result))
            {
                Group g = new Group();
                g.name       = Converts.ConvertUnicodeStringToChinese(item.Groups["name"].Value);
                g.groupindex = i;
                TheFriendlist.Groups.Add(item.Groups["index"].Value, g);
                i++;
            }
            TheFriendlist.groupnum = i;
            Regex friend = new Regex("({\"uin\":)(?<uin>[0-9]{5,11}?)(,\"categories\":)(?<id>[0-9]{1,2}?)(})");

            foreach (Match item in friend.Matches(result))
            {
                Friend f = new Friend();
                f.uin        = item.Groups["uin"].Value;
                f.groupid    = item.Groups["id"].Value;
                f.groupindex = TheFriendlist.Groups[f.groupid].groupindex;
                TheFriendlist.Friends.Add(f.uin, f);
            }
            Regex info = new Regex("({\"uin\":)(?<uin>[0-9]{5,11}?)(,\"nick\":)(?<nick>.+?)(\",\"face\":)(?<face>.+?)(,\"flag\":)(?<flag>.+?)(})");

            foreach (Match item in info.Matches(result))
            {
                TheFriendlist.Friends[item.Groups["uin"].Value].name = Converts.ConvertUnicodeStringToChinese(item.Groups["nick"].Value.Substring(1));
                TheFriendlist.Friends[item.Groups["uin"].Value].face = Convert.ToInt32(item.Groups["face"].Value);
            }
            return(TheFriendlist);
        }
Beispiel #7
0
        public string getlongnick2(string nick)
        {
            string result;

            nick = Converts.StrConvUrlEncoding(nick, "UTF-8");
            string postdate = String.Format("r=%7B%22nlk%22%3A%22{0}%22%2C%22vfwebqq%22%3A%22{1}%22%7D", nick, vfwebqq);

            result = HttpHelper.GetHtml("http://s.web2.qq.com/api/set_long_nick2", postdate, true, cc);

            if (result.IndexOf("\"result\":0") > 0)
            {
                result = "设置签名成功!";
            }
            else
            {
                result = "设置签名失败!";
            }
            return(result);
        }
Beispiel #8
0
        /// <summary>
        /// 发消息方法
        /// </summary>
        /// <param name="value"></param>
        private void GetAMessage(string value)
        {
            var    messagecontent = new Regex("(}],)(?<content>.+?)(],\"raw_content)");
            var    messageiduin   = new Regex("(\"msg_id\":)(?<msgid>[0-9]{1,8}?)(,\"from_uin\":)(?<fromuin>[0-9]{5,11}?)(,\")");
            string tempcontent    = Converts.ConvertUnicodeStringToChinese(messagecontent.Match(value).Groups["content"].Value);
            string content        = Converts.ArrangeMessage(tempcontent);
            string fromuin        = messageiduin.Match(value).Groups["fromuin"].Value;

            string[] command = content.Split(' ');
            switch (command[0].ToLower())
            {
            case "@":
                if (YZadmin(thefriendlist.Friends[fromuin].name) == "T")
                {
                    content = string.Format("您好,我是" + thefriendlist.myself.name + "\\\\n======您可以使用如下命令======\\\\n{0}weather    天气查询(新)\\\\n=======系统管理员命令=======\\\\n{0}turn     游戏赛季更新检测  例:{0}turn BB\\\\n{0}status   游戏夜间更新检测  例:{0}status BB\\\\n{0}season   查询赛季更新详情  例:{0}season XBA\\\\n{0}check    查询夜间更新是否执行  例:{0}check BB\\\\n{0}userinfo 查询官方区用户信息\\\\n==========特殊功能==========\\\\n{0}mail  简单邮件发送\\\\n{0}setnick  设置QQ机器人签名\\\\n{0}setqqstatus  设置机器人在线状态", fenge);
                }
                else
                {
                    content = string.Format("您好,我是" + thefriendlist.myself.name + "\\\\n======您可以使用如下命令======\\\\n{0}weather    天气查询(新)", fenge);
                }
                break;

            case "@weather":
                if (command.Length == 2)
                {
                    var api = new RobotApi();
                    content = api.GetWeather(command[1], "3").Replace("\r", "\\\\n");
                }
                else
                {
                    content = "参数错误。\\\\n天气查询(新)使用方法:@weather 城市名 或(区号,拼音(支持模糊),邮编)\\\\n例:\\\\n@weather 北京(城市名)\\\\n@weather 0597(区号)\\\\n@weather beijin(拼音)\\\\n@weather 364000(邮编)";
                }
                break;

            case "@turn":    //赛季更新查询
                if (command.Length == 2)
                {
                    content = sc.GetGameTurn(command[1]).Replace("\n", "\\\\n");
                }
                else
                {
                    content = "参数错误。\\\\n赛季更新检测的使用方法:@turn 项目名称(BB,FB)\\\\n例:@turn BB";
                }
                break;

            case "@status":    //夜间更新查询
                if (command.Length == 2)
                {
                    content = sc.GetGameStatus(command[1]).Replace("\n", "\\\\n");
                }
                else
                {
                    content = "参数错误。\\\\n夜间更新检测的使用方法:@status 项目名称(BB,FB)\\\\n例:@status BB";
                }
                break;

            case "@mail":    //发送邮件
                if (command.Length == 4)
                {
                    content = sm.SendMail(command[1], command[2], command[3]);
                }
                else
                {
                    content = "参数错误。\\\\n使用方法:@mail 收件邮件 邮件主题 邮件内容\\\\n例:@mail [email protected] 开会 三点开会";
                }
                break;

            case "@season":    //赛季更新时间查询
                if (command.Length == 2)
                {
                    content = sc.GetGameSeason(command[1]).Replace("\n", "\\\\n");
                }
                else
                {
                    content = "参数错误。\\\\n赛季更新检测的使用方法:@season 关键字名称(XBA,DW,TOM)\\\\n例:@season XBA";
                }
                break;

            case "@check":    //查询夜间更新是否执行
                if (command.Length == 2)
                {
                    content = sc.GetGameCheck(command[1]).Replace("\n", "\\\\n");
                }
                else
                {
                    content = "参数错误。\\\\n查询夜间更新是否执行的使用方法:@check 项目名称(BB,FB)\\\\n例:@check BB";
                }
                break;

            case "@userinfo":    //查询用户信息
                if (command.Length == 3)
                {
                    content = si.UserInfo(command[1], command[2]).Replace("\r\n", "\\\\n");
                }
                else
                {
                    content = "参数错误。\\\\n查询用户信息的使用方法:\\\\n@userinfo 用户名类型(0为经理名|1为用户名) 经理名\\\\n例:@userinfo 0 风中脱手";
                }
                break;

            case "@setnick":    //设置机器人签名
                if (command.Length == 2)
                {
                    content = QQUser.getlongnick2(command[1]);
                }
                else
                {
                    content = "参数错误。\\\\n设置机器人签名方法:\\\\n@setnick 签名内容\\\\n例:@setnick 今天好开心啊";
                }
                break;

            case "@setqqstatus":    //设置机器人在线状态
                if (command.Length == 2)
                {
                    content = QQUser.getchangestatus(command[1]);
                }
                else
                {
                    content = "参数错误。\\\\n设置机器人在线状态方法:\\\\n@setqqstatus (在线|离开|隐身)\\\\n例:@setqqstatus 在线";
                }
                break;
            }
            string result = QQUser.sendmessage(content, fromuin);

            if (result.IndexOf("ok") == -1)
            {
                MessageBox.Show("消息 " + content + " 发送失败");
            }
            //Thread.CurrentThread.Abort();
        }