示例#1
0
        private void MessageSorter(byte[] buffer, int start, int length, Socket clientSocket)
        {
            string            content  = Encoding.Default.GetString(buffer, 0, length);
            MessageDictionary messageD = new MessageDictionary(content);

            ShowMessage("从" + clientSocket.RemoteEndPoint.ToString() + "接收消息:" + content + "\n");
            CommandType command = (CommandType)Enum.Parse(typeof(CommandType), messageD[MesKeyStr.CommandType]);

            switch (command)
            {
            case CommandType.Login:
            {
                LoginEvent?.Invoke(this, new LoginEventArgs()
                    {
                        UserID        = messageD[MesKeyStr.UserID],
                        PassWord      = messageD[MesKeyStr.PassWord],
                        ReceiveSocket = clientSocket
                    });

                break;
            }

            case CommandType.Logout:
            {
                LogoutEvent?.Invoke(this, new User(messageD[MesKeyStr.UserID], messageD[MesKeyStr.NickName]));
                break;
            }

            case CommandType.SignUp:
            {
                SignUpEvent?.Invoke(this, new SignUpEventArgs(clientSocket, messageD[MesKeyStr.NickName], messageD[MesKeyStr.PassWord]));
                break;
            }

            case CommandType.GroupMessage:
            {
                GroupMessageEvent?.Invoke(this, messageD);
                break;
            }

            case CommandType.PrivateMessage:
            {
                PrivateMessageEvent?.Invoke(this, messageD);
                break;
            }

            case CommandType.UserJoin:
            case CommandType.UserQuit:
            case CommandType.LoginResult:
            case CommandType.SignUpResult:
            case CommandType.ServerDisconnect:
            case CommandType.Remove:
            {
                ShowMessage("收到错误的消息类型!");
                throw new Exception("收到错误的消息类型!");
            }
            }
        }
示例#2
0
        static void Main(string[] args)
        {
            cqhttp.Cyan.Logger.LogLevel = cqhttp.Cyan.Enums.Verbosity.INFO;
            CQApiClient cli = new CQHTTPClient(
                accessUrl: "http://127.0.0.1:5700",
                listen_port: 210
                );

            Group.Jobs.StartJobs(cli, 00000000);
            Private.Operation.LoadData();
            cli.OnEvent += (client, e) => {
                if (e is MessageEvent)
                {
                    string  text_message = getText((e as MessageEvent).message);
                    Command cmd;
                    try {
                        cmd = Parser.ParseCommand(text_message, (e as MessageEvent).sender.nickname);
                    } catch { return(new EmptyResponse()); }
                    if (e is GroupMessageEvent)
                    {
                        GroupMessageEvent ge = (e as GroupMessageEvent);
                        cmd.endPoint = (client, (ge.messageType, ge.group_id));
                        if (privateCommands.IndexOf(cmd.operation) != -1)
                        {
                            client.SendTextAsync(
                                cmd.endPoint.Item2, "请私聊调用这项功能"
                                );
                            client.SendTextAsync(
                                cqhttp.Cyan.Enums.MessageType.private_,
                                ge.sender.user_id, helpMsg
                                );
                        }
                        else
                        {
                            Group.Jobs.Handle(cmd);
                        }
                    }
                    else if (e is PrivateMessageEvent)
                    {
                        PrivateMessageEvent pe = (e as PrivateMessageEvent);
                        cmd.endPoint = (cli, (pe.messageType, pe.sender_id));
                        if (cmd.operation == "help")
                        {
                            cli.SendTextAsync(cmd.endPoint.Item2, helpMsg);
                            return(new EmptyResponse());
                        }
                        try {
                            Private.Operation.Handle(cmd).Wait();
                        } catch (AggregateException ee) {
                            throw ee.InnerException;
                        }
                    }
                }
                return(new EmptyResponse());
            };
            Console.ReadLine();
        }
