Exemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            string par = textBox1.Text.Trim();

            bool boolck = checkBox1.Checked;

            Regex rg = new Regex(par);

            if (radioButton1.Checked)
            {
                string con = textBox2.Text.Trim();

                if (rg.IsMatch(con))
                {
                    MessageBox.Show("该内容可匹配:" + rg.Match(con).Value, "提示");
                }
                else
                {
                    MessageBox.Show("该内容无法匹配", "提示");
                }
            }
            else if (radioButton2.Checked)
            {
                try
                {
                    Thread th = new Thread(new ThreadStart(delegate
                    {
                        TbInfo tbinfo = new TbInfo(textBox3.Text.Trim());
                        textBox4.Clear();
                        textBox4.AppendText("匹配到的标题如下:\r\n\r\n");
                        int i = 0;
                        foreach (string item in tbinfo.Titles)
                        {
                            if (rg.IsMatch(item))
                            {
                                i++;
                                textBox4.AppendText(i + ":" + item + "\r\n\r\n");
                            }
                        }

                        button1.Enabled = true;
                    }));
                    th.IsBackground = true;
                    th.Start();
                    button1.Enabled = false;
                }
                catch (Exception ee)
                {
                    textBox4.AppendText(ee.Message + "\r\n");
                }
            }
            else
            {
                //try
                //{
                Thread th = new Thread(new ThreadStart(delegate
                {
                    try
                    {
                        //Title title = new Title(textBox5.Text.Trim());
                        string[] tidpn = textBox5.Text.Trim().Split(':');
                        int pn         = 1;
                        if (tidpn.Length == 2)
                        {
                            pn = int.Parse(tidpn[1]);
                        }
                        ClientTit title = new ClientTit(tidpn[0], pn);

                        textBox4.Clear();
                        textBox4.AppendText("匹配情况如下:\r\n\r\n");

                        string tmpcon = "";
                        for (int i = 0, leng = title.Uids.Count; i < leng; i++)
                        {
                            // tmp = "{0}-未匹配-{1}-{2}";

                            if (boolck)
                            {
                                tmpcon = title.Authors[i].Replace("昵称:", "");
                            }
                            else
                            {
                                tmpcon = title.Content[i];
                            }

                            if (par == "" || rg.IsMatch(tmpcon))
                            {
                                // tmpcon = ;

                                textBox4.AppendText(String.Format("{0}-{1}-{2}-{3}", i + 1, title.Authors[i].StartsWith("昵称:") ? title.Authors[i] + "(" + Common.String2Unicode(title.Authors[i].Replace("昵称:", "")) + ")": title.Authors[i], ck_unconetn.Checked ? title.UnContent[i] : title.Content[i], Common.UnixTimeToStr(long.Parse(title.Times[i]))) + "\r\n\r\n");
                            }

                            //else
                            //{
                            //    textBox4.AppendText((i+1) + "->->" + title.Content[i] + "\r\n\r\n");
                            //}
                        }
                        //int i = 0;
                        //foreach (string item in title.Content)
                        //{

                        //    i++;
                        //    if (rg.IsMatch(item))
                        //    {

                        //        textBox4.AppendText(i + ":" + item + "\r\n\r\n");
                        //    }
                        //    else
                        //    {
                        //        textBox4.AppendText(i + "->未匹配->" + item + "\r\n\r\n");
                        //    }

                        //}
                    }
                    catch (Exception ee)
                    {
                        textBox4.AppendText(ee.Message + "\r\n");
                    }


                    button1.Enabled = true;
                }));
                th.IsBackground = true;
                th.Start();
                button1.Enabled = false;
                //}
                //catch (Exception ee)
                //{

                //    textBox4.AppendText(ee.Message + "\r\n");
                //}
            }
        }
