Exemple #1
0
        /// <summary>
        /// Center to handler all incoming text messages
        /// </summary>
        /// <returns></returns>
        public string MsgCenterHandler()
        {
            if (msg.Length <= 0)
            {
                Help help = new Help(CTYPE.C_HELP);
                return help.getHelp();
            }

            StringBuilder sb = new StringBuilder();

            if (vc.p.bInBlacklist)
            {
                sb.Append("You are in the blacklist");
                return sb.ToString();
            }
            CTYPE t = cg.GetCategoryType(Parameters[0]);

            //Trap for delivery
            if (t >= CTYPE.C_DELIVERY_START && t <= CTYPE.C_DELIVERY_END)
            {
                Delivery delivery = new Delivery(t, Parameters);
                return delivery.GetStatus();
            }

            //trap for 星座
            if (t >= CTYPE.C_XZ_START && t <= CTYPE.C_XZ_END)
            {
                Robot.Asterism.Asterism asterism = new Robot.Asterism.Asterism(Parameters);
                return asterism.GetStatus();
            }

            switch (t)
            {
                case CTYPE.C_WEATHER:
                    if (Parameters.Count > 1)
                    {
                        w = new CommonService.Weather.Weather(Parameters[1]);
                    }
                    else
                    {
                        w = new CommonService.Weather.Weather();
                    }
                    sb.Append(w.GetWeather());
                    break;
                case CTYPE.C_MAP:
                    map m = new map(Parameters);
                    sb.Append(m.GetData());
                    break;
                case CTYPE.C_SEARCH:
                    //sb.Append("Not sure what you are looking for!");
                    break;
                case CTYPE.C_YP:
                    yp = new yp_oversea(Parameters);
                    break;
                case CTYPE.C_TRANS:
                    yd = new YouDao(Parameters);
                    sb.Append(yd.GetResult());
                    break;
                case CTYPE.C_HELP:
                    Help help = new Help(CTYPE.C_HELP);
                    sb.Append(help.getHelp());
                    break;
                case CTYPE.C_SAVE:
                    break;
                case CTYPE.C_MEM:
                    break;
                //Grab currency data from china bank
                case CTYPE.C_CURRENCY:
                    ChinaBank cb = new ChinaBank(Parameters);
                    sb.Append(cb.GrabData());
                    break;
                //贵金属
                case CTYPE.C_METAL:
                    Metal metal = new Metal();
                    sb.Append(metal.GetPrice());
                    break;
                case CTYPE.C_SUGGESTION:
                    Suggestion sug = new Suggestion(userId, Parameters, DateTime.Now.ToString());
                    sb.Append(sug.SaveSug());
                    break;
                case CTYPE.C_REPEAT:
                    break;
                case CTYPE.C_FUEL_PRICE:
                    FuelPrice price = new FuelPrice(Parameters);
                    sb.Append(price.GetPrice());
                    break;
                case CTYPE.C_RSS:
                    RSS rss = new RSS(Parameters);
                    sb.Append(rss.GetSummary());
                    break;
                case CTYPE.C_TEST:
                    sb.Append("<a href='www.google.com'>more</a>");
                    break;
                //小黄鸡功能
                default:
                    if (bAnalytised)
                    {
                        sb.Append("亲爱的用户,你所输入的内容我们尚未能识别,如果您对该部分内容感兴趣,可以发送 【建议  您的建议内容,您的联系方式】给我们,我们的开发人员会尽力为您开发该功能。请发送 【help】查询我们已经开发好的功能。(发送时请不要带大括号)");
                    }
                    else
                    {
                        sb.Append(reUnion(msg));
                    }
                    //robot_yc yc = new robot_yc();
                    //sb.Append(yc.getResponse(msg));
                    break;
            }
            return sb.ToString();
        }
Exemple #2
0
        /// <summary>
        /// Center to handler all incoming text messages
        /// </summary>
        /// <returns></returns>
        public string MsgCenterHandler()
        {
            if (msg.Length <= 0)
            {
                Help help = new Help(CTYPE.C_HELP);
                return(help.getHelp());
            }

            StringBuilder sb = new StringBuilder();

            if (vc.p.bInBlacklist)
            {
                sb.Append("You are in the blacklist");
                return(sb.ToString());
            }
            CTYPE t = cg.GetCategoryType(Parameters[0]);

            //Trap for delivery
            if (t >= CTYPE.C_DELIVERY_START && t <= CTYPE.C_DELIVERY_END)
            {
                Delivery delivery = new Delivery(t, Parameters);
                return(delivery.GetStatus());
            }

            //trap for 星座
            if (t >= CTYPE.C_XZ_START && t <= CTYPE.C_XZ_END)
            {
                Robot.Asterism.Asterism asterism = new Robot.Asterism.Asterism(Parameters);
                return(asterism.GetStatus());
            }

            switch (t)
            {
            case CTYPE.C_WEATHER:
                if (Parameters.Count > 1)
                {
                    w = new CommonService.Weather.Weather(Parameters[1]);
                }
                else
                {
                    w = new CommonService.Weather.Weather();
                }
                sb.Append(w.GetWeather());
                break;

            case CTYPE.C_MAP:
                map m = new map(Parameters);
                sb.Append(m.GetData());
                break;

            case CTYPE.C_SEARCH:
                //sb.Append("Not sure what you are looking for!");
                break;

            case CTYPE.C_YP:
                yp = new yp_oversea(Parameters);
                break;

            case CTYPE.C_TRANS:
                yd = new YouDao(Parameters);
                sb.Append(yd.GetResult());
                break;

            case CTYPE.C_HELP:
                Help help = new Help(CTYPE.C_HELP);
                sb.Append(help.getHelp());
                break;

            case CTYPE.C_SAVE:
                break;

            case CTYPE.C_MEM:
                break;

            //Grab currency data from china bank
            case CTYPE.C_CURRENCY:
                ChinaBank cb = new ChinaBank(Parameters);
                sb.Append(cb.GrabData());
                break;

            //贵金属
            case CTYPE.C_METAL:
                Metal metal = new Metal();
                sb.Append(metal.GetPrice());
                break;

            case CTYPE.C_SUGGESTION:
                Suggestion sug = new Suggestion(userId, Parameters, DateTime.Now.ToString());
                sb.Append(sug.SaveSug());
                break;

            case CTYPE.C_REPEAT:
                break;

            case CTYPE.C_FUEL_PRICE:
                FuelPrice price = new FuelPrice(Parameters);
                sb.Append(price.GetPrice());
                break;

            case CTYPE.C_RSS:
                RSS rss = new RSS(Parameters);
                sb.Append(rss.GetSummary());
                break;

            case CTYPE.C_TEST:
                sb.Append("<a href='www.google.com'>more</a>");
                break;

            //小黄鸡功能
            default:
                if (bAnalytised)
                {
                    sb.Append("亲爱的用户,你所输入的内容我们尚未能识别,如果您对该部分内容感兴趣,可以发送 【建议  您的建议内容,您的联系方式】给我们,我们的开发人员会尽力为您开发该功能。请发送 【help】查询我们已经开发好的功能。(发送时请不要带大括号)");
                }
                else
                {
                    sb.Append(reUnion(msg));
                }
                //robot_yc yc = new robot_yc();
                //sb.Append(yc.getResponse(msg));
                break;
            }
            return(sb.ToString());
        }