Пример #1
0
        public static string Start(long uid)
        {
            //检查是否创建
            if (ps.Start == false)
            {
                return(CQApi.CQCode_At(uid) + "飞花令还未创建!回复【飞花令创建】创建一场比赛");
            }

            //检查是否开始
            if (ps.Flag != "")
            {
                return(CQApi.CQCode_At(uid) + "飞花令已经开始了!");
            }

            //检查是否发起者
            if (ps.CreateUid != uid)
            {
                return(CQApi.CQCode_At(uid) + "不是创建者无法开始飞花令!\n" + CQApi.CQCode_At(uid) + "如果觉得可以开始比赛了,请回复【飞花令开始】开始比赛!");
            }

            if (ps.Players.Count < 2)
            {
                return(CQApi.CQCode_At(uid) + "人数不足!无法开始比赛!\n请选手们回复【飞花令加入】参与!");
            }

            ps.Flag = PoemData.GetFlag();
            return($"飞花令开始!\n系统出题,关键字为【{ps.Flag}】\n请回复带有【{ps.Flag}】的诗句!\n(直接回复诗句即可)\n" +
                   $"现在请{CQApi.CQCode_At(ps.Players[0].Uid)}首先开始回复!\n(PS:如果暂时想不出来,请回复【飞花令跳过】)");
        }
Пример #2
0
        public static string Join(long uid)
        {
            //检查是否创建
            if (ps.Start == false)
            {
                return(CQApi.CQCode_At(uid) + "飞花令还未创建!回复【飞花令创建】创建一场比赛");
            }

            //检查是否开始
            if (ps.Flag != "")
            {
                return(CQApi.CQCode_At(uid) + "飞花令已经开始了!不能中途参加!");
            }

            //检查是否参加
            foreach (var tmp in ps.Players)
            {
                if (tmp.Uid == uid)
                {
                    return(CQApi.CQCode_At(uid) + "你已经加入比赛!");
                }
            }
            ps.Players.Add(new Player(uid));
            return(CQApi.CQCode_At(uid) + "加入比赛成功!" + CQApi.CQCode_At(ps.CreateUid) + "如果觉得可以开始比赛了,请回复【飞花令开始】开始比赛!");
        }
Пример #3
0
 /// <summary>
 /// 存在非法参数时的响应
 /// </summary>
 /// <param name="e">CQGroupMessageEventArgs</param>
 /// <param name="commandType">指令类型</param>
 /// <param name="errDescription">错误描述</param>
 public static void GetIllegalArgs(CQGroupMessageEventArgs e, PCRGuildCmdType commandType, string errDescription)
 {
     ConsoleLog.Warning("PCR公会管理", "非法参数");
     e.FromGroup.SendGroupMessage(
         CQApi.CQCode_At(e.FromQQ.Id),
         "\n非法参数请重新输入指令" +
         $"\n错误:{errDescription}" +
         $"\n指令帮助:{GetCommandHelp(commandType)}");
 }
Пример #4
0
        /// <summary>
        /// 初始化特殊关键词
        /// </summary>
        public static void SpecialKeywordsInit(CQApi cqApi)
        {
            Keywords.Add("查询排名", KeywordCmdType.PCRTools_GetGuildRank);
            Keywords.Add("来点切噜", KeywordCmdType.Cheru_Encode);
            Keywords.Add("切噜~", KeywordCmdType.Cheru_Decode);
            Keywords.Add("切噜~", KeywordCmdType.Cheru_Decode);

            Keywords.Add("echo", KeywordCmdType.Debug_Echo);
            Keywords.Add(CQApi.CQCode_At(cqApi.GetLoginQQ().Id).ToString(), KeywordCmdType.At_Bot);
        }
Пример #5
0
 public static string Create(long uid)
 {
     if (ps.Start)
     {
         return(CQApi.CQCode_At(uid) + "飞花令已经创建啦!");
     }
     ps.Start     = true;
     ps.CreateUid = uid;
     return(CQApi.CQCode_At(uid) + "飞花令创建完成!\n请选手们回复【飞花令加入】参与!\n" + CQApi.CQCode_At(uid) + "参与人数达2人及以上,回复【飞花令开始】开始比赛!");
 }
Пример #6
0
        public void GroupMemberIncrease(object sender, CQGroupMemberIncreaseEventArgs e)
        {
            IniObject iniObject = IniObject.Load(e.CQApi.AppDirectory + "config.ini", Encoding.UTF8);

            if ("711498146,222600436".IndexOf(e.FromGroup.Id.ToString()) >= 0)
            {
                string str = iniObject["InOne"]["YinZhiChen"].ToString().Replace(" ", "\n");

                e.FromGroup.SendGroupMessage(CQApi.CQCode_At(e.BeingOperateQQ) + str);
            }
        }
Пример #7
0
        /// <summary>
        /// 收到群消息
        /// </summary>
        /// <param name="sender">事件来源</param>
        /// <param name="e">事件参数</param>
        public void GroupMessage(object sender, CQGroupMessageEventArgs e)
        {
            #region ---AV号与BV号的转换---
            if (e.Message.Text.Contains("bilibili.com/video/BV"))
            {
                {
                    try
                    {
                        string bv_replace = "/BV(.){9,10}";
                        string bv         = System.Text.RegularExpressions.Regex.Match(e.Message.Text, bv_replace).ToString();
                        bv = bv.Replace("/", "");
                        WebClient                wb           = new WebClient();
                        byte[]                   DownloadData = wb.DownloadData("http://api.bilibili.com/x/web-interface/archive/stat?bvid=" + bv);
                        string                   EncodeStr    = System.Text.Encoding.UTF8.GetString(DownloadData);
                        JavaScriptSerializer     js           = new JavaScriptSerializer();
                        bilibiliClass.Rootobject root         = js.Deserialize <bilibiliClass.Rootobject>(EncodeStr);
                        e.CQApi.SendGroupMessage(e.FromGroup, CQApi.CQCode_At(e.FromQQ), "AV号:av" + root.data.aid + "\nBV号:" + root.data.bvid + "\n播放量:" + root.data.view + "\n收藏量:" + root.data.favorite);
                    }
                    catch
                    {
                        e.CQApi.SendGroupMessage(e.FromGroup, CQApi.CQCode_At(e.FromQQ) + "哦豁,出错了。");
                        e.Handler = false;
                        return;
                    }
                }
            }

            if (e.Message.Text.Contains("bilibili.com/video/av"))
            {
                {
                    try
                    {
                        string av_replace = "/av(.){1,10}";
                        string av         = System.Text.RegularExpressions.Regex.Match(e.Message.Text, av_replace).ToString();
                        av = av.Replace("/av", "");
                        WebClient                wb           = new WebClient();
                        byte[]                   DownloadData = wb.DownloadData("http://api.bilibili.com/x/web-interface/archive/stat?aid=" + av);
                        string                   EncodeStr    = System.Text.Encoding.UTF8.GetString(DownloadData);
                        JavaScriptSerializer     js           = new JavaScriptSerializer();
                        bilibiliClass.Rootobject root1        = js.Deserialize <bilibiliClass.Rootobject>(EncodeStr);
                        e.CQApi.SendGroupMessage(e.FromGroup, CQApi.CQCode_At(e.FromQQ), "AV号:av" + root1.data.aid + "\nBV号:" + root1.data.bvid + "\n播放量:" + root1.data.view + "\n收藏量:" + root1.data.favorite);
                    }
                    catch
                    {
                        e.CQApi.SendGroupMessage(e.FromGroup, CQApi.CQCode_At(e.FromQQ) + "哦豁,出错了。");
                        e.Handler = false;
                        return;
                    }
                }
            }
            #endregion
        }
Пример #8
0
        public static string Exit(long uid)
        {
            //检查是否创建
            if (ps.Start == false)
            {
                return(CQApi.CQCode_At(uid) + "飞花令还未创建!回复【飞花令创建】创建一场比赛");
            }

            //检查是否开始
            if (ps.Flag == "")
            {
                return(CQApi.CQCode_At(uid) + "飞花令还未开始!" + CQApi.CQCode_At(uid) + "如果觉得可以开始比赛了,请回复【飞花令开始】开始比赛!");
            }

            //检查是否参加
            bool isJoin = false;

            foreach (var tmp in ps.Players)
            {
                if (tmp.Uid == uid)
                {
                    isJoin = true;
                    break;
                }
            }
            if (isJoin == false)
            {
                return(CQApi.CQCode_At(uid) + "你未参加本次飞花令比赛!");
            }

            if (ps.LastPlayerIndex != -1)
            {
                int index = ps.Players.IndexOf(ps.Players.Where(p => p.Uid == uid).FirstOrDefault());
                if (index <= ps.LastPlayerIndex)
                {
                    ps.LastPlayerIndex--;
                }
            }
            ps.Players.Remove(ps.Players.Where(p => p.Uid == uid).First());
            if (ps.Players.Count <= 1)
            {
                return("由于飞花令当前参赛人数过少,强制结束\n" + End(ps.CreateUid));
            }
            int nextIndex = ps.LastPlayerIndex + 1;

            if (nextIndex >= ps.Players.Count)
            {
                nextIndex = 0;
            }
            return($"退出飞花令成功!\n现在请{CQApi.CQCode_At(ps.Players[nextIndex].Uid)}回复\n回复格式为【飞花令回复 诗句】\n(PS:如果暂时想不出来,请回复【飞花令跳过】)");
        }
Пример #9
0
        public static string Leap(long uid)
        {
            //检查是否创建
            if (ps.Start == false)
            {
                return(CQApi.CQCode_At(uid) + "飞花令还未创建!回复【飞花令创建】创建一场比赛");
            }

            //检查是否开始
            if (ps.Flag == "")
            {
                return(CQApi.CQCode_At(uid) + "飞花令还未开始!" + CQApi.CQCode_At(uid) + "如果觉得可以开始比赛了,请回复【飞花令开始】开始比赛!");
            }

            //检查是否参加
            bool isJoin = false;

            foreach (var tmp in ps.Players)
            {
                if (tmp.Uid == uid)
                {
                    isJoin = true;
                    break;
                }
            }
            if (isJoin == false)
            {
                return(CQApi.CQCode_At(uid) + "你未参加本次飞花令比赛!");
            }

            //检查当前轮玩家
            int index = ps.LastPlayerIndex + 1;

            if (index >= ps.Players.Count)
            {
                index = 0;
            }
            if (ps.Players[index].Uid != uid)
            {
                return(CQApi.CQCode_At(uid) + "还未轮到你回复!\n现在请" + CQApi.CQCode_At(ps.Players[index].Uid) + "回复");
            }

            ps.LastPlayerIndex = index;
            int nextIndex = ps.LastPlayerIndex + 1;

            if (nextIndex >= ps.Players.Count)
            {
                nextIndex = 0;
            }
            return($"{CQApi.CQCode_At(uid)}你跳过了本轮飞花令。本轮不加积分。\n现在请{CQApi.CQCode_At(ps.Players[nextIndex].Uid)}回复\n回复格式为【飞花令回复 诗句】\n(PS:如果暂时想不出来,请回复【飞花令跳过】)");
        }
        public void GroupMessage(object sender, CQGroupMessageEventArgs e)
        {
            Chat   chat = Chat.Of(e.FromGroup.Id);
            string msg  = e.Message.Text;

            if (msg.StartsWith(Global.Prefix))
            {
                chat.AddMessage(e.Message.Text, e.FromQQ.Id, Chat.Message.Command);
                QQGroupMemberType memberType = e.FromGroup.GetGroupMemberInfo(e.FromQQ).MemberType;
                DMEnv             env        = new DMEnv(
                    e.FromQQ.Id,
                    e.FromGroup.Id,
                    memberType == QQGroupMemberType.Manage || memberType == QQGroupMemberType.Creator
                    );
                if (Global.DoAt)
                {
                    env.Append(CQApi.CQCode_At(e.FromQQ));
                }
                if (Global.Reply(msg, env))
                {
                    string reply = env.ToString().Trim();
                    chat.SendMessage(reply, Chat.Message.Reply);
                    e.CQLog.Info("ArkhamDiceMaid", "响应成功");
                }
                else
                {
                    e.CQLog.Info("ArkhamDiceMaid", "响应失败");
                }
            }
            else
            {
                List <CQCode> codes = e.Message.CQCodes;

                if (codes?.Count > 0)
                {
                    long qq = e.FromQQ.Id;
                    foreach (CQCode code in codes)
                    {
                        switch (code.Function)
                        {
                        case CQFunction.Image: chat.AddMessage(e.CQApi.ReceiveImage(code), qq, Chat.Message.Image); break;
                        }
                    }
                }
                else
                {
                    chat.AddMessage(e.Message.Text, e.FromQQ.Id);
                }
            }
        }
