Пример #1
0
        /// <summary>消息处理实现
        /// </summary>
        /// <returns></returns>
        public override bool HandleMsg_Do(RobotCmd pRobotCmd)
        {
            Msg msg = pRobotCmd.MsgInfo;

            if (msg.msgType.ToString().ToUpper() != "TEXT")
            {
                return(false);
            }

            //解析命令
            string strCmd = pRobotCmd.CmdInfos.Cmdstr;

            switch (strCmd)
            {
            case "行情":
                return(_Done_Quote_query(msg, pRobotCmd));

            case "行情监测":
                return(_Done_Quote_MonitorSet(msg, pRobotCmd));

            default:
                break;
            }
            return(false);
        }
Пример #2
0
        //行情查询
        protected internal bool _Done_Quote_query(Msg msg, RobotCmd pRobotCmd, typePermission_PowerRobot pPermission = typePermission_PowerRobot.ReadOnly)
        {
            //用户权限判断
            Power_Robot pPowerRobot = pRobotCmd.CmdInfos.PowerRobot;

            if (!this._Check_Permission_usr(pPermission, msg, pPowerRobot))
            {
                return(false);
            }


            //提取行情API配置
            string            stockName    = ((CmdInfos_QuoteQuantify)pRobotCmd.CmdInfos).StockName;
            List <Data_Quote> lstDataQuote = Quote_Manager._Manager.QuoteQuery.Query(stockName);

            if (lstDataQuote == null)
            {
                this.NotifyMsg(string.Format("行情(stockName)查询识别!", stockName), msg, "行情信息");
                return(false);
            }

            //循环生成数据对象
            foreach (var pQuote in lstDataQuote)
            {
                string strMsg = pQuote.GetMsg_Perfix();
                zxcConsoleHelper.Debug(true, "行情信息:\n{0}", strMsg);
                this.NotifyMsg(strMsg, msg, "行情信息");
            }
            return(true);
        }
Пример #3
0
        /// <summary>消息处理实现
        /// </summary>
        /// <returns></returns>
        public override bool HandleMsg_Do(RobotCmd pRobotCmd)
        {
            Msg msg = pRobotCmd.MsgInfo;

            if (msg.msgType.ToString().ToUpper() != "TEXT")
            {
                return(false);
            }

            //解析命令
            string strCmd = pRobotCmd.CmdInfos.Cmdstr;

            switch (strCmd)
            {
            case "新增":
                return(_Done_Points_operation(msg, pRobotCmd));

            case "识字":
                return(_Done_Points_StudyWord(msg, pRobotCmd));

            case "识字ok":
                return(_Done_Points_StudyWord_ok(msg, pRobotCmd));

            default:
                return(_Done_Points_operation(msg, pRobotCmd, pRobotCmd.CmdInfos.CmdPermission));
            }
            return(false);
        }
Пример #4
0
        /// <summary>消息处理注册
        /// </summary>
        /// <param name="usr">用户对象</param>
        /// <param name="bRegistOut">是否反注册</param>
        /// <returns></returns>
        public virtual string Done_Regist(IUser usr, Msg msg, bool bRegistOut = false, bool bSysTrigger = true)
        {
            if (msg == null)
            {
                return("");
            }
            if (msg.msg != _CmdStr)
            {
                return("");
            }

            //实例命令信息
            if (bSysTrigger)
            {
                RobotCmd pCmd = new RobotCmd(_CmdStr, msg);
                _Cmds.Add(pCmd);
            }

            //创建返回消息
            string strReturn = this._Title_User_Regist(usr, bRegistOut);

            if (this.NotifyMsg(strReturn, msg))
            {
                return(strReturn);
            }
            return("");
        }
