示例#1
0
        /// <summary>
        /// 获取到群消息
        /// </summary>
        public void GetChat(KeywordCmdType cmdType)
        {
            if (CheruEventArgs == null || Sender == null)
            {
                return;
            }
            string[] commandArgs = CheruEventArgs.Message.Text.Split(' ');
            //检查参数
            switch (Utils.CheckForLength(commandArgs, 1))
            {
            case LenType.Illegal:
                CheruEventArgs.FromGroup.SendGroupMessage("你在说什么啊!");
                break;

            case LenType.Legitimate:
                switch (cmdType)
                {
                case KeywordCmdType.Cheru_Decode:
                    CheruToString(commandArgs[1]);
                    break;

                case KeywordCmdType.Cheru_Encode:
                    StringToCheru(commandArgs[1]);
                    break;
                }
                break;

            default:
            case LenType.Extra:
                CheruEventArgs.FromGroup.SendGroupMessage("你 说 话 带 空 格");
                return;
            }
        }
示例#2
0
 /// <summary>
 /// 收到信息的函数
 /// 并匹配相应指令
 /// </summary>
 public void GetChat(KeywordCmdType cmdType)
 {
     if (PCREventArgs == null || Sender == null)
     {
         return;
     }
     string[] commandArgs = PCREventArgs.Message.Text.Split(' ');
     switch (cmdType)
     {
     //查询公会排名
     case KeywordCmdType.PCRTools_GetGuildRank:
         GetGuildRank(commandArgs);
         break;
     }
     PCREventArgs.Handler = true;
 }
        /// <summary>
        /// 收到群消息
        /// </summary>
        /// <param name="sender">事件来源</param>
        /// <param name="e">事件参数</param>
        public void GroupMessage(object sender, CQGroupMessageEventArgs e)
        {
            if (sender == null || e == null)
            {
                return;
            }
            this.eventArgs = e;
            ConsoleLog.Info($"收到信息[群:{eventArgs.FromGroup.Id}]", $"{(eventArgs.Message.Text).Replace("\r\n", "\\r\\n")}");
            //读取配置文件
            ConfigIO config = new ConfigIO(eventArgs.CQApi.GetLoginQQ().Id, false);

            //Module moduleEnable = config.LoadedConfig.ModuleSwitch;

            //以#开头的消息全部交给PCR处理
            if (eventArgs.Message.Text.Trim().StartsWith("#") && //检查指令开头
                config.LoadConfig()                              //加载配置文件
                )
            {
                //检查模块使能
                if (!config.LoadedConfig.ModuleSwitch.PCR_GuildManager)
                {
                    SendDisableMessage();
                    return;
                }
                PCRGuildHandle pcrGuild = new PCRGuildHandle(sender, eventArgs);
                pcrGuild.GetChat();
                return;
            }

            //全字指令匹配
            WholeMatchCmd.KeyWords.TryGetValue(eventArgs.Message, out WholeMatchCmdType cmdType); //查找关键字
            if (cmdType != 0)
            {
                ConsoleLog.Info("触发关键词", $"消息类型={cmdType}");
                //加载配置文件
                if (!config.LoadConfig())
                {
                    return;
                }
            }
            switch (cmdType)
            {
            //输入debug
            case WholeMatchCmdType.Debug:
                if (!config.LoadedConfig.ModuleSwitch.Debug)
                {
                    SendDisableMessage();
                    return;
                }
                DefaultHandle dh = new DefaultHandle(sender, eventArgs);
                dh.GetChat(cmdType);
                return;

            //娱乐功能
            case WholeMatchCmdType.SurpriseMFK_Random:
            case WholeMatchCmdType.SurpriseMFK_Ban:
            case WholeMatchCmdType.SurpriseMFK_RedTea:
            case WholeMatchCmdType.SurpriseMFK_24YearsOld:
                if (!config.LoadedConfig.ModuleSwitch.HaveFun)
                {
                    SendDisableMessage();
                    return;
                }
                SurpriseMFKHandle smfh = new SurpriseMFKHandle(sender, eventArgs);
                smfh.GetChat(cmdType);
                return;

            //慧酱签到啦
            case WholeMatchCmdType.Suisei_SignIn:
                if (!config.LoadedConfig.ModuleSwitch.Suisei)
                {
                    SendDisableMessage();
                    return;
                }
                SuiseiHanlde suisei = new SuiseiHanlde(sender, eventArgs);
                suisei.GetChat(cmdType);
                return;

            //来点色图!
            case WholeMatchCmdType.Setu:
                if (!config.LoadedConfig.ModuleSwitch.Setu)
                {
                    SendDisableMessage();
                    return;
                }
                return;

            default:
                break;
            }

            //参数指令匹配
            KeywordCmdType keywordType = KeywordCmd.TryGetKeywordType(eventArgs.Message.Text);

            if (keywordType != 0)
            {
                ConsoleLog.Info("触发关键词", $"消息类型={cmdType}");
                //加载配置文件
                if (!config.LoadConfig())
                {
                    return;
                }
            }
            switch (keywordType)
            {
            case KeywordCmdType.PCRTools_GetGuildRank:
                if (!config.LoadedConfig.ModuleSwitch.PCR_GuildRank)
                {
                    SendDisableMessage();
                    return;
                }
                PCRToolsHandle pcrTools = new PCRToolsHandle(sender, eventArgs);
                pcrTools.GetChat(keywordType);
                return;

            case KeywordCmdType.At_Bot:
                ConsoleLog.Info("机器人事件", "机器人被AT");
                break;

            default:
                break;
            }

            eventArgs.Handler = true;
        }