Exemplo n.º 2
0
Arquivo: Task.cs Projeto: luxueqi/tb
        private void Complex(string tidComplex)
        {
            //Title restit;
            ClientTit restit;
            int       maxpn = mode.pn;
            // tidComplex = "5626300517";
            List <string> templistpid = new List <string>();

            for (int j = 1; j <= maxpn; j++)
            {
                restit = new ClientTit(tidComplex, j);
                //if (tidComplex == "4564696916")
                //{
                //    int s = 0;
                //}
                //if (tidComplex=="5044882021")
                //{
                //    int ss = 0;
                //}
                Log log = new Log();
                txtCallback(Thread.CurrentThread.Name + "--" + iflagCount + "-->正在扫描:" + restit.title + "-->tid:" + tidComplex + "?pn=" + j, Color.Black);
                //Thread.Sleep(10000);
                if (restit.maxPn == 0)
                {
                    throw new Exception("获取错误tid:" + tidComplex);
                }
                //if (restit.maxPn<=maxpn)
                //{
                //    maxpn = restit.maxPn;
                //}
                //else
                //{
                //    if (j==maxpn-1)
                //    {
                //        maxpn = restit.maxPn;
                //        j = maxpn - 1;
                //    }
                //}
                if (j == 1)
                {
                    if (1 + maxpn <= restit.maxPn)
                    {
                        j = restit.maxPn - mode.pn;
                    }
                    maxpn = restit.maxPn;
                }
                //进入帖子

                for (int i = 0; i < restit.Authors.Count; i++)
                {
                    string pid = "";
                    string outpikey;
                    bool   flagB = false, imgFlag = false;
                    //bool isbool = false;
                    try
                    {
                        manua.WaitOne();


                        string tconten = restit.Content[i];

                        if (listpid.Contains(restit.Pids[i]))
                        {
                            if (Task.detilinfo)
                            {
                                txtCallback(Thread.CurrentThread.Name + "--" + iflagCount + "-->跳过扫描pid:" + restit.Pids[i] + "-->" + "作者:" + restit.Authors[i] + "-->内容:" + (tconten.Length > 27 ? tconten.Substring(0, 27) + "......" : tconten), Color.Green);
                            }
                            continue;
                        }



                        if (Task.detilinfo)
                        {
                            txtCallback(Thread.CurrentThread.Name + "--" + iflagCount + "-->正在扫描pid:" + restit.Pids[i] + "-->" + "作者:" + restit.Authors[i] + "-->内容:" + (tconten.Length > 27 ? tconten.Substring(0, 27) + "......" : tconten), Color.Black);
                        }


                        if (whiteblackMethod(ref mode.ctwhitenames, restit.Authors[i].Replace("昵称:", ""), 'w', out outpikey))
                        {
                            if (Task.detilinfo)
                            {
                                txtCallback("跳过-->白名单-" + restit.Authors[i], Color.Blue);
                            }
                            templistpid.Add(restit.Pids[i]);
                            continue;
                        }



                        //if (mode.isblack)
                        //{
                        flagB = whiteblackMethod(ref mode.ctblacknames, restit.Authors[i].Replace("昵称:", ""), 'b', out outpikey);

                        if (flagB)
                        {
                            pid      = restit.Pids[i];
                            log.type = "匹配到复杂模式黑名单:" + restit.Authors[i];
                        }


                        //}
                        // if (tconten == "") continue;
                        if (!flagB)
                        {
                            bool ctconwitebool = false;
                            if (i == 0)
                            {
                                ctconwitebool = whiteblackMethod(ref mode.ctwhitecontents, restit.title.Trim(), 'c', out outpikey) || whiteblackMethod(ref mode.ctwhitecontents, tconten, 'c', out outpikey);
                            }
                            else
                            {
                                ctconwitebool = whiteblackMethod(ref mode.ctwhitecontents, tconten, 'c', out outpikey);
                            }

                            if (ctconwitebool)
                            {
                                if (Task.detilinfo)
                                {
                                    txtCallback("跳过-->信任内容-" + outpikey, Color.Blue);
                                }
                                templistpid.Add(restit.Pids[i]); continue;
                            }



                            if (mode.istime && Common.ConTime(restit.Times[i], mode.dt) < 0)
                            {
                                templistpid.Add(restit.Pids[i]);
                                if (Task.detilinfo)
                                {
                                    txtCallback("跳过-->该回复时间为" + Common.UnixTimeToStr(long.Parse(restit.Times[i])) + ",小于设定时间" + mode.dt.ToString("yyyy-MM-dd HH:mm:ss"), Color.Blue);
                                }
                                continue;
                            }


                            string flev = restit.Level[i] == "" ? "0" : restit.Level[i];

                            if (mode.islevel && int.Parse(flev) > mode.level)
                            {
                                templistpid.Add(restit.Pids[i]);
                                if (Task.detilinfo)
                                {
                                    txtCallback("跳过-->该用户等级为" + restit.Level[i] + ",大于设定等级" + mode.level, Color.Blue);
                                }
                                continue;
                            }

                            if (mode.isimghash)
                            {
                                int    dd;
                                string imgname;
                                //string himgtt = restit.Himgs[i];
                                if (hashmethod(mode.isimghash? tconten:"", out dd, out imgname))
                                {
                                    imgFlag = true;
                                    pid     = restit.Pids[i];

                                    log.type = "匹配到图片:" + imgname + "/" + dd;
                                }
                            }
                            if (!imgFlag)
                            {
                                bool valuesFlag = false;
                                if (i == 0)
                                {
                                    valuesFlag = whiteblackMethod(ref mode.cttitlekeys, restit.title.Trim(), 't', out outpikey, restit.Uids[i]) || whiteblackMethod(ref mode.ctreplaykeys, tconten, 'r', out outpikey);
                                }
                                else
                                {
                                    valuesFlag = whiteblackMethod(ref mode.ctreplaykeys, tconten, 'r', out outpikey, restit.Uids[i]);
                                }

                                if (valuesFlag)
                                {
                                    log.type = "匹配到复杂模式:" + outpikey;
                                    pid      = restit.Pids[i];
                                }
                            }
                        }



                        if (pid != "")
                        {
                            txtCallback(log.type, Color.Red);
                            log.author = restit.Authors[i];
                            log.fid    = Common.Fid;
                            log.tbname = Common.Kw;
                            log.title  = restit.title + "--->" + tconten;
                            log.tid    = tidComplex + "&" + pid;
                            log.uid    = restit.Uids[i];
                            string nickname = restit.Authors[i].StartsWith("昵称:") ? "" : restit.Authors[i];

                            /*if (flagB)
                             * {
                             *
                             *  log.result = Common.Del(tidComplex, pid) +"-->" + Common.Block(nickname, restit.Uids[i],10, mode.reason);
                             *
                             * }
                             * else
                             * {
                             *
                             * }*/
                            // flagB = true;
                            if (!flagB && ageNumMethod(restit.Uids[i]))
                            {
                                templistpid.Add(restit.Pids[i]);
                                txtCallback(log.type + "--跳过,吧龄或发贴数不符合", Color.Red);
                                continue;
                            }
                            log.result = "未执行删除封禁";
                            bool zxbool = false;
                            if (log.type.Contains("复杂模式"))
                            {
                                if (outpikey.StartsWith("[k:1]"))
                                {
                                    templistpid.Add(restit.Pids[i]);
                                    log.result = "需要手动确认";
                                    zxbool     = true;
                                }
                                else if (outpikey.StartsWith("[k:0]"))
                                {
                                    zxbool = false;
                                }
                            }
                            if (mode.isblock && !zxbool)
                            {
                                log.result = Common.Block(nickname, restit.Uids[i], mode.blockday, mode.reason);
                            }
                            if (mode.isblackname && !zxbool)
                            {
                                log.result = log.result + "-->" + Common.Black(restit.Authors[i]);
                            }
                            if (mode.isdel && !zxbool)
                            {
                                log.result = log.result.Replace("未执行删除封禁", "");
                                if ((mode.islz && restit.Authors[i] == restit.Authors[0]) || i == 0)
                                {
                                    log.result += Common.Delete(tidComplex);
                                }
                                else
                                {
                                    log.result += Common.Del(tidComplex, pid);
                                }
                            }
                            listCallback(log);
                            txtCallback(log.result, Color.Red);


                            if ((i == 0 || (restit.Authors[i] == restit.Authors[0] && mode.islz)) && log.result.Contains("删除成功"))
                            {
                                break;                                                                                                //当删除内容为一楼时,直接跳出
                            }
                        }
                        else
                        {
                            templistpid.Add(restit.Pids[i]);
                        }
                    }
                    catch (Exception ee)
                    {
                        adddefulttid(tidComplex);
                        if (pid != "")
                        {
                            listCallback(log);
                        }
                        txtCallback("Complex()" + ee.Message, Color.Red);
                    }
                }
            }

            if (templistpid.Count != 0)
            {
                lock (object1)
                {
                    if (listpid.Count > 20000)
                    {
                        listpid.Clear();
                    }
                    listpid.AddRange(templistpid);
                }
            }


            ////////////////////////////////////////
            //if (restit.maxPn>1&&pn!=restit.maxPn)
            //{
            //    Complex(restit.maxPn);
            //}
        }