示例#3
0
        public void ReceviceGroupMsg(GroupMessageEvent e)
        {
            if (e.SenderQQ == 1000032 || e.ThisQQ == e.SenderQQ)//不处理匿名信息和自己
            {
                return;
            }
            // Common.xlzAPI.SendGroupMessage(e.ThisQQ, e.MessageGroupQQ, "测试小栗子C# SDK", true);
            // Common.xlzAPI.RecviceImage(e.MessageContent, e.ThisQQ, e.SenderQQ);
            //if (e.MessageContent.Contains("转发"))
            //{
            //    Common.xlzAPI.SendGroupMessage(e.ThisQQ, e.MessageGroupQQ, e.MessageContent);
            //}
            if (e.MessageContent.Equals("谁是龙王"))
            {
                string lKing = GetDragonKing(e.ThisQQ, e.MessageGroupQQ);
                if (lKing.Contains("acceptLanguages"))
                {
                    dynamic token = new JavaScriptSerializer().Deserialize <dynamic>(lKing);
                    Dictionary <string, object> json = new JavaScriptSerializer().Deserialize <Dictionary <string, object> >(lKing);
                    int count = ((ArrayList)json["talkativeList"]).Count;
                    if (token["gc"] != null && (string)token["gc"] == e.MessageGroupQQ.ToString())
                    {
                        Common.xlzAPI.SendGroupMessage(e.ThisQQ, e.MessageGroupQQ, "现任龙王: " + (string)token["talkativeList"][0]["name"] + "(" + Convert.ToString(token["talkativeList"][0]["uin"]) + ")" + " 蝉联天数: " + (string)token["talkativeList"][0]["desc"]);
                        if (count > 1)
                        {
                            List <string> list = new List <string>();
                            for (int i = 1; i < count; i++)
                            {
                                list.Add((string)token["talkativeList"][i]["name"] + "(" + Convert.ToString(token["talkativeList"][i]["uin"]) + ")" + " 蝉联天数: " + (string)token["talkativeList"][i]["desc"]);
                                if (i > 5)
                                {
                                    break;
                                }
                            }
                            Common.xlzAPI.SendGroupMessage(e.ThisQQ, e.MessageGroupQQ, "历史龙王: " + Environment.NewLine + string.Join(Environment.NewLine, list));
                        }
                    }
                }
            }
            if (e.MessageContent.Equals("群签到"))
            {
                Common.xlzAPI.GroupSigninEvent(e.ThisQQ, e.MessageGroupQQ);
            }
            if (e.MessageContent.Equals("领红包"))
            {
                Common.xlzAPI.GetReceiveRedEnvelopeEvent(e.ThisQQ, e.MessageGroupQQ, e.SenderQQ, "", 2, "");
            }
            string picpath = System.Environment.CurrentDirectory + "\\logo.png";

            if (e.MessageContent.Equals("发图"))
            {
                Common.xlzAPI.SendGroupImage(e.ThisQQ, e.MessageGroupQQ, picpath, false);
            }
        }
示例#4
0
 public static int RecvicetGroupMessage(IntPtr intPtr)
 {
     if (Common.unityContainer.IsRegistered <IGroupMessage>())
     {
         GroupMessageEvent data = new GroupMessageEvent();
         data = (GroupMessageEvent)Marshal.PtrToStructure(intPtr, typeof(GroupMessageEvent));
         //string txt = Marshal.PtrToStringAnsi(data.MessageContent);
         Common.unityContainer.Resolve <IGroupMessage>().ReceviceGroupMsg(data);
         return((int)EventMessageEnum.Ignore);
     }
     return((int)EventMessageEnum.Ignore);
 }
