示例#1
0
        /// <summary>
        /// 每日限制检查
        /// </summary>
        /// <param name="enterAttr"></param>
        /// <param name="MsgDTO"></param>
        /// <param name="limitRecord"></param>
        /// <returns></returns>
        private static bool DailyLimitCheck(EnterCommandAttribute enterAttr, MsgInformation MsgDTO, DailyLimitRecord limitRecord)
        {
            var isTestingGroup = Global.TestGroups.Contains(MsgDTO.FromGroup);
            var timesLimit     = isTestingGroup ? enterAttr.TestingDailyLimit : enterAttr.DailyLimit;

            return(timesLimit == 0 || limitRecord.Check(timesLimit));
        }
示例#2
0
        /// <summary>
        /// 消息处理前置检查
        /// </summary>
        /// <param name="enterAttr"></param>
        /// <param name="MsgDTO"></param>
        /// <param name="param"></param>
        /// <returns></returns>
        private bool Check(EnterCommandAttribute enterAttr, MsgInformationEx MsgDTO, out object[] param)
        {
            param = null;
            if (!enterAttr.CommandsList.Contains(MsgDTO.Command))
            {
                return(false);
            }

            if ((!enterAttr.IsGroupAvailable && MsgDTO.Type == MsgType.Group) || (!enterAttr.IsPrivateAvailable && MsgDTO.Type == MsgType.Private))
            {
                return(false);
            }

            if (!SyntaxCheckerSvc.SyntaxCheck(enterAttr.SyntaxChecker, MsgDTO.Msg, out param))
            {
                return(false);
            }

            if (MsgDTO.Type == MsgType.Private)
            {
                return(true);
            }

            if (!AuthorityCheck(enterAttr.AuthorityLevel, MsgDTO))
            {
                MsgSender.PushMsg(MsgDTO, $"权限不足!需要 【{enterAttr.AuthorityLevel}】 权限!");
                return(false);
            }

            return(!enterAttr.IsTesting || Global.TestGroups.Contains(MsgDTO.FromGroup));
        }