Пример #1
0
        protected static MsgTalkMessage json2MsgSummaryNews(ResLpsSummaryNews2Json rlsn2)
        {
            //結果メッセージを作成
            MsgTalkMessage msg = new MsgTalkMessage();

            //リザルトSB
            StringBuilder sbResult = new StringBuilder();

            //ネームリスト、等作成
            foreach (string desc in rlsn2.descriptionList)
            {
                //ネームリストに追記
                msg.createList(desc);

                //全文章追記
                sbResult.Append(msg.result);
            }

            //最後のあっとまーくを除去する
            if (msg.nameList.Count > 0)
            {
                if (msg.nameList[msg.nameList.Count - 1] == "@")
                {
                    int targetIndex = msg.nameList.Count - 1;
                    msg.nameList.RemoveAt(targetIndex);
                    msg.emotionList.RemoveAt(targetIndex);
                    msg.pointList.RemoveAt(targetIndex);
                }
            }

            //EOSの除去
            string result = sbResult.ToString().Replace("EOS", "");

            //結果をメッセージに格納
            msg.url    = LpsLiplisUtil.nullCheck(rlsn2.url);
            msg.title  = LpsLiplisUtil.nullCheck(rlsn2.title);
            msg.result = result;
            msg.sorce  = result;
            msg.jpgUrl = "";
            msg.calcNewsEmotion();

            ///jpgURLのセット
            if (rlsn2.jpgUrl != null)
            {
                if (!rlsn2.jpgUrl.Equals(""))
                {
                    msg.jpgUrl = rlsn2.jpgUrl;
                }
            }
            return(msg);
        }
Пример #2
0
        /// <summary>
        /// 適当なニュースを取得する
        /// </summary>
        /// <returns></returns>
        public MsgTopic CreateTopicFromShortNews()
        {
            //一人のデータを取得する
            LiplisModel charData = GetCharacterRandam();

            //おしゃべりメッセージを取得
            MsgTalkMessage msg = ClalisShortNews.getShortNews("", "", "");

            //トピックを生成
            MsgTopic topic = new MsgTopic(charData.Tone, msg.sorce, msg.sorce, 0, 0, false, charData.AllocationId);

            //ショートニュースからトピックを生成する
            return(topic);
        }
Пример #3
0
        protected static MsgTalkMessage json2MsgShortNews(ResLpsShortNews2Json rlsn2)
        {
            //結果メッセージを作成
            MsgTalkMessage msg = new MsgTalkMessage();

            //リザルトSB
            StringBuilder sbResult = new StringBuilder();

            //ネームリスト、等作成
            string[] bufList = rlsn2.result.Split(';');

            foreach (string buf in bufList)
            {
                try
                {
                    string[] bufList2 = buf.Split(',');

                    if (buf.Length < 3)
                    {
                        break;
                    }

                    msg.nameList.Add(bufList2[0]);
                    msg.emotionList.Add(int.Parse(bufList2[1]));
                    msg.pointList.Add(int.Parse(bufList2[2]));
                    sbResult.Append(bufList2[0]);
                }
                catch
                {
                }
            }

            string result = sbResult.ToString().Replace("EOS", "");

            //結果をメッセージに格納
            msg.url    = rlsn2.url;
            msg.title  = result;
            msg.result = result;
            msg.sorce  = result;
            msg.calcNewsEmotion();
            msg.jpgUrl = "";

            return(msg);
        }
Пример #4
0
        public static MsgTalkMessage getShortNews(string uid, string toneUrl, string newsFlg)
        {
            MsgTalkMessage msg = new MsgTalkMessage();

            try
            {
                NameValueCollection ps = new NameValueCollection();
                ps.Add("tone", toneUrl);                //TONE_URLの指定
                ps.Add("newsFlg", newsFlg);             //NEWS_FLGの指定

                //Jsonで結果取得
                string jsonText = HttpPost.sendPost(LpsDefine.LIPLIS_API_SHORT_NEWS, ps);

                //APIの結果受け取り用クラス
                ResLpsShortNews2Json result = JsonConvert.DeserializeObject <ResLpsShortNews2Json>(jsonText);

                //結果を返す
                return(LiplisNewsJpJson.getShortNews(result));
            }
            catch
            {
                return(msg);
            }
        }