示例#5
0
        public static int RecvicetGroupMessage(ref GroupMessageEvent sMsg)
        {
            API.MyQQ = sMsg.ThisQQ;
            if (API.MsgRecod == true)
            {
                SqliHelper.InsertData("消息记录", new string[] { "GroupID", "QQID", "MessageReq", "MessageRandom", "TimeStamp", "Msg" }, new string[] { sMsg.MessageGroupQQ.ToString(), sMsg.SenderQQ.ToString(), sMsg.MessageReq.ToString(), sMsg.MessageRandom.ToString(), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss tt", CultureInfo.InvariantCulture), sMsg.MessageContent });
            }
            ;
            //SqliHelper.InsertData("消息记录", new string[] { "GroupID", "QQID", "MessageReq", "MessageRandom", "TimeStamp", "Msg" }, new string[] { sMsg.MessageGroupQQ.ToString(), sMsg.SenderQQ.ToString(), sMsg.MessageReq.ToString(), sMsg.MessageRandom.ToString(), ((long)(DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds).ToString(), sMsg.MessageContent }); ;
            if (SqliHelper.CheckDataExsit("授权群号", "GroupID", sMsg.MessageGroupQQ.ToString()) == false)            //如果不在高级权限里不反馈
            {
                return(0);
            }

            if (SqliHelper.CheckDataExsit("高级权限", "QQID", sMsg.SenderQQ.ToString()) == false && API.GetAdministratorLists(sMsg.ThisQQ, sMsg.MessageGroupQQ).Contains(sMsg.SenderQQ.ToString()) == false)            //如果不在高级权限里不反馈
            {
                if (sMsg.SenderQQ != sMsg.ThisQQ)
                {
                    //API.SendGroupMsg(PInvoke.plugin_key, sMsg.ThisQQ, sMsg.MessageGroupQQ, "[@" + sMsg.SenderQQ.ToString() + "]" + "抱歉!你的QQ号不在高级授权名单.", false);
                    return(0);
                }
            }

            if (sMsg.SenderQQ != sMsg.ThisQQ)
            {
                if (sMsg.MessageContent.Contains("[pic,hash="))
                {
                    MatchCollection matches = Regex.Matches(sMsg.MessageContent, "\\[pic,hash.*?\\]", RegexOptions.Multiline | RegexOptions.IgnoreCase);

                    foreach (Match match in matches)
                    {
                        API.GetImageLink(sMsg.ThisQQ, sMsg.SenderQQ, sMsg.MessageGroupQQ, match.Value);
                    }
                }
                else if (sMsg.MessageContent.Contains("[file,fileId="))                 //发送文件
                {
                }
                else if (sMsg.MessageContent.Contains("[Audio,hash="))                 //发送语音
                {
                }
                else if (sMsg.MessageContent == "开启消息记录")
                {
                    API.MsgRecod = true;
                    API.SendGroupMsg(PInvoke.plugin_key, sMsg.ThisQQ, sMsg.MessageGroupQQ, "[@" + sMsg.SenderQQ.ToString() + "]" + "已开始消息记录.", false);
                }
                else if (sMsg.MessageContent.Contains("添加黑名单"))
                {
                    string output = Regex.Replace(sMsg.MessageContent, @"[\d]", string.Empty);
                    if ((new Regex("(?i)[^添加黑名单]")).IsMatch(output.Replace(" ", "")) == true)
                    {
                        return(0);
                    }
                    Match m = new Regex("\\d+").Match(sMsg.MessageContent);
                    if (m.Value.Length < 7)
                    {
                        return(0);
                    }
                    if (m.Success)
                    {
                        if (API.DeleteGroupMember(PInvoke.plugin_key, sMsg.ThisQQ, sMsg.MessageGroupQQ, long.Parse(m.Value), true))
                        {
                            if (SqliHelper.CheckDataExsit("黑名单", "QQID", m.Value) == false)
                            {
                                SqliHelper.InsertData("黑名单", new string[] { "QQID", "time" }, new string[] { m.Value, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss tt", CultureInfo.InvariantCulture) });
                                API.SendGroupMsg(PInvoke.plugin_key, sMsg.ThisQQ, sMsg.MessageGroupQQ, "[@" + sMsg.SenderQQ.ToString() + "]" + "已将" + m.Value + "移除群并添加到黑名单!", false);
                            }
                        }
                    }
                }
                else if (sMsg.MessageContent.Contains("添加全局黑名单"))
                {
                    string output = Regex.Replace(sMsg.MessageContent, @"[\d]", string.Empty);
                    if ((new Regex("(?i)[^添加全局黑名单]")).IsMatch(output.Replace(" ", "")) == true)
                    {
                        return(0);
                    }
                    Match m = new Regex("\\d+").Match(sMsg.MessageContent);
                    if (m.Value.Length < 7)
                    {
                        return(0);
                    }
                    if (m.Success)
                    {
                        if (API.DeleteGroupMember(PInvoke.plugin_key, sMsg.ThisQQ, sMsg.MessageGroupQQ, long.Parse(m.Value), false))
                        {
                            if (SqliHelper.CheckDataExsit("黑名单", "QQID", m.Value) == false)
                            {
                                SqliHelper.InsertData("黑名单", new string[] { "QQID", "time" }, new string[] { m.Value, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss tt", CultureInfo.InvariantCulture) });
                                API.SendGroupMsg(PInvoke.plugin_key, sMsg.ThisQQ, sMsg.MessageGroupQQ, "[@" + sMsg.SenderQQ.ToString() + "]" + "已将" + m.Value + "移除群并添加到黑名单!", false);
                            }
                        }
                    }
                }
                else if (sMsg.MessageContent.Contains("解除黑名单"))
                {
                    string output = Regex.Replace(sMsg.MessageContent, @"[\d]", string.Empty);
                    if ((new Regex("(?i)[^解除黑名单]")).IsMatch(output.Replace(" ", "")) == true)
                    {
                        return(0);
                    }
                    Match m = new Regex("\\d+").Match(sMsg.MessageContent);
                    if (m.Value.Length < 7)
                    {
                        return(0);
                    }
                    if (m.Success)
                    {
                        if (API.DeleteGroupMember(PInvoke.plugin_key, sMsg.ThisQQ, sMsg.MessageGroupQQ, long.Parse(m.Value), false))
                        {
                            if (SqliHelper.CheckDataExsit("黑名单", "QQID", m.Value) == true)
                            {
                                SqliHelper.DeleteData("黑名单", "QQID", "QQID", "QQID like'" + m.Value + "'");
                                API.SendGroupMsg(PInvoke.plugin_key, sMsg.ThisQQ, sMsg.MessageGroupQQ, "[@" + sMsg.SenderQQ.ToString() + "]" + "已解除黑名单:" + m.Value, false);
                            }
                        }
                    }
                }
                else if (sMsg.MessageContent.ToUpper() == "查询CPU占用")
                {
                    string SendQQ  = sMsg.SenderQQ.ToString();
                    long   GroupQQ = sMsg.MessageGroupQQ;
                    long   thisqq  = sMsg.ThisQQ;
                    new Thread(() =>
                    {
                        string text = string.Join(Environment.NewLine, CpuMemoryCapacity.GetCpuUsage());
                        API.SendGroupMsg(PInvoke.plugin_key, thisqq, GroupQQ, "[@" + SendQQ + "]" + Environment.NewLine + text, false);
                    }).Start();
                }
                else if (sMsg.MessageContent == "查询内存占用")
                {
                    string SendQQ  = sMsg.SenderQQ.ToString();
                    long   GroupQQ = sMsg.MessageGroupQQ;
                    long   thisqq  = sMsg.ThisQQ;
                    new Thread(() =>
                    {
                        string[] strArray = CpuMemoryCapacity.GetMemoryUsage().ToArray();;
                        strArray          = strArray.Select(s => s.TrimStart('0')).ToArray();
                        API.SendGroupMsg(PInvoke.plugin_key, thisqq, GroupQQ, "[@" + SendQQ + "]" + Environment.NewLine + string.Join(Environment.NewLine, strArray), false);
                    }).Start();
                }
                else if (sMsg.MessageContent == "查询资源占用")
                {
                    string SendQQ  = sMsg.SenderQQ.ToString();
                    long   GroupQQ = sMsg.MessageGroupQQ;
                    long   thisqq  = sMsg.ThisQQ;
                    new Thread(() =>
                    {
                        string text = string.Join(Environment.NewLine, CpuMemoryCapacity.HardwareInfo());
                        text        = text + Environment.NewLine + string.Join(Environment.NewLine, CpuMemoryCapacity.MemoryAvailable());
                        text        = text + Environment.NewLine + string.Join(Environment.NewLine, CpuMemoryCapacity.GetUsage());
                        API.SendGroupMsg(PInvoke.plugin_key, thisqq, GroupQQ, "[@" + SendQQ + "]" + Environment.NewLine + text, false);
                    }).Start();
                }
                else if (sMsg.MessageContent == "机器人菜单")
                {
                    API.SendGroupMsg(PInvoke.plugin_key, sMsg.ThisQQ, sMsg.MessageGroupQQ, "[@" + sMsg.SenderQQ.ToString() + "]" + Environment.NewLine + PInvoke.RobotMenu, false);
                }
                else if (sMsg.MessageContent == "全员禁言")
                {
                    if (API.MuteGroupAll(PInvoke.plugin_key, sMsg.ThisQQ, sMsg.MessageGroupQQ, true))
                    {
                        API.SendGroupMsg(PInvoke.plugin_key, sMsg.ThisQQ, sMsg.MessageGroupQQ, "已开启全员禁言!", false);
                    }
                }
                else if (sMsg.MessageContent == "解除全员禁言")
                {
                    if (API.MuteGroupAll(PInvoke.plugin_key, sMsg.ThisQQ, sMsg.MessageGroupQQ, true))
                    {
                        API.SendGroupMsg(PInvoke.plugin_key, sMsg.ThisQQ, sMsg.MessageGroupQQ, "已解除全员禁言!", false);
                    }
                }
                else if (sMsg.MessageContent.Contains("禁言") && sMsg.MessageContent.Contains("时间") && sMsg.MessageContent.Contains("分钟"))
                {
                    string output = Regex.Replace(sMsg.MessageContent, @"[\d]", string.Empty);
                    if (new Regex("(?i)[^禁言时间分钟]").IsMatch(output.Replace(" ", "")) == true)
                    {
                        return(0);
                    }
                    string          szQQID  = "123";
                    uint            minute  = 0;
                    MatchCollection matches = new Regex("\\d+").Matches(sMsg.MessageContent);
                    if (matches.Count > 2)
                    {
                        return(0);
                    }
                    foreach (Match match in matches)
                    {
                        if (match.Value.ToString().Length >= 6)
                        {
                            szQQID = match.Value;
                        }
                        else if (match.Value.ToString().Length < 3)
                        {
                            minute = uint.Parse(match.Value);
                        }
                    }
                    if (API.MuteGroupMember(PInvoke.plugin_key, sMsg.ThisQQ, sMsg.MessageGroupQQ, long.Parse(szQQID), minute * 60))
                    {
                        API.SendGroupMsg(PInvoke.plugin_key, sMsg.ThisQQ, sMsg.MessageGroupQQ, szQQID + "已被禁言" + minute.ToString() + "分钟!", false);
                    }
                }
                else if (sMsg.MessageContent.Contains("解除禁言"))
                {
                    string output = Regex.Replace(sMsg.MessageContent, @"[\d]", string.Empty);
                    if ((new Regex("(?i)[^解除禁言]")).IsMatch(output.Replace(" ", "")) == true)
                    {
                        return(0);
                    }
                    Match m = new Regex("\\d+").Match(sMsg.MessageContent);
                    if (m.Value.Length < 7)
                    {
                        return(0);
                    }
                    if (m.Success)
                    {
                        if (API.MuteGroupMember(PInvoke.plugin_key, sMsg.ThisQQ, sMsg.MessageGroupQQ, long.Parse(m.Value), 0))
                        {
                            API.SendGroupMsg(PInvoke.plugin_key, sMsg.ThisQQ, sMsg.MessageGroupQQ, "已解除" + m.Value + "的禁言", false);
                        }
                    }
                }
                else if (sMsg.MessageContent == "取群列表")
                {
                    API.GetGroupLists(sMsg.ThisQQ, sMsg.MessageGroupQQ);
                }
                else if (sMsg.MessageContent == "取群成员列表")
                {
                    API.GetGroupMemberlists(sMsg.ThisQQ, sMsg.MessageGroupQQ);
                }
                else if (sMsg.MessageContent.Contains("同意") && sMsg.MessageContent.Contains("入群"))
                {
                    string output = Regex.Replace(sMsg.MessageContent, @"[\d]", string.Empty);
                    if (new Regex("(?i)[^同意入群]").IsMatch(output.Replace(" ", "")) == true)
                    {
                        return(0);
                    }
                    Match m = new Regex("\\d+").Match(sMsg.MessageContent);
                    if (m.Value.Length < 7)
                    {
                        return(0);
                    }
                    if (m.Success)
                    {
                        try
                        {
                            API.GroupVerificationEvent(PInvoke.plugin_key, sMsg.ThisQQ, API.EventDics[long.Parse(m.Value)].Item1, long.Parse(m.Value), API.EventDics[long.Parse(m.Value)].Item3, GroupVerificationOperateEnum.Agree, PInvoke.EventTypeEnum.Group_MemberVerifying, null);
                            API.EventDics.Remove(long.Parse(m.Value));
                            API.SendGroupMsg(PInvoke.plugin_key, sMsg.ThisQQ, sMsg.MessageGroupQQ, "[@" + sMsg.SenderQQ.ToString() + "]" + "已处理完毕.", false);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Message.ToString());
                        }
                    }
                }
                else if (sMsg.MessageContent.Contains("拒绝") && sMsg.MessageContent.Contains("入群"))
                {
                    string output = Regex.Replace(sMsg.MessageContent, @"[\d]", string.Empty);
                    if ((new Regex("(?i)[^拒绝入群]")).IsMatch(output.Replace(" ", "")) == true)
                    {
                        return(0);
                    }
                    Match m = new Regex("\\d+").Match(sMsg.MessageContent);
                    if (m.Value.Length < 7)
                    {
                        return(0);
                    }
                    if (m.Success)
                    {
                        try
                        {
                            API.GroupVerificationEvent(PInvoke.plugin_key, sMsg.ThisQQ, API.EventDics[long.Parse(m.Value)].Item1, long.Parse(m.Value), API.EventDics[long.Parse(m.Value)].Item3, GroupVerificationOperateEnum.Deny, PInvoke.EventTypeEnum.Group_MemberVerifying, "拒绝入群");
                            API.EventDics.Remove(long.Parse(m.Value));
                            API.SendGroupMsg(PInvoke.plugin_key, sMsg.ThisQQ, sMsg.MessageGroupQQ, "[@" + sMsg.SenderQQ.ToString() + "]" + "已处理完毕.", false);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Message.ToString());
                        }
                    }
                }
                else if (sMsg.MessageContent.Contains("同意进群"))
                {
                    string output = Regex.Replace(sMsg.MessageContent, @"[\d]", string.Empty);
                    if ((new Regex("(?i)[^同意进群]")).IsMatch(output.Replace(" ", "")) == true)
                    {
                        return(0);
                    }
                    Match m = new Regex("\\d+").Match(sMsg.MessageContent);
                    if (m.Value.Length < 6)
                    {
                        return(0);
                    }
                    if (m.Success)
                    {
                        try
                        {
                            var ret = API.GroupVerificationEvent(PInvoke.plugin_key, sMsg.ThisQQ, API.EventDics[long.Parse(m.Value)].Item1, long.Parse(m.Value), API.EventDics[long.Parse(m.Value)].Item3, GroupVerificationOperateEnum.Agree, PInvoke.EventTypeEnum.Group_Invited, "同意入群");
                            API.EventDics.Remove(long.Parse(m.Value));
                            API.SendGroupMsg(PInvoke.plugin_key, sMsg.ThisQQ, sMsg.MessageGroupQQ, "[@" + sMsg.SenderQQ.ToString() + "]" + "已加入群:" + m.Value, false);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Message.ToString());
                        }
                    }
                }
                else if (sMsg.MessageContent.Contains("拒绝进群"))
                {
                    string output = Regex.Replace(sMsg.MessageContent, @"[\d]", string.Empty);
                    if ((new Regex("(?i)[^拒绝进群]")).IsMatch(output.Replace(" ", "")) == true)
                    {
                        return(0);
                    }
                    Match m = new Regex("\\d+").Match(sMsg.MessageContent);
                    if (m.Value.Length < 6)
                    {
                        return(0);
                    }
                    if (m.Success)
                    {
                        try
                        {
                            API.GroupVerificationEvent(PInvoke.plugin_key, sMsg.ThisQQ, API.EventDics[long.Parse(m.Value)].Item1, long.Parse(m.Value), API.EventDics[long.Parse(m.Value)].Item3, GroupVerificationOperateEnum.Deny, PInvoke.EventTypeEnum.Group_MemberInvited, "拒绝进群");
                            API.EventDics.Remove(long.Parse(m.Value));
                            API.SendGroupMsg(PInvoke.plugin_key, sMsg.ThisQQ, sMsg.MessageGroupQQ, "[@" + sMsg.SenderQQ.ToString() + "]" + "已拒绝邀请.", false);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Message.ToString());
                        }
                    }
                }
                else if (sMsg.MessageContent.Contains("同意加") && sMsg.MessageContent.Contains("为好友"))
                {
                    string output = Regex.Replace(sMsg.MessageContent, @"[\d]", string.Empty);
                    if ((new Regex("(?i)[^同意加为好友]")).IsMatch(output.Replace(" ", "")) == true)
                    {
                        return(0);
                    }
                    Match m = new Regex("\\d+").Match(sMsg.MessageContent);
                    if (m.Value.Length < 7)
                    {
                        return(0);
                    }
                    if (m.Success)
                    {
                        try
                        {
                            API.FriendverificationEvent(PInvoke.plugin_key, sMsg.ThisQQ, long.Parse(m.Value), API.EventDics[long.Parse(m.Value)].Item3, FriendVerificationOperateEnum.Agree);
                            API.EventDics.Remove(long.Parse(m.Value));
                            API.SendGroupMsg(PInvoke.plugin_key, sMsg.ThisQQ, sMsg.MessageGroupQQ, "[@" + sMsg.SenderQQ.ToString() + "]" + "已处理完毕.", false);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Message.ToString());
                        }
                    }
                }
                else if (sMsg.MessageContent.Contains("拒绝加") && sMsg.MessageContent.Contains("为好友"))
                {
                    string output = Regex.Replace(sMsg.MessageContent, @"[\d-]", string.Empty);
                    if (new Regex("(?i)[^拒绝加为好友]").IsMatch(output.Replace(" ", "")) == true)
                    {
                        return(0);
                    }
                    Match m = new Regex("\\d+").Match(sMsg.MessageContent);
                    if (m.Value.ToString().Length < 7)
                    {
                        return(0);
                    }
                    if (m.Success)
                    {
                        try
                        {
                            API.FriendverificationEvent(PInvoke.plugin_key, sMsg.ThisQQ, long.Parse(m.Value), API.EventDics[long.Parse(m.Value)].Item3, FriendVerificationOperateEnum.Deny);
                            API.EventDics.Remove(long.Parse(m.Value.ToString()));
                            API.SendGroupMsg(PInvoke.plugin_key, sMsg.ThisQQ, sMsg.MessageGroupQQ, "[@" + sMsg.SenderQQ.ToString() + "]" + "已处理完毕.", false);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Message);
                        }
                    }
                }
                else if (sMsg.MessageContent.Contains("撤回") && sMsg.MessageContent.Contains("最近消息") && sMsg.MessageContent.Contains("条"))
                {
                    string output = Regex.Replace(sMsg.MessageContent, @"[\d-]", string.Empty);
                    if (new Regex("(?i)[^撤回最近消息条]").IsMatch(output.Replace(" ", "")) == true)
                    {
                        return(0);
                    }
                    string          szQQID  = "123";
                    int             Number  = 0;
                    MatchCollection matches = new Regex("\\d+").Matches(sMsg.MessageContent);
                    if (matches.Count > 2)
                    {
                        return(0);
                    }
                    foreach (Match match in matches)
                    {
                        if (match.Value.ToString().Length >= 6)
                        {
                            szQQID = match.Value;
                        }
                        else if (match.Value.ToString().Length < 3)
                        {
                            Number = int.Parse(match.Value);
                        }
                    }
                    List <List <string> > MsgList = SqliHelper.ReadData("消息记录", new string[] { "GroupID", "QQID", "MessageReq", "MessageRandom", "TimeStamp" }, "ORDER BY ID DESC LIMIT " + Number, "QQID like '" + szQQID + "'");
                    int n = 0;
                    foreach (List <string> list in MsgList)
                    {
                        n = n + 1;
                        bool sucess = API.Undo_GroupEvent(PInvoke.plugin_key, sMsg.ThisQQ, long.Parse(list[0]), long.Parse(list[3]), int.Parse(list[2]));
                        if (sucess)
                        {
                            API.SendGroupMsg(PInvoke.plugin_key, sMsg.ThisQQ, sMsg.MessageGroupQQ, "[@" + sMsg.SenderQQ.ToString() + "]" + "已撤回" + szQQID + "最近消息" + n.ToString() + "条", false);
                        }
                    }
                }
                else if (sMsg.MessageContent == "压力测试")
                {
                    token = cts.Token;
                    long thisqq = sMsg.ThisQQ;
                    Task.Factory.StartNew(() =>
                    {
                        int i = 0;
                        while (!token.IsCancellationRequested)
                        {
                            i = i + 1;
                            API.SendGroupMsg(plugin_key, thisqq, 66847886, "小栗子机器人插件\r\n发送群消息压力测试\r\n测试~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n" + DateTime.Now.ToString(), false);
                            //API.SendGroupMsg(API.MyQQ, 66847886, "小栗子机器人插件\r\n发送群消息压力测试\r\n测试~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n" +DateTime.Now.ToString());
                            API.SendGroupMsg(plugin_key, thisqq, 66847886, i.ToString(), false);
                            Thread.Sleep(500);
                        }
                    }, token);
                }
                else if (sMsg.MessageContent == "停止压力测试")
                {
                    if (cts != null)
                    {
                        cts.Cancel();
                        cts.Dispose();
                        cts = new CancellationTokenSource();
                    }
                }
                else
                {
                    //复读机
                    //API.SendGroupMsg(PInvoke.plugin_key,sMsg.ThisQQ, sMsg.MessageGroupQQ, "[@" + sMsg.SenderQQ.ToString() + "]" + "你发送了这样的消息:" + sMsg.MessageContent,false);
                }
            }
            return(0);
        }