Пример #5
0
        //积分添加
        protected internal bool _Done_Points_operation(Msg msg, RobotCmd pRobotCmd, typePermission_PowerRobot pPermission = typePermission_PowerRobot.Writable, string strReasonDetial = "")
        {
            //用户权限判断
            Power_Robot pPowerRobot = pRobotCmd.CmdInfos.PowerRobot;

            if (!this._Check_Permission_usr(pPermission, msg, pPowerRobot))
            {
                return(false);
            }

            //积分操作
            bool           checkPoints = pRobotCmd.CmdInfos.NoteLabel == "兑换" ? true : false;
            Data_PointsLog pDataLog    = _growthPoints.Add_Points((CmdInfos_PointsGrowth)pRobotCmd.CmdInfos, pPowerRobot.NameUserAlias, checkPoints);

            if (pDataLog != null)
            {
                string strPerfix = pDataLog.PointExChange > 0 ? "恭喜!" : "很遗憾!";
                string strMidfix = pDataLog.PointExChange > 0 ? "获得" + pDataLog.PointsNote_Label + "!" : pDataLog.PointsNote_Label == "兑换" ? "兑换成功!" : "被" + pDataLog.PointsNote_Label + "!";

                string strNumExChange = pDataLog.PointExChange > 0 ? "+" + pDataLog.PointExChange.ToString() : pDataLog.PointExChange.ToString();
                string strExchange    = pDataLog.PointExChange > 0 ? "新增" : "被扣除";
                string strReason      = strExchange.Replace("被", "") + "原由";
                string strRemark      = string.IsNullOrEmpty(pDataLog.Remark) ? "" : string.Format("({0}).", pDataLog.Remark);
                if (pDataLog.PointsNote_Label == "兑换")
                {
                    strReason = "兑换内容";
                }
                else if (pDataLog.PointsNote_Label == "奖励")
                {
                    strReason = "奖励原由";
                }

                if (pDataLog.IsValid)
                {
                    string strMsg = string.Format("{0}「{1}」{2} 个宝贝分.", strPerfix, pDataLog.PointsUser, strNumExChange);
                    strMsg = string.Format("{0}\n{1}:{2}{3}\n审核人:{4}\n当前分:{5} 宝贝分", strMsg, strReason, strReasonDetial != "" ? strReasonDetial : pDataLog.PointsNote, strRemark, pDataLog.PointsUser_OP, pDataLog.PointsNow);

                    zxcConsoleHelper.Debug(true, "宝贝分变动:{0}\n{1}", strMidfix, strMsg);
                    this.NotifyMsg(strMsg, msg, "宝贝分变动:" + strMidfix);
                    return(true);
                }
                else
                {
                    string strMsg = string.Format("{0}:{1}{2} \n兑换消耗:{3} 宝贝分 \n兑换失败:当前 {4} 宝贝分,不足以兑换.", strReason, pDataLog.PointsNote, strRemark, strNumExChange, pDataLog.PointsNow);
                    zxcConsoleHelper.Debug(true, "宝贝分提示:兑换失败!\n{0}", strMsg);
                    this.NotifyMsg(strMsg, msg, "宝贝分提示:兑换失败!");
                }
            }
            return(false);
        }
Пример #6
0
        //识字学习
        protected internal bool _Done_Points_StudyWord(Msg msg, RobotCmd pRobotCmd, typePermission_PowerRobot pPermission = typePermission_PowerRobot.Writable)
        {
            //用户权限判断
            Power_Robot pPowerRobot = pRobotCmd.CmdInfos.PowerRobot;

            if (!this._Check_Permission_usr(pPermission, msg, pPowerRobot))
            {
                return(false);
            }

            //汉字识字
            Word pWord = Word_Manager._Manager.GetWord_ByUser(pRobotCmd.CmdInfos.NoteUserTag);

            if (pWord == null)
            {
                this.NotifyMsg("字库汉字已经学完,请检查!", msg, "宝贝学习(识字)");
                return(false);
            }

            //信息提示
            CmdInfos_PointsGrowth pGrowthPoints = (CmdInfos_PointsGrowth)pRobotCmd.CmdInfos;
            string strMsg = string.Format("新汉字:【{0}】\n识字奖励:{1} 宝贝分.\n任务提示:回复字音,确认后获得奖励!\n发布人:{2}", pWord.WordStr, pGrowthPoints.PointsNum, pPowerRobot.NameUserAlias);

            this.NotifyMsg(strMsg, msg, "宝贝学习(识字)");


            //发送字形图片
            string strWordImg = pWord.Get_Image();

            this.NotifyMsg(strWordImg, msg, "", typeMsg.IMAGE);

            //发送字音文件
            string strWordSound = pWord.Get_Sound();

            this.NotifyMsg(strWordSound, msg, "", typeMsg.FILE);

            //发送字笔画gif
            //string strWordStrokesImg = pWord.Get_StrokesImage();
            //this.NotifyMsg(strWordStrokesImg, msg, "", typeMsg.IMAGE);

            //记录日志
            if (Word_Manager._Manager.InitWord_Record(pRobotCmd.CmdInfos.NoteUserTag, pWord, zxcStudy.Record.typeWordRecord.None, "已学"))
            {
                return(true);
            }
            return(false);
        }