Пример #11
0
        public static void GameHandle(CQGroupMessageEventArgs e)
        {
            if (cookies.ThatWords.Running)
            {
                e.FromGroup.SendGroupMessage("上一个游戏还在进行,设置地雷的人为", CQApi.CQCode_At(cookies.ThatWords.qq));
            }
            else
            {
                e.FromGroup.SendGroupMessage(@"游戏:蜘蛛地雷
1. 发起者私聊面粉团,设置一个词语,作为地雷
2. 后续说出这个词语的玩家,将踩雷");
                //设置当前玩家
                cookies.ThatWords.qq = e.FromQQ.Id;
                e.FromQQ.SendPrivateMessage("嘿~小家伙,请说出你要设置的词语(2-4个字)");
            }
        }
Пример #12
0
        /// <summary>
        /// 按照抽卡结果生成图片
        /// </summary>
        /// <param name="count">抽卡次数</param>
        /// <returns></returns>
        public static string GetPicPath(int count, PoolInfo poolInfo, CQGroupMessageEventArgs e)
        {
            List <PoolContent> ls = new List <PoolContent>();

            for (int i = 0; i < count; i++)
            {
                var item = poolInfo.PoolContents[RandomGacha(poolInfo)];
                ls = FoldItem(item, ls);
            }
            Event_GroupMessage.SubDiamond(e, poolInfo.PerGachaConsumption * count);
            PicHelper combine = new PicHelper();

            ls = ls.OrderByDescending(x => x.Value).ToList();
            string CQAt = poolInfo.ResultAt ? CQApi.CQCode_At(e.FromQQ).ToSendString() : string.Empty;

            return(CQAt + combine.GeneratePic(poolInfo, ls, Event_GroupMessage.GetDiamond(e)));
        }
Пример #13
0
        public static string End(long uid)
        {
            //检查是否创建
            if (ps.Start == false)
            {
                return(CQApi.CQCode_At(uid) + "飞花令还未创建!回复【飞花令创建】创建一场比赛");
            }

            //检查是否开始
            if (ps.Flag == "")
            {
                return(CQApi.CQCode_At(uid) + "飞花令还未开始!" + CQApi.CQCode_At(uid) + "如果觉得可以开始比赛了,请回复【飞花令开始】开始比赛!");
            }

            //检查是否发起者
            if (ps.CreateUid != uid)
            {
                return(CQApi.CQCode_At(uid) + "不是创建者无法结束飞花令!\n本次飞花令发起者:" + CQApi.CQCode_At(ps.CreateUid));
            }

            //结束,统计分数
            for (int i = 0; i < ps.Players.Count - 1; i++)
            {
                for (int j = 0; j < ps.Players.Count - i - 1; j++)
                {
                    if (ps.Players[j].Score < ps.Players[j + 1].Score)
                    {
                        Player tmp = ps.Players[j];
                        ps.Players[j]     = ps.Players[j + 1];
                        ps.Players[j + 1] = tmp;
                    }
                }
            }

            //输出消息
            string result = "本次飞花令积分排行";

            for (int i = 0; i < ps.Players.Count; i++)
            {
                result += $"\n{i + 1}:{CQApi.CQCode_At(ps.Players[i].Uid)}[{ps.Players[i].Score}]";
            }
            ps = new PlayStatu();
            return(result);
        }
Пример #14
0
 /// <summary>
 /// 检查参数数组长度
 /// </summary>
 /// <param name="args">指令数组</param>
 /// <param name="len">至少需要的参数个数</param>
 /// <param name="QQgroup">(可选,不给的话就不发送错误信息)\n报错信息要发送到的QQ群对象</param>
 /// <param name="fromQQid">(可选,但QQgroup给了的话本参数必填)\n要通知的人的QQ Id</param>
 /// <returns>Illegal不符合 Legitimate符合 Extra超出</returns>
 public static LenType CheckForLength(string[] args, int len, Group QQgroup = null, long fromQQid = 0)
 {
     if (args.Length >= len + 1)
     {
         if (args.Length == len + 1)
         {
             return(LenType.Legitimate);
         }
         else
         {
             return(LenType.Extra);
         }
     }
     else
     {
         QQgroup?.SendGroupMessage(CQApi.CQCode_At(fromQQid), " 命令参数不全,请补充。");
         return(LenType.Illegal);
     }
 }
Пример #15
0
        public void GroupMemberIncrease(object sender, CQGroupMemberIncreaseEventArgs e)
        {
            List <Group> grouList = ReadXml.GetGroupsData();

            foreach (Group group in grouList)
            {
                if (e.FromGroup.Id == long.Parse(group.GroupNo))
                {
                    var picture = CQApi.CQCode_Image(group.ImageName).ToSendString();
                    var at      = CQApi.CQCode_At(e.BeingOperateQQ).ToSendString();

                    //发送群消息
                    e.CQApi.SendGroupMessage(e.FromGroup, at + group.Text + (group.IsSendImage ? picture : string.Empty));

                    e.Handler = true;
                    return;
                }
            }
        }
Пример #16
0
        public void PrivateMessage(object sender, CQPrivateMessageEventArgs e)
        {
            string msg = e.Message.Text;

            if (msg.StartsWith(Global.Prefix))
            {
                DMEnv env = new DMEnv(
                    e.FromQQ.Id,
                    Global.Users.TryGetValue(e.FromQQ.Id, out long groupId) ? groupId : 0,
                    false
                    );
                if (Global.DoAt)
                {
                    env.Append(CQApi.CQCode_At(e.FromQQ));
                }
                if (Global.Reply(msg, env))
                {
                    e.CQApi.SendPrivateMessage(e.FromQQ, env.ToString().Trim());
                }
            }
        }
Пример #17
0
        /// <summary>
        /// 获取水晶相关排行榜
        /// </summary>
        /// <param name="cn"></param>
        /// <param name="e"></param>
        /// <returns></returns>
        public static StringBuilder GetDiamondRank(SQLiteConnection cn, CQGroupMessageEventArgs e)
        {
            long          groupid = e.FromGroup.Id;
            StringBuilder sb      = new StringBuilder();

            sb.AppendLine($"----水晶排行榜----");
            SQLiteCommand cmd = new SQLiteCommand($"SELECT diamond,qq,sign_count FROM UserData WHERE Fromgroup={groupid} order by diamond desc", cn);

            using (SQLiteDataReader sr = cmd.ExecuteReader())
            {
                int count = 1;
                if (!sr.HasRows)
                {
                    return(sb);
                }
                while (sr.Read())
                {
                    int diamond = sr.GetInt32(0);
                    try
                    {
                        var    temp       = e.FromGroup.GetGroupMemberInfo(sr.GetInt64(1));
                        string name       = temp.Card == ""? temp.Nick:temp.Card;
                        int    sign_count = sr.GetInt32(2);
                        sb.AppendLine($"{count}. {name}->{diamond}水 共计签到{sign_count}次");
                    }
                    catch
                    {
                        int sign_count = sr.GetInt32(2);
                        sb.AppendLine($"{count}. {CQApi.CQCode_At(sr.GetInt64(1)).ToSendString()}->{diamond}水 共计签到{sign_count}次");
                    }
                    if (count == 10)
                    {
                        break;
                    }
                    count++;
                }
            }
            return(sb);
        }
Пример #18
0
        /// <summary>
        /// 判断是否满足拉取图片的权限, 并发送相关文本 (处理逻辑合理性待评)
        /// </summary>
        /// <param name="GroupID">需要判断的群号</param>
        /// <param name="QQID">需要判断的QQ号</param>
        public static bool QuotaCheck(long GroupID, long QQID)
        {
            //判断能否拉取图片,须符合:在群、个人调用未达上限、群调用未达上限
            List <string> response = JudgeLegality(GroupID, QQID);

            if (response.Count != 2)
            {
                return(false);
            }
            //将自定义at替换为CQ码
            response[1] = response[1].Replace("<@>", CQApi.CQCode_At(QQID).ToString());
            //发送处理后回答,内容可以是:调用成功、个人上限、群上限
            if (!string.IsNullOrEmpty(response[1]))
            {
                MainSave.CQApi.SendGroupMessage(GroupID, response[1]);
            }
            //若第一个数是非0说明不满足发送图片的要求
            if (response[0] != "0")
            {
                return(false);
            }
            return(true);
        }
Пример #19
0
        // 接收事件
        public void GroupMessage(object sender, CQGroupMessageEventArgs e)
        {
            int sid; double qq = 0;
            List <Native.Csharp.Sdk.Cqp.Model.GroupMemberInfo> mem;
            Random r = new Random(); string ques = "";
            int    hIndex = -1; MainThread.MessagePoster.HotMsg hhmsg = new MainThread.MessagePoster.HotMsg();

            Log("(" + e.FromGroup.Id + ")Message:" + e.FromQQ.Id + "," + e.Message.Text, ConsoleColor.Cyan);

            //Artifical Repeater
            long hothander = 0;

            MainThread.MessagePoster.HotMsg hmsg = new MainThread.MessagePoster.HotMsg();
            for (int i = 0; i < Manager.mHot.data.Count; i++)
            {
                hmsg = (MainThread.MessagePoster.HotMsg)Manager.mHot.data[i];
                if (hmsg.group == e.FromGroup.Id)
                {
                    hhmsg = hmsg; hIndex = i; break;
                }
            }
            string fstr = ""; string estr = ""; string[] qtemp;

            for (int i = 0; i < Manager.Hots.data.Count; i++)
            {
nexthmsg:
                if (i >= Manager.Hots.data.Count)
                {
                    break;
                }
                hmsg = (MainThread.MessagePoster.HotMsg)Manager.Hots.data[i];
                //是否在目标群
                if (hmsg.group == e.FromGroup.Id)
                {
                    if (hmsg.delaymsg) //延迟复读
                    {
                        if (hmsg.hasre == false)
                        {
                            Log("(" + e.FromGroup.Id + ")(" + i + ")Delay repeat:" + hmsg.msg, ConsoleColor.Yellow);
                            e.FromGroup.SendGroupMessage(hmsg.msg);
                            hmsg.delaymsg = false; hmsg.hasre = true;
                            Log("(" + e.FromGroup.Id + ")(" + i + ")Conntinue-repeat:" + hmsg.delaymsg, ConsoleColor.Yellow);
                        }
                    }
                    if (e.Message.Text != hmsg.msg)
                    {
                        hmsg.hot--;
                    }                                              //如果当前的发言和上句发言不同,上句发言热度-1
                    //如果当前的发言和上句发言一直,上句发言热度+1
                    if (e.Message.Text == hmsg.msg)
                    {
                        hothander = hmsg.id;
                        // 不是同一个QQ在刷屏
                        if (hmsg.qq.IndexOf(e.FromQQ.Id.ToString() + ";") < 0)
                        {
                            Log("(" + e.FromGroup.Id + ")(" + i + ")Heat:" + hmsg.msg + " , hot :" + hmsg.hot);
                            hmsg.hasup = true;
                            hmsg.qq    = hmsg.qq + e.FromQQ.Id.ToString() + ";";
                            Log("(" + e.FromGroup.Id + ")(" + i + ")Members:" + hmsg.qq);
                            hmsg.hot++;
                            if (hIndex > -1)
                            {
                                if (hmsg.hot >= hhmsg.hot)
                                {
                                    hhmsg = hmsg; hhmsg.hasup = false;
                                    Manager.mHot.data[hIndex] = hhmsg;
                                    Log("(" + e.FromGroup.Id + ")(" + i + ")Broke records! :" + hmsg.qq + "," + hmsg.msg, ConsoleColor.Green);
                                }
                            }
                            else
                            {
                                hhmsg = hmsg; hhmsg.hasup = false;
                                Manager.mHot.data.Add(hhmsg);
                            }
                        }
                        else
                        {
                            hmsg.banqq = hmsg.banqq + e.FromQQ.Id.ToString() + ";";
                            int bancount = GotCount(hmsg.banqq, e.FromQQ.Id.ToString());
                            Log("(" + e.FromGroup.Id + ")(" + i + ")Boring-repeat:" + e.FromQQ.Id + " x " + bancount, ConsoleColor.Red);
                            if (bancount > 2)
                            {
                                if (e.FromGroup.Id != 490623220)
                                {
                                    TimeSpan bantime = new TimeSpan(0, 2, 33);
                                    e.FromGroup.SetGroupMemberBanSpeak(Convert.ToInt64(e.FromQQ.Id), bantime);
                                }
                                e.FromGroup.SendGroupMessage(CQApi.CQCode_At(e.FromQQ.Id), "不许刷屏");
                                Log("(" + e.FromGroup.Id + ")(" + i + ")This human is too too boring:" + e.FromQQ.Id, ConsoleColor.Red);
                            }
                        }
                    }
                    //如果发言冷却,移除
                    if (hmsg.hot <= -2)
                    {
                        if (hmsg.hasup)
                        {
                            Log("(" + e.FromGroup.Id + ")(" + i + ")Disapper repeat:" + hmsg.msg, ConsoleColor.Red);
                        }
                        Manager.Hots.data.RemoveAt(i); goto nexthmsg;
                    }
                    //发言热度越高,越容易引发复读
                    if (r.Next(0, 100) > 100 - hmsg.hot * 20 * (hmsg.hot / 2))
                    {
                        hmsg.delaymsg = (r.Next(0, 10) > 6); //设置延迟一回合
                        hothander     = hmsg.id;
                        if (!hmsg.delaymsg)
                        {
                            if (hmsg.hasre == false)
                            {
                                Log("(" + e.FromGroup.Id + ")(" + i + ")Repeat:" + hmsg.msg + ",impossible:" + (100 - hmsg.hot * 20 * (hmsg.hot / 2)), ConsoleColor.Yellow);
                                e.FromGroup.SendGroupMessage(hmsg.msg);
                                hmsg.hasre = true;
                            }
                        }
                        else
                        {
                            Log("(" + e.FromGroup.Id + ")(" + i + ")Delay set:" + hmsg.msg, ConsoleColor.Yellow);
                        }
                    }
                    if (i >= Manager.Hots.data.Count)
                    {
                        break;
                    }
                    Manager.Hots.data[i] = hmsg;
                }
            }
            //如果当前发言没有被处理,则加入新热点
            if (hothander == 0)
            {
                hmsg.group = e.FromGroup.Id; hmsg.msg = e.Message.Text; hmsg.hot = 1; hmsg.delaymsg = false;
                hmsg.qq    = e.FromQQ.Id.ToString() + ";"; hmsg.banqq = ""; hmsg.id = DateTime.Now.Ticks;
                hmsg.hasup = false; hmsg.hasre = false;
                Manager.Hots.data.Add(hmsg);
            }
            else
            {
                if (hIndex > -1)
                {
                    if (hhmsg.id == hmsg.id)
                    {
                        hhmsg = hmsg; hhmsg.hasup = false;
                        Manager.mHot.data[hIndex] = hhmsg;
                        Log("(" + e.FromGroup.Id + ")Stay breaking record ...", ConsoleColor.Green);
                    }
                }
            }

            //Random Topic
            string tsay = "";

            if (e.Message.Text.IndexOf("[CQ:") < 0)
            {
                if ((r.Next(0, 100) == 50) || (FailAI == true))
                {
                    try
                    {
                        tsay = ArtificalAI.Talk(e.Message.Text, "tieba");
                        if (tsay == "")
                        {
                            FailAI = true;
                        }
                        else
                        {
                            string[] tsa = tsay.Split('。');
                            FailAI = false; e.FromGroup.SendGroupMessage(tsa[r.Next(0, tsa.Length)]);
                        }
                    }
                    catch
                    {
                        FailAI = true;
                    }
                }
            }

            //Lock Processing
            sid = Manager.LCards.SearchFor(e.FromQQ.Id);
            if (sid != -1)
            {
                Log("Lock target:" + sid, ConsoleColor.Yellow);
                string tname = Manager.LCards.data[sid + 1].ToString();
                if (e.FromQQ.CQApi.GetGroupMemberInfo(e.FromGroup.Id, e.FromQQ.Id, false).Card != tname)
                {
                    if (e.FromGroup.SetGroupMemberVisitingCard(e.FromQQ.Id, tname))
                    {
                        e.FromGroup.SendGroupMessage(CQApi.CQCode_At(e.FromQQ.Id), "检测到您的群名片与主人设定的群名片不相符,已强制修正为:", tname);
                    }
                    else
                    {
                        e.FromGroup.SendGroupMessage(CQApi.CQCode_At(1361778219), "强制修正目标群员的群名片失败,可能本机没有权限操作。");
                    }
                }
                return;
            }

            //Console Processing
            PermissionName pe = PermissionName.AirPermission; string pename = "";

            if (e.Message.Text.StartsWith("intallk"))
            {
                sid = Manager.CPms.SearchFor(e.FromQQ.Id);
                if (e.FromGroup == 490623220)
                {
                    if (sid == -1)
                    {
                        Manager.CPms.data.Add(e.FromQQ.Id);
                        Manager.CPms.data.Add(PermissionName.UserPermission);
                        Manager.CPms.SaveData();
                        e.FromGroup.SendGroupMessage(CQApi.CQCode_At(e.FromQQ.Id), "您已通过此群的特殊地位拿到访问权限:User");
                        sid = Manager.CPms.SearchFor(e.FromQQ.Id);
                    }
                }
                if (sid == -1)
                {
                    e.FromGroup.SendGroupMessage(CQApi.CQCode_At(e.FromQQ.Id), "您没有任何权限,禁止访问Intallk QQ机器人控制台。");
                    return;
                }

                try
                {
                    pe     = (PermissionName)Convert.ToInt64(Manager.CPms.data[sid + 1].ToString());
                    pename = GetPermissionName(pe);
                    string[] p = e.Message.Text.Split(' ');
                    if (p.Length < 2)
                    {
                        string cmdstr = "";
                        if (CanMatch(e.Message.Text, "msdn", "搜索", "资料", "文档", "国外", "微软", "巨硬", "microsoft"))
                        {
                            cmdstr += "*msdn [content]] 检索msdn并返回页面内容(容易失败)\n";
                        }
                        if (CanMatch(e.Message.Text, "csdn", "搜索", "资料", "文档", "国内"))
                        {
                            cmdstr += "csdn [content] 检索csdn并返回页面内容(阅读效果不佳)\n";
                        }
                        if (CanMatch(e.Message.Text, "壁纸", "桌面", "背景", "图片", "风景"))
                        {
                            cmdstr += "wallpaper 获取一张随机桌面壁纸\n";
                        }
                        if (CanMatch(e.Message.Text, "404", "睡觉", "晚安", "关机", "强制"))
                        {
                            cmdstr += "#forcesleep 强制设定404的电脑在2分钟后关机\n";
                        }
                        if (CanMatch(e.Message.Text, "管理", "禁言", "违规", "刷屏", "shit"))
                        {
                            cmdstr += "*ban [qq] [time] 设定群成员禁言(分钟)\n";
                        }
                        if (CanMatch(e.Message.Text, "管理", "禁言", "违规", "刷屏", "shit", "全员", "所有人"))
                        {
                            cmdstr += "*allban [bool] 开关全体禁言\n";
                        }
                        if (CanMatch(e.Message.Text, "管理", "危险", "祝福", "超级", "问候", "全员", "所有人"))
                        {
                            cmdstr += "#supergoodnight [content] 将所有成员艾特一遍发送指定消息\n";
                        }
                        if (CanMatch(e.Message.Text, "管理", "危险", "祝福", "超级", "问候", "全员", "所有人"))
                        {
                            cmdstr += "#supergoodnightfancy♂ [content] 将所有成员私聊一遍发送指定消息\n";
                        }
                        if (CanMatch(e.Message.Text, "管理", "新", "任命", "我要", "提权", "权限", "地位"))
                        {
                            cmdstr += "#manager [qq] 设置新的管理员\n";
                        }
                        if (CanMatch(e.Message.Text, "管理", "撤", "罢免", "我要", "降权", "权限", "地位"))
                        {
                            cmdstr += "#unmanager [qq] 解除管理员\n";
                        }
                        if (CanMatch(e.Message.Text, "permission", "令牌", "修改", "系统", "更改", "权限", "地位"))
                        {
                            cmdstr += "!permission [qq] [pid] 设置权限\n";
                        }
                        if (CanMatch(e.Message.Text, "聊天", "无逻辑", "无聊", "百度", "搜索", "骚"))
                        {
                            cmdstr += "talk [content] 无逻辑谈话(百度贴吧)\n";
                        }
                        if (CanMatch(e.Message.Text, "聊天", "无逻辑", "无聊", "百度", "搜索", "骚"))
                        {
                            cmdstr += "talk_old [content] 无逻辑谈话(百度知道)\n";
                        }


                        e.FromGroup.SendGroupMessage(CQApi.CQCode_At(e.FromQQ.Id), "关于黑嘴Intallk稽气人(1.4.6),垃圾臭狗机器人的同义词。\n制作:Error 404(QQ1361778219)\nGithub地址:https://github.com/buger404\nPowered by CoolQ\n\n支持的指令:\n" +
                                                     "(无标注的指令至少需要User权限,*至少需要Superman权限,#至少需要Master权限,!至少需要Heaven权限)\n" +
                                                     "***您当前所持权限:" + pename + "(级别:" + Convert.ToInt64(pe) + ")***\n" +
                                                     "*honor [content] 给予自己永久头衔\n" +
                                                     "*praise 为自己发送10个赞\n" +
                                                     "*lockcard [qq] [name] 检测到指定全员名片与设定不符时自动修改\n" +
                                                     "pop 输出今日本群最热发言\n" +
                                                     "其他功能:智能复读,刷屏检测,自主发言等。");
                        return;
                    }
                    switch (p[1])
                    {
                    case ("pop"):
                        if (hIndex > -1)
                        {
                            qtemp = hhmsg.banqq.Split(';');
                            for (int i = 0; i < qtemp.Length - 1; i++)
                            {
                                estr = estr + CQApi.CQCode_At(Convert.ToInt64(qtemp[i]));
                            }
                            qtemp = hhmsg.qq.Split(';');
                            for (int i = 0; i < qtemp.Length - 1; i++)
                            {
                                fstr = fstr + CQApi.CQCode_At(Convert.ToInt64(qtemp[i]));
                            }
                            e.FromGroup.SendGroupMessage("截止刚才,本群今日最热发言:\n" + hhmsg.msg + "\n复读发起人:" + CQApi.CQCode_At(Convert.ToInt64(qtemp[0])) + "\n复读热度:" + hhmsg.hot + "\n该热度发言被这些成员复读过:" + fstr + "\n在该热度发言发起时,这些成员太过激动试图刷屏:" + estr);
                        }
                        else
                        {
                            e.FromGroup.SendGroupMessage("截止刚才我群今日暂无最热发言。");
                        }
                        break;

                    case ("msdn"):
                        //msdn searching
                        if (pe < PermissionName.SupermanPermission)
                        {
                            e.FromGroup.SendGroupMessage(CQApi.CQCode_At(e.FromQQ.Id), "您当前持有的权限'" + pename + "'(级别" + Convert.ToInt64(pe) + ")不足以访问该指令。"); return;
                        }
                        if (p.Length < 2)
                        {
                            throw new Exception("'" + p[1] + "'所给的参数个数不正确");
                        }
                        e.FromGroup.SendGroupMessage(CQApi.CQCode_At(e.FromQQ.Id), "该功能正在回炉改造中..."); return;

                        for (int i = 2; i < p.Length; i++)
                        {
                            ques = ques + p[i] + " ";
                        }
                        e.FromGroup.SendGroupMessage(CQApi.CQCode_At(e.FromQQ.Id) + "\n" + ArtificalAI.Talk(ques, "msdn"));
                        break;

                    case ("csdn"):
                        //csdn searching
                        if (pe < PermissionName.UserPermission)
                        {
                            e.FromGroup.SendGroupMessage(CQApi.CQCode_At(e.FromQQ.Id), "您当前持有的权限'" + pename + "'(级别" + Convert.ToInt64(pe) + ")不足以访问该指令。"); return;
                        }
                        e.FromGroup.SendGroupMessage(CQApi.CQCode_At(e.FromQQ.Id), "该功能正在回炉改造中..."); return;

                        if (p.Length < 2)
                        {
                            throw new Exception("'" + p[1] + "'所给的参数个数不正确");
                        }
                        for (int i = 2; i < p.Length; i++)
                        {
                            ques = ques + p[i] + " ";
                        }
                        e.FromGroup.SendGroupMessage(CQApi.CQCode_At(e.FromQQ.Id) + "\n" + ArtificalAI.Talk(ques, "csdn"));
                        break;

                    case ("wallpaper"):
                        if (pe < PermissionName.UserPermission)
                        {
                            e.FromGroup.SendGroupMessage(CQApi.CQCode_At(e.FromQQ.Id), "您当前持有的权限'" + pename + "'(级别" + Convert.ToInt64(pe) + ")不足以访问该指令。"); return;
                        }
                        e.FromGroup.SendGroupMessage(CQApi.CQCode_At(e.FromQQ.Id) + "您喜欢这个壁纸吗?\n" + Wallpaper.GetWallpaper());
                        break;

                    case ("forcesleep"):
                        if (pe < PermissionName.MasterPermission)
                        {
                            e.FromGroup.SendGroupMessage(CQApi.CQCode_At(e.FromQQ.Id), "您当前持有的权限'" + pename + "'(级别" + Convert.ToInt64(pe) + ")不足以访问该指令。"); return;
                        }
                        e.FromGroup.SendGroupMessage(CQApi.CQCode_At(1361778219), " 滚去睡觉吧!");
                        ShellExecute(IntPtr.Zero, "open", @"shutdown", "-s -t 120", "", ShowCommands.SW_SHOWNORMAL);
                        break;

                    case ("ban"):
                        if (pe < PermissionName.SupermanPermission)
                        {
                            e.FromGroup.SendGroupMessage(CQApi.CQCode_At(e.FromQQ.Id), "您当前持有的权限'" + pename + "'(级别" + Convert.ToInt64(pe) + ")不足以访问该指令。"); return;
                        }
                        if (p.Length < 3)
                        {
                            throw new Exception("'" + p[1] + "'所给的参数个数不正确");
                        }
                        qq = Convert.ToDouble(p[2]);
                        TimeSpan ctime = new TimeSpan(0, Convert.ToInt16(p[3]), 0);
                        if (e.FromGroup.SetGroupMemberBanSpeak(Convert.ToInt64(qq), ctime))
                        {
                            e.FromGroup.SendGroupMessage(CQApi.CQCode_At(e.FromQQ.Id), "禁言目标成员成功。");
                        }
                        else
                        {
                            e.FromGroup.SendGroupMessage(CQApi.CQCode_At(e.FromQQ.Id), "禁言目标成员失败,可能本机没有权限。");
                        }
                        break;

                    case ("allban"):
                        if (pe < PermissionName.SupermanPermission)
                        {
                            e.FromGroup.SendGroupMessage(CQApi.CQCode_At(e.FromQQ.Id), "您当前持有的权限'" + pename + "'(级别" + Convert.ToInt64(pe) + ")不足以访问该指令。"); return;
                        }
                        bool bswitch = Convert.ToBoolean(p[2]);
                        if (bswitch)
                        {
                            if (e.FromGroup.SetGroupBanSpeak())
                            {
                                e.FromGroup.SendGroupMessage(CQApi.CQCode_At(e.FromQQ.Id), "禁言全体成员成功。");
                            }
                            else
                            {
                                e.FromGroup.SendGroupMessage(CQApi.CQCode_At(e.FromQQ.Id), "禁言全体成员失败,可能本机没有权限。");
                            }
                        }
                        else
                        {
                            e.FromGroup.RemoveGroupBanSpeak();
                            e.FromGroup.SendGroupMessage(CQApi.CQCode_At(e.FromQQ.Id), "解禁全体成员成功。");
                        }
                        break;

                    case ("manager"):
                        if (pe < PermissionName.MasterPermission)
                        {
                            e.FromGroup.SendGroupMessage(CQApi.CQCode_At(e.FromQQ.Id), "您当前持有的权限'" + pename + "'(级别" + Convert.ToInt64(pe) + ")不足以访问该指令。"); return;
                        }
                        qq = Convert.ToDouble(p[2]);
                        e.FromGroup.SetGroupManage(Convert.ToInt64(qq));
                        e.FromGroup.SendGroupMessage(CQApi.CQCode_At(Convert.ToInt64(qq)), "您已被授予管理员。");
                        break;

                    case ("unmanager"):
                        if (pe < PermissionName.MasterPermission)
                        {
                            e.FromGroup.SendGroupMessage(CQApi.CQCode_At(e.FromQQ.Id), "您当前持有的权限'" + pename + "'(级别" + Convert.ToInt64(pe) + ")不足以访问该指令。"); return;
                        }
                        qq = Convert.ToDouble(p[2]);
                        e.FromGroup.RemoveGroupManage(Convert.ToInt64(qq));
                        e.FromGroup.SendGroupMessage(CQApi.CQCode_At(Convert.ToInt64(qq)), "您的管理员宝座被移除。");
                        break;

                    case ("supergoodnightfancy♂"):
                        if (pe < PermissionName.MasterPermission)
                        {
                            e.FromGroup.SendGroupMessage(CQApi.CQCode_At(e.FromQQ.Id), "您当前持有的权限'" + pename + "'(级别" + Convert.ToInt64(pe) + ")不足以访问该指令。"); return;
                        }
                        if (p.Length < 2)
                        {
                            throw new Exception("'" + p[1] + "'所给的参数个数不正确");
                        }
                        mem = e.FromGroup.GetGroupMemberList();
                        for (int i = 0; i < mem.Count; i++)
                        {
                            mem[i].QQ.SendPrivateMessage(p[2]);
                            Log("Wish:" + i, ConsoleColor.Yellow);
                            //e.FromGroup.SendGroupMessage(atstr, p[2]);
                            Thread.Sleep(500);
                        }
                        break;

                    case ("supergoodnight"):
                        if (pe < PermissionName.MasterPermission)
                        {
                            e.FromGroup.SendGroupMessage(CQApi.CQCode_At(e.FromQQ.Id), "您当前持有的权限'" + pename + "'(级别" + Convert.ToInt64(pe) + ")不足以访问该指令。"); return;
                        }
                        string atstr = "";
                        if (p.Length < 2)
                        {
                            throw new Exception("'" + p[1] + "'所给的参数个数不正确");
                        }
                        mem = e.FromGroup.GetGroupMemberList();
                        for (int i = 0; i < mem.Count; i += 10)
                        {
                            atstr = "";
                            for (int s = i; s < i + 10; s++)
                            {
                                Log("Wish:" + s, ConsoleColor.Yellow);
                                if (s > mem.Count)
                                {
                                    break;
                                }
                                atstr = atstr + CQApi.CQCode_At(mem[s].QQ.Id);
                            }
                            e.FromGroup.SendGroupMessage(atstr, p[2]);
                            Thread.Sleep(3000);
                        }
                        break;

                    case ("permission"):
                        if (pe < PermissionName.HeavenPermission)
                        {
                            e.FromGroup.SendGroupMessage(CQApi.CQCode_At(e.FromQQ.Id), "您当前持有的权限'" + pename + "'(级别" + Convert.ToInt64(pe) + ")不足以访问该指令。"); return;
                        }
                        qq  = Convert.ToDouble(p[2]);
                        sid = Manager.CPms.SearchFor(qq);
                        if (sid != -1)
                        {
                            Manager.CPms.data[sid + 1] = p[3];
                            Manager.CPms.SaveData();
                            pe = (PermissionName)Convert.ToInt64(p[3]);
                            e.FromGroup.SendGroupMessage(CQApi.CQCode_At(e.FromQQ.Id), "\n" +
                                                         CQApi.CQCode_At(Convert.ToInt64(qq)) + "的权限已经更新。\n" +
                                                         "权限:" + GetPermissionName(pe) + "(级别:" + Convert.ToInt64(pe) + ")\n" +
                                                         "权限编号:" + sid + "\n");
                        }
                        else
                        {
                            Manager.CPms.data.Add(qq);
                            Manager.CPms.data.Add(PermissionName.UserPermission);
                            Manager.CPms.SaveData();
                            sid = Manager.CPms.SearchFor(qq);
                            e.FromGroup.SendGroupMessage(CQApi.CQCode_At(e.FromQQ.Id),
                                                         "成功给予" + CQApi.CQCode_At(Convert.ToInt64(qq)) + "权限!\n" +
                                                         "权限编号:" + sid);
                        }
                        break;

                    case ("honor"):
                        if (pe < PermissionName.SupermanPermission)
                        {
                            e.FromGroup.SendGroupMessage(CQApi.CQCode_At(e.FromQQ.Id), "您当前持有的权限'" + pename + "'(级别" + Convert.ToInt64(pe) + ")不足以访问该指令。"); return;
                        }
                        if (p.Length < 2)
                        {
                            throw new Exception("'" + p[1] + "'所给的参数个数不正确");
                        }
                        if (e.FromQQ.SetGroupMemberForeverExclusiveTitle(e.FromGroup.Id, p[2]) == false)
                        {
                            throw new Exception("设置您的专属头衔失败,可能没有权限");
                        }
                        e.FromGroup.SendGroupMessage(CQApi.CQCode_At(e.FromQQ.Id), "设置成功!");
                        break;

                    case ("praise"):
                        if (pe < PermissionName.SupermanPermission)
                        {
                            e.FromGroup.SendGroupMessage(CQApi.CQCode_At(e.FromQQ.Id), "您当前持有的权限'" + pename + "'(级别" + Convert.ToInt64(pe) + ")不足以访问该指令。"); return;
                        }
                        if (e.FromQQ.SendPraise(10) == false)
                        {
                            throw new Exception("点赞失败");
                        }
                        e.FromGroup.SendGroupMessage(CQApi.CQCode_At(e.FromQQ.Id), "成功为您刷入十个赞");
                        break;

                    case ("talk"):
                        if (pe < PermissionName.UserPermission)
                        {
                            e.FromGroup.SendGroupMessage(CQApi.CQCode_At(e.FromQQ.Id), "您当前持有的权限'" + pename + "'(级别" + Convert.ToInt64(pe) + ")不足以访问该指令。"); return;
                        }
                        if (p.Length < 2)
                        {
                            throw new Exception("'" + p[1] + "'所给的参数个数不正确");
                        }
                        for (int i = 2; i < p.Length; i++)
                        {
                            ques = ques + p[i] + " ";
                        }
                        tsay = ArtificalAI.Talk(ques, "tieba");
                        if (tsay != "")
                        {
                            e.FromGroup.SendGroupMessage(CQApi.CQCode_At(e.FromQQ.Id) + tsay);
                        }
                        else
                        {
                            e.FromGroup.SendGroupMessage(CQApi.CQCode_At(e.FromQQ.Id) + "怀疑超出人类认知范围。");
                        }
                        break;

                    case ("talk_old"):
                        if (pe < PermissionName.UserPermission)
                        {
                            e.FromGroup.SendGroupMessage(CQApi.CQCode_At(e.FromQQ.Id), "您当前持有的权限'" + pename + "'(级别" + Convert.ToInt64(pe) + ")不足以访问该指令。"); return;
                        }
                        if (p.Length < 2)
                        {
                            throw new Exception("'" + p[1] + "'所给的参数个数不正确");
                        }
                        for (int i = 2; i < p.Length; i++)
                        {
                            ques = ques + p[i] + " ";
                        }
                        tsay = ArtificalAI.Talk(ques, "baidu");
                        if (tsay != "")
                        {
                            e.FromGroup.SendGroupMessage(CQApi.CQCode_At(e.FromQQ.Id) + tsay);
                        }
                        else
                        {
                            e.FromGroup.SendGroupMessage(CQApi.CQCode_At(e.FromQQ.Id) + "怀疑超出人类认知范围。");
                        }
                        break;

                    case ("lockcard"):
                        if (pe < PermissionName.SupermanPermission)
                        {
                            e.FromGroup.SendGroupMessage(CQApi.CQCode_At(e.FromQQ.Id), "您当前持有的权限'" + pename + "'(级别" + Convert.ToInt64(pe) + ")不足以访问该指令。"); return;
                        }
                        if (p.Length < 3)
                        {
                            throw new Exception("'" + p[1] + "'所给的参数个数不正确");
                        }
                        qq  = Convert.ToDouble(p[2]); string lname = p[3];
                        sid = Manager.LCards.SearchFor(qq);
                        if (sid != -1)
                        {
                            e.FromGroup.SendGroupMessage(CQApi.CQCode_At(e.FromQQ.Id), CQApi.CQCode_At(Convert.ToInt64(qq)),
                                                         "目标成员的群名片已经被锁定过了。\n" +
                                                         "锁定地址:" + sid +
                                                         "\n上次锁定的名片:" + Manager.LCards.data[sid + 1] +
                                                         "\n已修改锁定的名片为当前新设定的名片。");
                            Manager.LCards.data[sid + 1] = lname;
                            Manager.LCards.SaveData();
                        }
                        else
                        {
                            Manager.LCards.data.Add(qq);
                            Manager.LCards.data.Add(lname);
                            Manager.LCards.SaveData();
                            sid = Manager.LCards.SearchFor(qq);
                            e.FromGroup.SendGroupMessage(CQApi.CQCode_At(e.FromQQ.Id), CQApi.CQCode_At(Convert.ToInt64(qq)),
                                                         "锁定目标成员的群名片成功!\n" +
                                                         "锁定地址:" + sid +
                                                         "\n锁定的名片:" + Manager.LCards.data[sid + 1]);
                        }
                        break;

                    default:
                        e.FromGroup.SendGroupMessage(CQApi.CQCode_At(e.FromQQ.Id),
                                                     "'" + p[1] + "'不是有效的指令");
                        break;
                    }
                }
                catch (Exception err)
                {
                    if (e.FromGroup == 490623220)
                    {
                        string[] statemp = err.StackTrace.Split('在');
                        e.FromGroup.SendGroupMessage(CQApi.CQCode_At(1361778219),
                                                     "异常描述:" + err.Message +
                                                     "\n顶异常堆栈:" + statemp[statemp.Length - 1] +
                                                     "\n导致异常的指令:" + e.Message.Text);
                    }
                    else
                    {
                        e.FromGroup.SendGroupMessage(CQApi.CQCode_At(e.FromQQ.Id),
                                                     "给予的指令可能错误。\n异常描述:" + err.Message +
                                                     "\n请联系QQ1361778219取得解决方案");
                    }
                }
                return;
            }

            //throw new NotImplementedException();
        }
Пример #20
0
        public void Command(CQGroupMessageEventArgs e)
        {
            if (!e.Message.Text.StartsWith("."))
            {
                return;
            }
            #region Command Text Convert
            string[] r  = e.Message.Text.Split(new string[] { "[CQ:at,qq=" }, StringSplitOptions.None);
            string   re = "";
            if (r.Length > 1)
            {
                for (int i = 0; i < r[1].Length; i++)
                {
                    if (r[1][i] == ']')
                    {
                        r[1] = r[1].Remove(i, 1); break;
                    }
                }
                re = r[0] + r[1];
            }
            else
            {
                re = e.Message.Text;
            }
            string[] p = re.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            #endregion
            #region Command Recording
            DT.log("intallk-command", e.FromGroup.Id + "\\" + e.FromQQ.Id + ":" + re);
            #endregion

            #region Information Command
            if (p[0] == ".bark" && DT.pm(e.FromQQ.Id, 0))
            {
                e.FromGroup.SendGroupMessage("汪");
            }
            if (p[0] == ".help")
            {
                e.FromGroup.SendGroupMessage("https://buger404.gitee.io/web/blog.html?article=intallk-guidence");
            }
            if (p[0] == ".lic")
            {
                e.FromGroup.SendGroupMessage("https://buger404.gitee.io/web/blog.html?article=intallk-license");
            }
            if (p[0] == ".pms")
            {
                if (p.Length == 1)
                {
                    e.FromGroup.SendGroupMessage(DT.pmi(e.FromQQ.Id));
                }
                if (p.Length == 2)
                {
                    e.FromGroup.SendGroupMessage(DT.pmi(long.Parse(p[1])));
                }
                if (p.Length == 3)
                {
                    if (DT.pmc(e.FromQQ.Id, long.Parse(p[1])))
                    {
                        if (int.Parse(p[2]) >= DT.pmi(e.FromQQ.Id))
                        {
                            e.FromGroup.SendGroupMessage(e.FromQQ.CQCode_At(), "不能给予目标比自身高的权限");
                        }
                        else
                        {
                            DT.pms["q" + p[1], "permission"] = int.Parse(p[2]);
                            e.FromGroup.SendGroupMessage(e.FromQQ.CQCode_At(), "成功更新目标权限");
                        }
                    }
                    else
                    {
                        e.FromGroup.SendGroupMessage(e.FromQQ.CQCode_At(), "您的权限必须高于目标对象");
                    }
                }
            }
            #endregion
            #region Repeat Record Command
            if (p[0] == ".ws" && DT.pm(e.FromQQ.Id, 0))
            {
                if (p.Length == 1)
                {
                    e.FromGroup.SendGroupMessage("共" + DT.re["count"] + "条语录");
                }
                if (p.Length == 2)
                {
                    e.FromGroup.SendGroupMessage("对象共有" + DT.re["q" + p[1], "count"] + "条语录");
                }
            }
            if (p[0] == ".w" && DT.pm(e.FromQQ.Id, 0))
            {
                if (p.Length == 1)
                {
                    List <DataCenter.DataItem> dl = DT.re.di.FindAll(m => m.name != "count");
                    DataCenter.DataItem        d  = dl[ran.Next(0, dl.Count)];
                    e.FromGroup.SendGroupMessage(
                        CQApi.CQCode_At(long.Parse(d.group.Remove(0, 1))), ":", d.var.ToString()
                        );
                }
                if (p.Length == 2)
                {
                    int ind = 0, exc = int.Parse(p[1]);
                    for (int i = 0; i < DT.re.di.Count; i++)
                    {
                        if (DT.re.di[i].name != "count")
                        {
                            ind++;
                        }
                        if (ind == exc)
                        {
                            e.FromGroup.SendGroupMessage(
                                CQApi.CQCode_At(long.Parse(DT.re.di[i].group.Remove(0, 1))), ":", DT.re.di[i].var.ToString()
                                );
                        }
                    }
                }
            }
            if (p[0] == ".wp" && DT.pm(e.FromQQ.Id, 0))
            {
                if (p.Length == 2)
                {
                    int index = ran.Next(1, (int)DT.re["q" + p[1], "count"] + 1);
                    e.FromGroup.SendGroupMessage(
                        CQApi.CQCode_At(long.Parse(p[1])), ":", DT.re["q" + p[1], index.ToString()].ToString()
                        );
                }
                if (p.Length == 3)
                {
                    e.FromGroup.SendGroupMessage(
                        CQApi.CQCode_At(long.Parse(p[1])), ":", DT.re["q" + p[1], p[2]].ToString()
                        );
                }
            }
            if (p[0] == ".wse" && DT.pm(e.FromQQ.Id, 0))
            {
                if (p.Length == 2)
                {
                    List <DataCenter.DataItem> dl = DT.re.di.FindAll(m => m.name != "count" && m.var.ToString().ToLower().Contains(p[1].ToLower()));
                    DataCenter.DataItem        d  = dl[ran.Next(0, dl.Count)];
                    e.FromGroup.SendGroupMessage(
                        CQApi.CQCode_At(long.Parse(d.group.Remove(0, 1))), ":", d.var.ToString()
                        );
                }
                if (p.Length == 3)
                {
                    List <DataCenter.DataItem> dl = DT.re.di.FindAll(m => m.name != "count" && m.group == "q" + p[2] && m.var.ToString().ToLower().Contains(p[1].ToLower()));
                    DataCenter.DataItem        d  = dl[ran.Next(0, dl.Count)];
                    e.FromGroup.SendGroupMessage(
                        CQApi.CQCode_At(long.Parse(d.group.Remove(0, 1))), ":", d.var.ToString()
                        );
                }
            }
            if (p[0] == ".t" && DT.pm(e.FromQQ.Id, 0))
            {
                string o = "";
                foreach (Msg m in mq.FindAll(m => m.group == e.FromGroup.Id))
                {
                    if (m.repeaters != "")
                    {
                        string n = "";
                        foreach (string qqs in m.repeaters.Split(';'))
                        {
                            if (qqs != "")
                            {
                                n += GetGroupCard(long.Parse(qqs), e.FromGroup) + ",";
                            }
                        }
                        o += "(复读者:" + n + ")\n" + m.content + "\n";
                    }
                    else
                    {
                        o += "(" + GetGroupCard(m.qq, e.FromGroup) + ")\n" + m.content + "\n";
                    }
                }
                o = o.Replace("[CQ:at,", "[艾特,").Replace("[CQ:image,", "[图片,");
                o = o.Replace("[CQ:,", "[操作:");
                e.FromQQ.SendPrivateMessage(o);
                e.FromGroup.SendGroupMessage(e.FromQQ.CQCode_At(), "私聊查收");
            }
            #endregion
            #region Debug Command
            if (p[0] == ".or")
            {
                string o = "";
                for (int i = 0; i < e.Message.Text.Length; i++)
                {
                    o += e.Message.Text[i] + " ";
                }
                e.FromGroup.SendGroupMessage(o);
            }
            if (p[0] == ".fea")
            {
                e.FromGroup.SendGroupMessage(re);
            }
            if (p[0] == ".cmd")
            {
                string o = "param.length = " + p.Length + "\n";
                for (int i = 0; i < p.Length; i++)
                {
                    o += "p[" + i + "] = " + p[i] + "\n";
                }
                e.FromGroup.SendGroupMessage(o);
            }
            if (p[0] == ".elog" && DT.pm(e.FromQQ.Id, 0))
            {
                Exception err = errlog[int.Parse(p[1])];
                e.FromQQ.SendPrivateMessage(err.Message);
                e.FromQQ.SendPrivateMessage(err.StackTrace);
                e.FromQQ.SendPrivateMessage(err.Source);
                string o = "";
                if (err.Data.Count > 0)
                {
                    foreach (DictionaryEntry de in err.Data)
                    {
                        o += de.Key.ToString() + ":" + de.Value + "\n";
                    }
                }
                e.FromQQ.SendPrivateMessage(o);
                e.FromGroup.SendGroupMessage(e.FromQQ.CQCode_At(), "私聊查收");
            }
            if (p[0] == ".save" && DT.pm(e.FromQQ.Id, 32767))
            {
                DT.pms.Write(); DT.sw.Write(); DT.bm.Write(); DT.re.Write();
                e.FromGroup.SendGroupMessage(e.FromQQ.CQCode_At(), "成功");
            }
            #endregion
        }
Пример #21
0
        public void GroupMessage(object sender, CQGroupMessageEventArgs e)
        {
            int            gunInArmoy;
            int            rand;
            userManager    userManager    = new userManager("F:\\CoolQAir\\dev\\com.girlsfrontline.demo\\UserInfo.xml");
            Filter         filter         = new Filter("F:\\CoolQAir\\dev\\com.girlsfrontline.demo\\filterRule.xml");
            CharacterLoder characterLoder = new CharacterLoder("F:\\CoolQAir\\dev\\com.girlsfrontline.demo\\Guns.xml");

            gunInArmoy = characterLoder.NumOfCharacter();

            if (e.Message.Text.StartsWith("添加卡牌"))
            {
                //添加卡片 姓名 星级 留言

                if (Regex.IsMatch(CQApi.CQDeCode(e.Message.Text),
                                  @"^\w+\s[a-zA-z0-9()\-[!.\u4E00-\u9FA5]+\s\d\s[a-zA-z0-9()\-[!.\u4E00-\u9FA5]") == false || filter.Wordfilter(e.Message.Text) == false)
                {
                    e.FromGroup.SendGroupMessage("加入失败");
                    return;
                }

                string[] info = CQApi.CQDeCode(e.Message.Text).Split(new char[] { ' ' }, options: StringSplitOptions.RemoveEmptyEntries);
                foreach (string ele in info)
                {
                    if (ele == null)
                    {
                        return;
                    }
                }

                string name    = info[1];
                string rank    = info[2];
                string message = info[3];

                int ans = characterLoder.AddCard(name, rank, message);

                if (ans != 0 && filter.Rankfilter(rank))
                {
                    e.FromGroup.SendGroupMessage("加入成功,效能赋值:", ans);
                }
                else
                {
                    e.FromGroup.SendGroupMessage("加入失败");
                }
            }

            if (e.Message.Text.Equals("抽卡"))
            {
                CharacterRandom characterrandom = new CharacterRandom();

                rand = int.Parse(characterrandom.CardSelect(1, gunInArmoy, "F:\\CoolQAir\\dev\\com.girlsfrontline.demo\\Guns.xml"));


                e.FromGroup.SendGroupMessage(
                    "池子存有人形数:",
                    gunInArmoy.ToString(),
                    "\n本次抽取到的人形是:\n",
                    characterLoder.CharacterName(rand),
                    "\n星级:",
                    characterLoder.CharacterRank(rand),
                    "\n",
                    characterLoder.CharacterMsg(rand),
                    "\n战斗效能:",
                    characterLoder.CharacterAttack(rand)
                    );;

                userManager.AddCardToUser(rand, e.FromQQ.Id.ToString());
            }

            if (e.Message.Text.Equals("读取数据"))
            {
                e.FromGroup.SendGroupMessage("获取:",
                                             e.FromGroup.GetGroupMemberInfo(1256893006).Nick
                                             );
            }

            if (e.Message.Text == "我的梯队")
            {
                DarwinGame darwinGame = new DarwinGame("F:\\CoolQAir\\dev\\com.girlsfrontline.demo\\UserInfo.xml",
                                                       "F:\\CoolQAir\\dev\\com.girlsfrontline.demo\\Guns.xml");

                if (darwinGame.IsPlayer(e.FromQQ.Id.ToString()) == false)
                {
                    e.FromGroup.SendGroupMessage("玩家不存在");
                    return;
                }

                StringBuilder          ans     = new StringBuilder();
                IEnumerable <XElement> members = userManager.TeamOfUser(e.FromQQ.Id.ToString());

                ans.Append("您的梯队:\n");

                foreach (var ele in members)
                {
                    if (int.Parse(ele.Value) == 0)
                    {
                        ans.Append("N/A");
                    }
                    else
                    {
                        ans.Append(characterLoder.CharacterName(int.Parse(ele.Value)));
                        ans.Append(' ');
                        ans.Append("等级");
                        ans.Append(characterLoder.CharacterRank(int.Parse(ele.Value)));
                        ans.Append(' ');
                        ans.Append("战斗效能");
                        ans.Append(characterLoder.CharacterAttack(int.Parse(ele.Value)));
                    }

                    ans.Append('\n');
                }

                ans.Append("战斗效能总和");
                ans.Append(userManager.TeamAttack(e.FromQQ.Id.ToString()));
                e.FromGroup.SendGroupMessage(ans);
            }

            if (e.Message.Text == "我的卡牌")
            {
                StringBuilder          ans      = new StringBuilder();
                IEnumerable <XElement> userinfo = userManager.CardOfUser(e.FromQQ.Id.ToString());

                if (userinfo == null || userinfo.Elements().Count() == 0)
                {
                    e.FromGroup.SendGroupMessage("您暂无卡牌");
                    return;
                }

                ans.Append("您拥有:\n");

                foreach (XElement ele in userinfo)
                {
                    ans.Append("ID: ");
                    ans.Append(ele.Attribute("id").Value);
                    ans.Append(' ');
                    ans.Append(characterLoder.CharacterName(int.Parse(ele.Attribute("id").Value)));
                    ans.Append(' ');
                    ans.Append("等级");
                    ans.Append(characterLoder.CharacterRank(int.Parse(ele.Attribute("id").Value)));
                    ans.Append(' ');
                    ans.Append("战斗效能");
                    ans.Append(characterLoder.CharacterAttack(int.Parse(ele.Attribute("id").Value)));
                    ans.Append(' ');
                    ans.Append("数量");
                    ans.Append(ele.Element("num").Value);
                    ans.Append("\n");
                }

                e.FromGroup.SendGroupMessage(ans);
            }

            if (e.Message.Text.StartsWith("删除卡牌"))
            {
                int    start = CQApi.CQDeCode(e.Message.Text).IndexOf(' ');
                string id    = CQApi.CQDeCode(e.Message.Text).Substring(start + 1);
                int    flag  =
                    userManager.DeleteCardById(id, e.FromQQ.Id.ToString());

                switch (flag)
                {
                case 0:
                    e.FromGroup.SendGroupMessage("你现在空无一卡");
                    return;

                case 1:
                    e.FromGroup.SendGroupMessage("你没有这张卡");
                    return;

                case 2:
                    e.FromGroup.SendGroupMessage("删除成功");
                    return;
                }
            }

            if (e.Message.Text.StartsWith("发起对战"))
            {
                GroupMemberInfo playerinfo = e.FromGroup.GetGroupMemberInfo(e.FromQQ.Id);
                string          playername = playerinfo.Nick;

                DarwinGame darwinGame = new DarwinGame("F:\\CoolQAir\\dev\\com.girlsfrontline.demo\\UserInfo.xml",
                                                       "F:\\CoolQAir\\dev\\com.girlsfrontline.demo\\Guns.xml");

                string rivalqq = "N/A";

                foreach (var cqcode in e.Message.CQCodes.FindAll(c => c.Function == CQFunction.At))
                {
                    foreach (var item in cqcode.Items)
                    {
                        rivalqq = item.Value;
                    }
                }

                if (rivalqq == "N/A")
                {
                    e.FromGroup.SendGroupMessage("请重新@你的对手");
                    return;
                }
                //GroupMemberInfo rivalinfo = e.FromGroup.GetGroupMemberInfo(long.Parse(rivalqq));

                GroupMemberInfo rivalinfo = e.FromGroup.GetGroupMemberInfo(long.Parse(rivalqq));

                string rivalname = rivalinfo.Nick;

                if (darwinGame.IsPlayer(e.FromQQ.Id.ToString()) == false ||
                    darwinGame.IsPlayer(rivalqq) == false ||
                    e.FromQQ.Id.ToString() == rivalqq ||
                    CQApi.CQCode_At(e.CQApi.GetLoginQQ()).ToString() == rivalqq)
                {
                    e.FromGroup.SendGroupMessage("对战不成立");
                    return;
                }

                e.FromGroup.SendGroupMessage(playername, "与" + rivalname, "开始对战!");
                int result = darwinGame.fight(e.FromQQ.Id.ToString(), rivalqq);

                if (result == 3)
                {
                    e.FromGroup.SendGroupMessage("平局");
                }
                else if (result == 1)
                {
                    e.FromGroup.SendGroupMessage(playername, "获胜");
                }
                else if (result == 2)
                {
                    e.FromGroup.SendGroupMessage(rivalname, "获胜");
                }
            }

            if (e.Message.Text.StartsWith("设置梯队"))
            {
                int[]    id    = { 0, 0, 0, 0, 0 };
                char[]   space = { ' ' };
                string[] res   = e.Message.Text.Split(space, options: StringSplitOptions.RemoveEmptyEntries);

                if (res.Length > 6)
                {
                    e.FromGroup.SendGroupMessage("最多只能容许5个成员");
                    return;
                }

                for (int i = 1; i < res.Length; i++)
                {
                    for (int j = i + 1; j < res.Length; j++)
                    {
                        if (res[i] == res[j])
                        {
                            e.FromGroup.SendGroupMessage("一个队伍中不能有重复角色");
                            return;
                        }
                    }
                }

                for (int i = 1; i < res.Length; i++)
                {
                    id[i - 1] = int.Parse(res[i]);
                }

                foreach (var item in id)
                {
                    if (item < 0 || item > characterLoder.NumOfCharacter())
                    {
                        e.FromGroup.SendGroupMessage("存在非法id");
                        return;
                    }
                }

                DarwinGame darwinGame = new DarwinGame("F:\\CoolQAir\\dev\\com.girlsfrontline.demo\\UserInfo.xml",
                                                       "F:\\CoolQAir\\dev\\com.girlsfrontline.demo\\Guns.xml");

                switch (darwinGame.SetMemder(e.FromQQ.Id.ToString(), id))
                {
                case 0:
                    e.FromGroup.SendGroupMessage("玩家不存在");
                    return;

                case 1:
                    e.FromGroup.SendGroupMessage("设置的卡牌中有不存在的卡牌");
                    return;

                case 2:
                    StringBuilder ans = new StringBuilder();
                    ans.Append("设置完毕,当前战斗效能");
                    ans.Append(userManager.TeamAttack(e.FromQQ.Id.ToString()));
                    e.FromGroup.SendGroupMessage(ans);
                    return;
                }
            }

            if (e.Message.Text.Contains(CQApi.CQCode_At(e.CQApi.GetLoginQQ()).ToString()))
            {
                e.FromGroup.SendGroupMessage("使用格式:\n" +
                                             "[抽卡] 抽取一张卡片\n" +
                                             "[添加卡片 名称 星级 留言]将卡片放入池子\n" +
                                             "例如:\n" +
                                             "添加卡片 绍沙 4 绍沙M1915,向您报到。\n" +
                                             "星级范围2-5\n" +
                                             "[我的卡牌] 查看拥有的卡牌\n" +
                                             "[删除卡牌 id]删除卡片\n" +
                                             "例如:删除卡牌 抽卡机\n" +
                                             "[发起对战 @某人]向某人发起对战\n" +
                                             "[设置梯队 id id id id id]设置一个梯队\n" +
                                             "[我的梯队]查看自己的梯队");
            }
        }
Пример #22
0
        public static void GuildBattleResponse(object Sender, CQGroupMessageEventArgs GBattleEventArgs,
                                               PCRGuildCmdType commandType) //功能响应
        {
            if (GBattleEventArgs == null)
            {
                throw new ArgumentNullException(nameof(GBattleEventArgs));
            }
            Group           qqGroup    = GBattleEventArgs.FromGroup;
            QQ              senderQQ   = GBattleEventArgs.FromQQ;
            GroupMemberInfo memberInfo = GBattleEventArgs.CQApi.GetGroupMemberInfo(qqGroup.Id, senderQQ.Id);

            //index=0为命令本身,其余为参数
            string[] commandArgs = GBattleEventArgs.Message.Text.Split(' ');
            //数据库实例
            GuildBattleMgrDBHelper guildBattleDB = new GuildBattleMgrDBHelper(Sender, GBattleEventArgs);

            //查找是否存在这个公会
            if (!guildBattleDB.GuildExists())
            {
                ConsoleLog.Debug("GuildExists", "guild not found");
                qqGroup.SendGroupMessage(CQApi.CQCode_At(senderQQ.Id),
                                         "\r\n此群未被登记为公会",
                                         "\r\n请使用以下指令创建公会",
                                         $"\r\n{PCRGuildHandle.GetCommandHelp(commandType)}");
                return;
            }
            //TODO 自动更新boss数据

            switch (commandType)
            {
            case PCRGuildCmdType.BattleStart:
                //检查执行者权限
                if (memberInfo.MemberType == QQGroupMemberType.Member)
                {
                    //执行者为普通群员时拒绝执行指令
                    qqGroup.SendGroupMessage(CQApi.CQCode_At(senderQQ.Id),
                                             "此指令只允许管理者执行");
                    ConsoleLog.Warning($"会战[群:{qqGroup.Id}]", $"群成员{memberInfo.Nick}正在尝试执行指令{commandType}");
                    return;
                }
                ConsoleLog.Info($"会战[群:{qqGroup.Id}]", $"开始处理指令{commandType}");
                int result = guildBattleDB.StartBattle();
                //判断返回值
                switch (result)
                {
                case -1:        //已经执行过开始命令
                    qqGroup.SendGroupMessage(CQApi.CQCode_At(senderQQ.Id),
                                             "\r\n出刀统计已经开始了嗷",
                                             "\r\n请检查是否未结束上期会战的出刀统计");
                    break;

                case 0:
                    qqGroup.SendGroupMessage(CQApi.CQCode_AtAll(),
                                             "\r\n新的一期会战开始啦!");
                    break;

                default:
                    qqGroup.SendGroupMessage(CQApi.CQCode_At(senderQQ.Id),
                                             "\r\nERROR",
                                             "\r\n遇到未知错误,请联系当前机器人维护者");
                    break;
                }
                break;

            default:
                throw new NotImplementedException();
            }
        }
Пример #23
0
 /// <summary>
 /// 数据库发生错误时的消息提示
 /// </summary>
 public static void DatabaseFailedTips(CQGroupMessageEventArgs groupEventArgs)
 {
     groupEventArgs.FromGroup.SendGroupMessage(CQApi.CQCode_At(groupEventArgs.FromQQ.Id),
                                     "\r\nERROR",
                                     "\r\n数据库错误");
 }
Пример #24
0
 /// <summary>
 /// 得到未知指令时的响应
 /// </summary>
 /// <param name="e">CQGroupMessageEventArgs</param>
 public static void GetUnknowCommand(CQGroupMessageEventArgs e)
 {
     ConsoleLog.Warning("PCR公会管理", "未知指令");
     e.FromGroup.SendGroupMessage(CQApi.CQCode_At(e.FromQQ.Id), "\n未知指令");
 }
Пример #25
0
 /// <summary>
 /// 获取酷Q "At某人" 代码
 /// </summary>
 /// <returns>返回 <see cref="CQCode"/> 对象</returns>
 public CQCode CQCode_At()
 {
     return(CQApi.CQCode_At(this));
 }
Пример #26
0
 /// <summary>
 /// 初始化特殊关键词
 /// </summary>
 public static void SpecialKeywordsInit(CQApi cqApi)
 {
     Keywords.Add("查询排名", KeywordCmdType.PCRTools_GetGuildRank);
     Keywords.Add(CQApi.CQCode_At(cqApi.GetLoginQQ().Id).ToString(), KeywordCmdType.At_Bot);
 }
Пример #27
0
        /// <summary>
        /// 将消息中的东西替换为CQ码
        /// </summary>
        /// <param name="message">原始消息</param>
        /// <returns></returns>
        public static string Start(ReceiveMessage message)
        {
            string result = string.Empty;
            string msg    = message.CurrentPacket.Data.Content;

            switch (message.CurrentPacket.Data.MsgType)
            {
            case "TempSessionMsg":
                if (msg.Contains("图片"))
                {
                    var c = JsonConvert.DeserializeObject <PicMessage>(msg).FriendPic;
                    foreach (var item in c)
                    {
                        result += MakeCQImage(item);
                    }
                }
                else
                {
                    result = JObject.Parse(msg)["Content"].ToString();
                }

                break;

            case "AtMsg":
            {
                //at消息主要将消息中的at消息转变为CQ码
                //而@人名 中的人名格式可能会不同,不能直接用群名片替换,所以要从群成员列表寻找这个人
                //按备注->群名片->昵称的顺序,替换可能出现的名称
                TextMessage textMessage = JsonConvert.DeserializeObject <TextMessage>(msg);
                result = textMessage.Content;
                //从缓存寻找这个群
                GroupMemberList ls = MemberSave.Find(x => x.GroupUin == message.CurrentPacket.Data.FromGroupId);
                if (ls == null)         //未在缓存找到,将这个群加入缓存
                {
                    ls = JsonConvert.DeserializeObject <GroupMemberList>(
                        WebAPI.GetGroupMemberList(message.CurrentPacket.Data.FromGroupId));
                    MemberSave.Add(ls);
                }

                foreach (var item in textMessage.UserID)
                {
                    GroupMemberList.Memberlist mem = ls.MemberList.Where(x => x.MemberUin == item).First();
                    foreach (var pro in mem.GetType().GetProperties())
                    {
                        //将空文本变成null,方便后续??运算符
                        try
                        {
                            if (string.IsNullOrEmpty(pro.GetValue(mem).ToString()))
                            {
                                pro.SetValue(mem, null);
                            }
                        }
                        catch (NullReferenceException e)
                        {
                            pro.SetValue(mem, null);         //如果是null则会跳至catch块
                        }
                    }

                    string originStr = "@" + (mem.AutoRemark ?? mem.GroupCard ?? mem.NickName);
                    result = result.Replace(originStr, CQApi.CQCode_At(item).ToSendString());
                }

                break;
            }

            case "TextMsg":
                result = msg;
                break;

            case "PicMsg":
            {
                //图片消息是将图片消息的信息配置进image文件夹下的以MD5为名称的cqimg文件内
                PicMessage picMessage =
                    JsonConvert.DeserializeObject <PicMessage>(message.CurrentPacket.Data.Content);
                if (!Directory.Exists("data\\image"))
                {
                    Directory.CreateDirectory("data\\image");
                }
                result = picMessage.Content;
                if (picMessage.GroupPic != null)         //是群图片消息
                {
                    foreach (var item in picMessage.GroupPic)
                    {
                        result += MakeCQImage(item);
                    }
                }
                else         //是好友图片消息
                {
                    foreach (var item in picMessage.FriendPic)
                    {
                        result += MakeCQImage(item);
                    }
                }
                break;
            }

            case "VoiceMsg":
            {
                if (!Directory.Exists("data\\record\\"))
                {
                    Directory.CreateDirectory("data\\record\\");
                }
                JObject json = JObject.Parse(msg);
                string  url  = json["Url"].ToString();
                string  MD5  = GenerateMD5(url);
                string  path = "data\\record\\" + MD5 + ".silk";
                if (!File.Exists(path))
                {
                    IniConfig ini = new IniConfig(path);
                    ini.Object.Add(new ISection("record"));
                    ini.Object["record"]["url"] = url;
                    ini.Save();
                }

                result = CQApi.CQCode_Record(MD5 + ".silk").ToString();
                break;
            }

            case "RedBagMsg":
            {
                string title = JObject.Parse(msg)["Content"]?.ToString();
                result = $"[CQ:hb,title={title}]";
                break;
            }

            case "XmlMsg":
            {
                result = JObject.Parse(msg)["Content"].ToString();
                var xml   = new XmlDocument();
                int index = result.IndexOf("</msg>");
                result = result.Substring(0, index + "</msg>".Length);
                xml.LoadXml(result);
                var root = xml.FirstChild.NextSibling;
                foreach (XmlAttribute item in root.Attributes)
                {
                    if (item.Name == "actionData" && item.Value.Contains("group:"))
                    {
                        result = $"[CQ:contact,id={item.Value.Replace("group:", "")},type=group]";
                        break;
                    }
                    else if (item.Name == "actionData" && item.Value.Contains("AppCmd://OpenContactInfo/?uin"))
                    {
                        result = $"[CQ:contact,id={item.Value.Replace("AppCmd://OpenContactInfo/?uin=", "")},type=qq]";
                        break;
                    }
                    else if (item.Name == "url" && item.Value.Contains("y.music.163.com"))
                    {
                        int musicid = Convert.ToInt32(Regex.Replace(item.Value, "https:\\/\\/y.music.163.com\\/m/song\\/([0-9]*)\\/\\?userid=([0-9]*)", "$1"));
                        int userid  = Convert.ToInt32(Regex.Replace(item.Value, "https:\\/\\/y.music.163.com\\/m/song\\/([0-9]*)\\/\\?userid=([0-9]*)", "$2"));
                        result = $"[CQ:music,type=163,id={musicid},userid={userid}]";
                        break;
                    }
                }
                if (!result.StartsWith("[CQ:"))
                {
                    result = $"[CQ:rich,content={result.Replace("\n","").Replace("\r","")}]";
                }
                break;
            }

            case "JsonMsg":
            {
                result = JObject.Parse(msg)["Content"].ToString();
                result = result.Substring(result.IndexOf("{\"app\":\""));
                var json = JObject.Parse(result);
                if (json["meta"]["music"] != null)
                {
                    var musicroot = json["meta"]["music"];
                    int musicid   = Convert.ToInt32(Regex.Replace(musicroot["jumpUrl"].ToString(), "https:\\/\\/y.music.163.com\\/m/song\\/([0-9]*)\\/\\?userid=([0-9]*)", "$1"));
                    int userid    = Convert.ToInt32(Regex.Replace(musicroot["jumpUrl"].ToString(), "https:\\/\\/y.music.163.com\\/m/song\\/([0-9]*)\\/\\?userid=([0-9]*)", "$2"));
                    result = $"[CQ:music,type=163,id={musicid},userid={userid},title={musicroot["title"]},desc={musicroot["desc"]}]";
                }
                else
                {
                    result = $"[CQ:rich,title={json["prompt"]}]";
                }
                break;
            }
            }

            result = Regex.Replace(result, "\\[表情(\\d*)\\]", "[CQ:face,id=$1]"); //处理QQ表情信息
            //处理emoji消息
            foreach (var a in result)
            {
                //UTF-8下,大部分的emoji都是以\ud83d开头
                if (a == '\ud83d' && result.IndexOf(a) != result.Length - 1)
                {
                    //取这个emoji
                    string        str   = a.ToString() + result[result.IndexOf(a) + 1].ToString();
                    UTF32Encoding enc   = new UTF32Encoding(true, false);
                    byte[]        bytes = enc.GetBytes(str); //转换字节数组
                    //使用BitConvert将字节数组转换为16进制,之后转换为10进制即可
                    result = result.Replace(str,
                                            CQApi.CQCode_Emoji(Convert.ToInt32(BitConverter.ToString(bytes).Replace("-", ""), 16))
                                            .ToString());
                    break;
                }
            }

            return(result);
        }
Пример #28
0
 /// <summary>
 /// 获取酷Q "At某人" 代码
 /// </summary>
 /// <returns>返回 <see cref="CQCode"/> 对象</returns>
 public CQCode CQCode_At()
 {
     return(CQApi.CQCode_At((long)this));
 }
Пример #29
0
        /// <summary>
        /// 获取周榜文本
        /// </summary>
        /// <param name="cn"></param>
        /// <param name="e"></param>
        /// <returns></returns>
        public static StringBuilder GetWeekRankText(SQLiteConnection cn, CQGroupMessageEventArgs e)
        {
            long          groupid = e.FromGroup.Id;
            StringBuilder sb      = new StringBuilder();

            sb.AppendLine($"----抽卡周榜({GetLastSunday().AddDays(-6):yyyy-M-d} - {GetLastSunday():yyyy-M-d})----");

            SQLiteCommand    cmd = new SQLiteCommand(GetQueryStr("count(*)", $"fromgroup={groupid}"), cn);
            SQLiteDataReader sr  = cmd.ExecuteReader();

            sr.Read();
            int count = sr.GetInt32(0);

            sb.AppendLine($"上周本群共抽卡:{count}次 共消耗水晶:{count * 280} 大约为大伟哥捐了{count * 280 / 7640 + 1}个648");

            cmd = new SQLiteCommand(GetQueryStr("count(*)", $"fromgroup={groupid} and type='Weapon' and quality=2"), cn); sr = cmd.ExecuteReader();
            sr.Read();
            sb.AppendLine($"抽到了四星武器:{sr.GetInt32(0)}个");

            cmd = new SQLiteCommand(GetQueryStr("count(*)", $"fromgroup={groupid} and type='Stigmata' and quality=2"), cn); sr = cmd.ExecuteReader();
            sr.Read();
            sb.AppendLine($"抽到了四星圣痕:{sr.GetInt32(0)}个");

            cmd = new SQLiteCommand(GetQueryStr("count(*)", $"fromgroup={groupid} and type='Character' and class_='S'"), cn); sr = cmd.ExecuteReader();
            sr.Read();
            sb.AppendLine($"抽到了S角色:{sr.GetInt32(0)}个");

            cmd = new SQLiteCommand(GetQueryStr("count(*)", $"fromgroup={groupid} and type='Character' and class_='A'"), cn); sr = cmd.ExecuteReader();
            sr.Read();
            sb.AppendLine($"抽到了A角色:{sr.GetInt32(0)}个");


            cmd = new SQLiteCommand(GetQueryStr("count(qq),qq", $"fromgroup={groupid}", "group by qq order by count(qq) desc"), cn); sr = cmd.ExecuteReader();
            sr.Read();

            var    temp = e.FromGroup.GetGroupMemberInfo(sr.GetInt64(1));
            string name = temp.Card == "" ? temp.Nick : temp.Card;

            sb.AppendLine($"抽卡次数最多的是:{name} 一共抽了{sr.GetInt32(0)}次 共花费了{sr.GetInt32(0) * 280}水晶");


            List <Member> ls = new List <Member>();

            cmd = new SQLiteCommand(GetQueryStr("count(qq),qq", $"fromgroup={groupid} and (quality=2 or class_='S')", "group by qq"), cn); sr = cmd.ExecuteReader();
            while (sr.Read())
            {
                Member member = new Member()
                {
                    qqid         = sr.GetInt64(1),
                    purple_count = sr.GetInt32(0)
                };
                ls.Add(member);
            }

            cmd = new SQLiteCommand(GetQueryStr("count(*),qq", $"fromgroup={groupid}", "group by qq"), cn); sr = cmd.ExecuteReader();
            while (sr.Read())
            {
                foreach (var item in ls)
                {
                    if (item.qqid == sr.GetInt64(1))
                    {
                        item.gacha_count = sr.GetInt32(0);
                    }
                }
            }
            ls.OrderByDescending(x => x.purple_count / (double)x.gacha_count);
            sb.AppendLine($"最欧的是:{CQApi.CQCode_At(ls[0].qqid).ToSendString()} 综合出货率为{(ls[0].purple_count / (double)ls[0].gacha_count * 100):0.000}%");

            return(sb);
        }
Пример #30
0
        public static void Poster()
        {
posthead:
            //Hot Poster
            string fstr = ""; string estr = ""; string[] qtemp;

            Native.Csharp.Sdk.Cqp.Model.Group g;
            HotMsg hhmsg = new HotMsg();

            for (int s = 0; s < Manager.mHot.data.Count; s++)
            {
                hhmsg = (HotMsg)Manager.mHot.data[s];
                if (DateTime.Now.Hour >= 22 && hhmsg.hasup == false)
                {
                    Log("Annouce:" + hhmsg.group, ConsoleColor.Green);
                    qtemp = hhmsg.banqq.Split(';');
                    for (int i = 0; i < qtemp.Length - 1; i++)
                    {
                        estr = estr + CQApi.CQCode_At(Convert.ToInt64(qtemp[i]));
                    }
                    qtemp = hhmsg.qq.Split(';');
                    for (int i = 0; i < qtemp.Length - 1; i++)
                    {
                        fstr = fstr + CQApi.CQCode_At(Convert.ToInt64(qtemp[i]));
                    }
                    hhmsg.hasup = true;
                    g           = new Native.Csharp.Sdk.Cqp.Model.Group(pCQ, Convert.ToInt64(hhmsg.group));
                    g.SendGroupMessage("截止刚才,本群今日最热发言:\n" + hhmsg.msg + "\n复读发起人:" + CQApi.CQCode_At(Convert.ToInt64(qtemp[0])) + "\n复读热度:" + hhmsg.hot + "\n该热度发言被这些成员复读过:" + fstr + "\n在该热度发言发起时,这些成员太过激动试图刷屏:" + estr);
                    Manager.mHot.data[s] = hhmsg;
                }
            }
            //Homework network
            string f = "0";

            if (File.Exists("D:\\DataArrange\\homeworklock.bin"))
            {
                f = File.ReadAllText("D:\\DataArrange\\homeworklock.bin", Encoding.UTF8);
            }
            if (Convert.ToInt64(f) == 1)
            {
                Log("New homework recevied !", ConsoleColor.Green);
                f = File.ReadAllText("D:\\DataArrange\\homework.bin", Encoding.UTF8);
                g = new Native.Csharp.Sdk.Cqp.Model.Group(pCQ, 817755769);
                g.SendGroupMessage("[今日作业推送消息]\n" + f + "\n————来自黑嘴稽气人的自动推送");
                File.WriteAllText("D:\\DataArrange\\homeworklock.bin", "0");
            }
            f = "";
            if (File.Exists("D:\\DataArrange\\announcer.bin"))
            {
                f = File.ReadAllText("D:\\DataArrange\\announcer.bin", Encoding.UTF8);
            }
            if (f != "")
            {
                Log("Announce:" + f, ConsoleColor.Green);
                string[] p = f.Split('\\'); long gr = 0;
                if (p[0] == "class")
                {
                    gr = 817755769;
                }
                if (p[0] == "inter")
                {
                    gr = 554272507;
                }
                g = new Native.Csharp.Sdk.Cqp.Model.Group(pCQ, gr);
                switch (p[1])
                {
                case ("hlesson"):
                    f = "今天上午的网课出炉啦~\n地址:{url}\n往期网课精彩回顾:https://space.bilibili.com/313086171/channel/detail?cid=103565 ".Replace("{url}", p[2]);
                    break;

                case ("lesson"):
                    f = "今天全天的网课出炉啦~\n地址:{url}\n往期网课精彩回顾:https://space.bilibili.com/313086171/channel/detail?cid=103565 ".Replace("{url}", p[2]);
                    break;

                case ("default"):
                    f = p[2];
                    break;

                default:
                    Log("Unkown announce .", ConsoleColor.Red);
                    return;
                }
                g.SendGroupMessage("[通知]\n" + f + "\n————来自黑嘴稽气人的自动推送");
                File.WriteAllText("D:\\DataArrange\\announcer.bin", "");
            }
            Thread.Sleep(1000);
            goto posthead;
        }