Exemple #1
0
        /// <summary>
        /// 处理群消息方法
        /// </summary>
        /// <param name="obj"></param>
        private void DealWithGroupMessage(object obj)
        {
            try
            {
                object[] paramaters = (object[])obj;

                long   fromGroup = (long)paramaters[2];
                long   fromQq    = (long)paramaters[3];
                string msg       = (string)paramaters[5];

                if (!m_QQdics.ContainsKey(fromGroup))
                {
                    //获取群成员 需要api权限160
                    List <GroupMemberInfo> memebers = CoolQApi.GetGroupMemberList(fromGroup).Model.ToList();
                    m_QQdics.Add(fromGroup, memebers.Select(t => t.Number).ToList());
                }

                List <long> qqList = CheckHasAtQQ(m_QQdics[fromGroup], msg);

                if (qqList.Count > 0)
                {
                    //禁言部分
                    if (msg.Contains("禁言") || msg.Contains("闭嘴") || msg.Contains("别说话") || msg.Contains("让你说话了么") || msg.Contains("ShutUp"))
                    {
                        foreach (var targetqq in qqList)
                        {
                            //全体成员跳过
                            if (targetqq == -1)
                            {
                                continue;
                            }

                            //对该机器人
                            if (targetqq == CoolQApi.GetLoginQQ())
                            {
                                CoolQApi.SendGroupMsg(fromGroup, CoolQCode.At(fromQq) + " 小逼,想禁言我?找死是吧!3分钟不谢!");
                                CoolQApi.SetGroupBan(fromGroup, fromQq, 180);
                                break;
                            }

                            //成功概率1/3
                            bool success = m_Rand.Next(4200) % 3 == 1;
                            if (success)
                            {
                                CoolQApi.SendGroupMsg(fromGroup, CoolQCode.At(fromQq) + "对" + CoolQCode.At(targetqq) + "释放了禁言术! 成功了!  " + CoolQCode.At(targetqq) + "被禁言3分钟!");
                                CoolQApi.SetGroupBan(fromGroup, targetqq, 180);
                            }
                            else
                            {
                                CoolQApi.SendGroupMsg(fromGroup, CoolQCode.At(fromQq) + "对" + CoolQCode.At(targetqq) + "释放了禁言术! 但是什么都没有发生!");
                            }
                        }
                    }
                    //踢出群部分
                    if (msg.Contains("滚") || msg.Contains("KickOut") || msg.Contains("踢了") || msg.Contains("飞踢") || msg.Contains("ThaiKick"))
                    {
                        foreach (var targetqq in qqList)
                        {
                            //全体成员跳过
                            if (targetqq == -1)
                            {
                                continue;
                            }
                            //对该机器人
                            if (targetqq == CoolQApi.GetLoginQQ())
                            {
                                CoolQApi.SendGroupMsg(fromGroup, CoolQCode.At(fromQq) + " 小逼,想踢我?找死是吧!翻滚吧!");
                                CoolQApi.SetGroupKick(fromGroup, fromQq, false);
                                break;
                            }
                            //成功概率1/5
                            bool success = m_Rand.Next(4200) % 5 == 1;
                            if (success)
                            {
                                CoolQApi.SendGroupMsg(fromGroup, CoolQCode.At(fromQq) + "狠狠踢了" + CoolQCode.At(targetqq) + "一脚! " + CoolQCode.At(targetqq) + "飞了好远,直到飞出了群");
                                CoolQApi.SetGroupKick(fromGroup, targetqq, false);
                            }
                            else
                            {
                                CoolQApi.SendGroupMsg(fromGroup, CoolQCode.At(fromQq) + "想要狠狠踢" + CoolQCode.At(targetqq) + "一脚,结果没有踢着,把脚崴了。好惨!");
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                CoolQApi.AddLog(1, CoolQLogLevel.Error, e.Message);
            }
        }