Пример #7
0
        //积分添加
        protected internal bool _Done_Quote_MonitorSet(Msg msg, RobotCmd pRobotCmd, typePermission_PowerRobot pPermission = typePermission_PowerRobot.ReadOnly)
        {
            //用户权限判断
            Power_Robot pPowerRobot = pRobotCmd.CmdInfos.PowerRobot;

            if (!this._Check_Permission_usr(pPermission, msg, pPowerRobot))
            {
                return(false);
            }


            //提取行情API配置
            string stockName = ((CmdInfos_QuoteQuantify)pRobotCmd.CmdInfos).StockName;

            if (string.IsNullOrEmpty(stockName))
            {
                this.NotifyMsg("未指定标的名称,无法配置!", msg, "行情信息");
                return(false);
            }

            //检查标的信息
            bool isValid = stockName.Substring(0, 1) != "-";

            stockName = stockName.Replace("+", "").Replace("-", "");
            StockInfo pStockInfo = Quote_Manager._Manager.Stocks.Get_StockInfo(stockName);

            if (pStockInfo == null)
            {
                this.NotifyMsg(string.Format("标的({0})未识别!情检查确认。", stockName), msg, "行情信息");
                return(false);
            }

            //更新API监测配置
            if (Quote_Manager._Manager.QuoteMonitor._MonitorSets.Updata_APISets(pStockInfo.StockID_TagSina, isValid))
            {
                MonitorSet pSet   = Quote_Manager._Manager.QuoteMonitor._MonitorSets.Get_MonitorSet(pStockInfo.StockID_TagSina);
                string     strMsg = string.Format("标的({0}) {1} 行情监测。", pStockInfo.StockName, pSet == null ? "已移除" : pSet.IsValid ? "已启动" : "已暂停");
                zxcConsoleHelper.Debug(true, "行情信息:\n{0}", strMsg);
                this.NotifyMsg(strMsg, msg, "行情信息");
            }
            return(true);
        }
Пример #8
0
        /// <summary>处理消息
        /// </summary>
        /// <param name="msg"></param>
        /// <returns></returns>
        public override bool HandleMsg(Msg msg)
        {
            //解析命令
            RobotCmd pRobotCmd = this.Init_CmdInfo(msg);

            if (pRobotCmd == null)
            {
                return(false);
            }
            if (!pRobotCmd.CmdInfos.IsVaild)
            {
                return(false);
            }

            //剔除非命令触发(全命令触发类型)
            if (!_checkAllMsg && pRobotCmd.CmdInfos.Cmdstrs.Length <= 1)
            {
                return(false);
            }

            //权限检查
            if (!this.HandleMsg_Check(msg))
            {
                return(false);
            }

            //启动命令-注册/反注册
            if (pRobotCmd.Cmdstr == _CmdStr)
            {
                this.Done_Regist(null, pRobotCmd.MsgInfo, !this._Permission.IsRunning);
                _Cmds.Add(pRobotCmd);                    //记录命令信息
                return(true);
            }

            //消息处理
            if (this.HandleMsg_Do(pRobotCmd))
            {
                _Cmds.Add(pRobotCmd);                    //记录命令信息
                return(true);
            }
            return(false);
        }
Пример #9
0
        protected internal bool _Done_Points_StudyWord_ok(Msg msg, RobotCmd pRobotCmd, typePermission_PowerRobot pPermission = typePermission_PowerRobot.Writable)
        {
            //汉字识字
            Word        pWord   = Word_Manager._Manager.GetWord_ByUser(pRobotCmd.CmdInfos.NoteUserTag);
            Word_Record pRecord = Word_Manager._Manager._zxcWordRecords.Where(e => e.WordStr == pWord.WordStr && e.RecordType == typeWordRecord.None && e.IsDel == false).FirstOrDefault();

            if (pRecord == null)
            {
                this.NotifyMsg("当前没有正在学习的汉字,请检查!", msg, "宝贝学习(识字)");
                return(false);
            }

            //积分变动
            if (Word_Manager._Manager.InitWord_Record(pRobotCmd.CmdInfos.NoteUserTag, pWord, zxcStudy.Record.typeWordRecord.字形, "已学"))
            {
                _Done_Points_operation(msg, pRobotCmd, pPermission, string.Format("新识【{0}】字({1})", pWord.WordStr, zxcStudy.Record.typeWordRecord.字形.ToString()));
            }
            if (Word_Manager._Manager.InitWord_Record(pRobotCmd.CmdInfos.NoteUserTag, pWord, zxcStudy.Record.typeWordRecord.字音, "已学"))
            {
                _Done_Points_operation(msg, pRobotCmd, pPermission, string.Format("新识【{0}】字({1})", pWord.WordStr, zxcStudy.Record.typeWordRecord.字音.ToString()));
            }
            return(true);
        }
Пример #10
0
        /// <summary>消息处理实现
        /// </summary>
        /// <returns></returns>
        public override bool HandleMsg_Do(RobotCmd pRobotCmd)
        {
            Msg msg = pRobotCmd.MsgInfo;

            if (msg.msgType.ToString().ToUpper() != "NOTE")
            {
                return(false);
            }

            //解析通知
            string noteTag = "";

            if (msg.msg.IndexOf("撤回了一条消息") > 0)
            {
                noteTag = "REVOKE";
                return(this._Done_Revoke(msg));
            }
            else if (msg.msg.IndexOf("收到转账") > 0)
            {
                noteTag = "PAY";
                return(this._Done_Pay(msg));
            }
            return(false);
        }
Пример #11
0
 /// <summary>消息处理实现
 /// </summary>
 /// <returns></returns>
 public virtual bool HandleMsg_Do(RobotCmd pRobotCmd)
 {
     return(true);
 }
Пример #12
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);
        }