Example #1
0
 /// <summary>初始解析后消息内容
 /// </summary>
 /// <param name="cmdInfos"></param>
 /// <returns></returns>
 public bool Init_CmdInfos(RobotCmd_Infos cmdInfos = null)
 {
     _CmdInfos = cmdInfos;
     return(true);
 }
Example #2
0
        //初始机器人功能命令信息
        protected internal virtual RobotCmd Init_CmdInfo(Msg msg)
        {
            if (msg == null)
            {
                return(null);
            }

            //解析命令
            string strCmd = msg.msg.Trim();

            if (strCmd.Length < 2)
            {
                return(null);
            }
            if (!_checkAllMsg && strCmd.Substring(0, 1) != "@")
            {
                return(null);
            }

            //提取命令头
            string perfixCmd = strCmd.Substring(0, 2);
            bool   bStartCmd = strCmd.Length >= _CmdStr.Length && strCmd.Substring(0, _CmdStr.Length) == _CmdStr;

            if (perfixCmd != "@@" && perfixCmd != "@*")
            {
                //@个人
                if (!_checkAllMsg)
                {
                    return(null);
                }
                else
                {
                    perfixCmd = "";
                }
            }

            //解析命令
            string[] strCmds    = strCmd.Split(perfixCmd);
            string   strCmdtemp = strCmds.Length <= 1 ? strCmds[0] : strCmds[1];

            strCmds = strCmdtemp.Split(" ");
            strCmd  = strCmds[0];

            //启动命令检测
            if (bStartCmd)
            {
                strCmd = "@@" + strCmd;
                if (strCmds.Length - 1 != 1)
                {
                    return(null);
                }
                if (strCmd != _CmdStr)
                {
                    return(null);
                }
            }

            //解析命令
            Power_Robot    pPower   = _Permission.Get_Permission(_Permission._configTag, msg.GetNameGroup(), msg.GetNameUser(), msg.usrPlat.ToString());
            RobotCmd_Infos cmdInfos = this._Init_CmdInfo(strCmds, pPower);

            //初始命令信息
            RobotCmd pRobotCmd = new RobotCmd(strCmd, msg, cmdInfos);

            //_Cmds.Add(pRobotCmd);                    //记录命令信息
            return(pRobotCmd);
        }
Example #3
0
 public RobotCmd(string cmdstr, Msg msgInfo, RobotCmd_Infos cmdInfos = null)
 {
     Cmdstr   = cmdstr;
     _MsgInfo = msgInfo;
     this.Init_CmdInfos(cmdInfos);
 }