Example #1
0
        public static MsgShortNews createMsgMassageDlFaild()
        {
            MsgShortNews msg = new MsgShortNews();

            msg.result = "データの取得に失敗しました。";

            msg.nameList.Add("データ");
            msg.nameList.Add("の");
            msg.nameList.Add("取得");
            msg.nameList.Add("に");
            msg.nameList.Add("失敗");
            msg.nameList.Add("し");
            msg.nameList.Add("まし");
            msg.nameList.Add("た。");

            msg.emotionList.Add(1);
            msg.emotionList.Add(1);
            msg.emotionList.Add(1);
            msg.emotionList.Add(1);
            msg.emotionList.Add(1);
            msg.emotionList.Add(1);
            msg.emotionList.Add(1);
            msg.emotionList.Add(1);

            msg.pointList.Add(-1);
            msg.pointList.Add(-1);
            msg.pointList.Add(-1);
            msg.pointList.Add(-1);
            msg.pointList.Add(-1);
            msg.pointList.Add(-1);
            msg.pointList.Add(-1);
            msg.pointList.Add(-1);

            return msg;
        }
Example #2
0
        public static void setTag(MsgShortNews msg)
        {
            //ソースで既に振られてくるため廃止
            //HTMLリンクにタグを付与する
            msg.result = LpsRegularEx.fctReplaceHtmlLink(msg.result);

            //動画IDにタグを付与する
            msg.result = LpsRegularEx.fctReplaceNicoVideoId(msg.result);

            //myリストにタグを付与する
            msg.result = LpsRegularEx.fctReplaceNicoMyListId(msg.result);

            //BR変換
            msg.result = LpsRegularEx.fctReplaceNewLine(msg.result);

            //連続びっくりマークを統合
            LpsRegularEx.fctBikkuriTogo(msg.result);
        }
        /// <summary>
        /// APIにポストする
        /// </summary>
        /// <param name="uid"></param>
        /// <param name="toneUrl"></param>
        /// <param name="version"></param>
        /// <param name="sentence"></param>
        public MsgShortNews apiPost(string uid, string toneUrl, string newsFlg)
        {
            MsgShortNews msg = new MsgShortNews();
            try
            {
                LpsLogControllerCus.d("getSummaryNews");
                NameValueCollection ps = new NameValueCollection();
                ps.Add("tone", toneUrl);                //TONE_URLの指定
                ps.Add("newsFlg", newsFlg);             //NEWS_FLGの指定

                //パラメーター設定
                object[] obj = new object[5];

                obj[0] = LiplisDefine.LIPLIS_API_SUMMARY_NEWS;
                obj[1] = ps;

                //スレッドでポストする
                Thread thread = new Thread(new ParameterizedThreadStart(postThread));
                thread.Start(obj);

                //スレッドの終了を待つ
                while (thread.IsAlive)
                {
                    Thread.Sleep(100);
                }

                //タグの付与
                FctTagFactory.setTag(msg);

                //結果を返す
                return convertRlSumNjToMsg(result);
            }
            catch
            {
                return msg;
            }
        }
Example #4
0
        public void chatGetResponse(MsgShortNews msn)
        {
            //応答が0件以上なら
            if (msn.nameList.Count > 0)
            {
                //ニュートラルに戻しておく
                setObjectBodyNeutral();
                //チャットトークなのでフラグをオン
                flgChatTalk = true;
                //返答をしゃべる。
                talk(msn);

                StringBuilder sb = new StringBuilder();

                foreach (string name in msn.nameList)
                {
                    sb.Append(name);
                }
            }
            //応答件数が0なら
            else
            {
                //何をおっしゃられているか分かりません・・・・。

                //ウインドウに表示
                //act.setResponse(olc.getChatWordStr("noreply"));
            }
        }
Example #5
0
 protected bool checkSitdown()
 {
     try
     {
         if(flgSitdown)
         {
             liplisNowTopic = null;
             updateBodySitDown();
             return true;
         }
         return false;
     }
     catch(Exception err)
     {
         LpsLogControllerCus.writingLog(this.GetType().Name, MethodBase.GetCurrentMethod().Name, err.ToString());
          return false;
     }
 }
Example #6
0
 protected bool checkMinimize()
 {
     try
     {
         if(flgMinimize)
         {
             reSetUpdateCount();
             liplisNowTopic = null;
             checkEnd();
             return true;
         }
         return false;
     }
     catch(Exception err)
     {
         LpsLogControllerCus.writingLog(this.GetType().Name, MethodBase.GetCurrentMethod().Name, err.ToString());
          return false;
     }
 }
        public MsgShortNews getChatWord(string pType, string name)
        {
            MsgShortNews result = new MsgShortNews();
            int idx = 0;

            //対象インデックスリスト
            List<int> resList = new List<int>();

            //時間に合致する挨拶を検索
            foreach (string type in typeList)
            {
                //挨拶なら対象
                if (type.Equals(pType) && nameList[idx].Equals(name))
                {
                    resList.Add(idx);
                }
                idx++;
            }

            //候補が置ければ1個目を取得
            if (resList.Count > 0)
            {
                if (nameList.Count > 0)
                {
                    Random rnd = new Random();

                    int ran = rnd.Next(resList.Count);
                    int tarIdx = resList[ran];

                    try
                    {
                        result = new MsgShortNews(discriptionList[tarIdx], emotionList[tarIdx], emotionList[tarIdx]);
                    }
                    catch (Exception)
                    {
                        result = new MsgShortNews("", 0, 0);
                    }
                }
                else
                {
                    result = new MsgShortNews("", 0, 0);
                }
            }

            return result;
        }
        protected static MsgShortNews convertRlSumNjToMsg(ResLpsSummaryNews2Json rlsn2)
        {
            //ディスクリプションチェック
            if (rlsn2.descriptionList.Count < 1)
            {
                return FctLiplisMsg.createMsgMassageDlFaild();
            }

            //結果メッセージを作成
            MsgShortNews msg = new MsgShortNews();

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

            //ネームリスト、等作成
            foreach (string desc in rlsn2.descriptionList)
            {
                try
                {
                    string[] bufList = desc.Split(';');

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

                        if (bufList2.Length == 3)
                        {
                            msg.nameList.Add(bufList2[0]);
                            msg.emotionList.Add(int.Parse(bufList2[1]));
                            msg.pointList.Add(int.Parse(bufList2[2]));
                            sbResult.Append(bufList2[0]);
                        }
                        else
                        {

                        }
                    }
                }
                catch
                {

                }
            }

            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.calcNewsEmotion();

            ///jpgのダウンロード
            if (rlsn2.jpgUrl != null && !rlsn2.jpgUrl.Equals(""))
            {
                msg.jpgUrl = LiplisWedFileDownLoader.downLoadthumb(rlsn2.jpgUrl);
            }
            else
            {
                msg.jpgUrl = "";
            }

            return msg;
        }
        public static MsgShortNews getFreeWord(string sentence,string tone)
        {
            MsgShortNews msg = new MsgShortNews();
            try
            {
                LpsLogControllerCus.d("getFreeWord");
                NameValueCollection ps = new NameValueCollection();

                ps.Add("tone", tone);                //TONE_URLの指定
                ps.Add("sentence", sentence);             //NEWS_FLGの指定

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

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

                //結果を返す
                return convertRlShtNjToMsg(result);
            }
            catch
            {
                return msg;
            }
        }
Example #10
0
 protected bool checkEnd()
 {
     try
     {
         chatStop();
         flgSkipping = false;
         herfEyeCheck();
         if (liplisNowTopic != null)
         {
             if (!flgChatTalk)
             {
                 appendLog();
             }
             else
             {
                 appendChatTalk();
             }
         }
         liplisNowTopic = null;
         return true;
     }
     catch(Exception err)
     {
         LpsLogControllerCus.writingLog(this.GetType().Name, MethodBase.GetCurrentMethod().Name, err.ToString());
         return false;
     }
 }
Example #11
0
        protected void talkBatteryInfo()
        {
            try
            {
                //チャットを停止させておく
                chatStop();

                //バッテリーのセリフを取得
                liplisNowTopic = olc.getBatteryInfo(liplisBatteryLevel, obtry.batteryExists);

                //チャット情報の初期化
                initChatInfo();

                //トークアクティビティの初期化
                initActivityTalk();

                //おしゃべりスレッドスタート
                chatStart();

                LpsLogControllerCus.d("コンバーティッド * " + liplisNowTopic.result);
            }
            catch (Exception err)
            {
                LpsLogControllerCus.writingLog(this.GetType().Name, MethodBase.GetCurrentMethod().Name, err.ToString());
            }
        }
Example #12
0
        protected void talk(string talkString, int emotion)
        {
            try
            {
                //チャットを停止させておく
                chatStop();

                //なうトピックを上書き
                liplisNowTopic = new MsgShortNews(talkString, emotion, emotion);

                //チャット情報の初期化
                initChatInfo();

                //トークアクティビティの初期化
                initActivityTalk();

                //おしゃべりスレッドスタート
                chatStart();
                }
            catch (Exception err)
            {
                LpsLogControllerCus.writingLog(this.GetType().Name, MethodBase.GetCurrentMethod().Name, err.ToString());
            }
        }
Example #13
0
        protected bool getTopic()
        {
            try
            {
                flgThinking = true;
                updateThinkingIcon();

                //ショートニュース取得
                liplisNowTopic = otp.getTopic();

                //ver4.0.1
                //ツイッター内容控え
                liplisTweetMessege = liplisNowTopic.sorce;
                liplisTweetMessegeTitle = liplisNowTopic.title;

                flgThinking = false;
                updateThinkingIcon();

                //話題取得の可否を返す
                return liplisNowTopic != null;
            }
            catch (Exception err)
            {
                flgThinking = false;
                updateThinkingIcon();
                LpsLogControllerCus.writingLog(this.GetType().Name, MethodBase.GetCurrentMethod().Name, err.ToString());

                return false;
            }
        }
        private MsgShortNews getMacheGreet(LstShufflableList<int> idxList)
        {
            MsgShortNews result = new MsgShortNews();
            LstShufflableList<int> resList = new LstShufflableList<int>();
            string[] timeList;
            string[] startList;
            string[] endList;

            int nowHour = 0;
            int nowMin = 0;
            int startHour = 0;
            int startMin = 0;
            int endHour = 0;
            int endMin = 0;

            try
            {
                //インデックスリストを回してチェック
                foreach (int idx in idxList)
                {
                    Application.DoEvents();
                    try
                    {
                        if (!prerewuisteList[idx].Equals(""))
                        {
                            timeList = prerewuisteList[idx].Split(',');

                            startList = timeList[0].Split(':');
                            endList = timeList[1].Split(':');

                            if (startList.Length == 2 && endList.Length == 2)
                            {
                                DateTime cal1 = DateTime.Now;

                                nowHour = cal1.Hour;
                                nowMin = cal1.Minute;

                                startHour = int.Parse(startList[0]);
                                startMin = int.Parse(startList[1]);

                                endHour = int.Parse(endList[0]);
                                endMin = int.Parse(endList[1]);

                                //スタートアワーの場合、分を確認
                                if (nowHour == startHour && nowMin >= startMin)
                                {
                                    if (nowHour == endHour && nowMin <= endMin)
                                    {
                                        resList.Add(idx);
                                    }
                                    else if (nowHour < endHour)
                                    {
                                        resList.Add(idx);
                                    }
                                }
                                else if (nowHour >= startHour)
                                {
                                    if (nowHour == endHour && nowMin <= endMin)
                                    {
                                        resList.Add(idx);
                                    }
                                    else if (nowHour < endHour)
                                    {
                                        resList.Add(idx);
                                    }
                                }
                            }
                        }
                    }
                    catch
                    {
                        continue;
                    }

                }

                //取得したけっかから一つ選んで返す
                if (resList.Count > 0)
                {
                    if (nameList.Count > 0)
                    {
                        resList.Shuffle();
                        int tarIdx = resList[0];

                        try
                        {
                            result = new MsgShortNews(discriptionList[tarIdx] + " ", emotionList[tarIdx], emotionList[tarIdx]);
                        }
                        catch
                        {
                            result = new MsgShortNews("", 0, 0);
                        }
                    }
                    else
                    {
                        result = new MsgShortNews("", 0, 0);
                    }
                }

                //取得グリートメッセージのあっとマークを改行に変換しておく
                result.result = result.result.Replace("@", Environment.NewLine);

                return result;
            }
            catch
            {
                return new MsgShortNews("", 0, 0);
            }
        }
        public MsgShortNews getTimeSignal(int hour)
        {
            MsgShortNews result = new MsgShortNews();
            MsgShortNews buf;

            try
            {
                switch (hour)
                {
                    case 1: buf = getChatWord("1Oclock"); return new MsgShortNews(buf.nameList[0], buf.emotionList[0], buf.pointList[0]);
                    case 2: buf = getChatWord("2Oclock"); return new MsgShortNews(buf.nameList[0], buf.emotionList[0], buf.pointList[0]);
                    case 3: buf = getChatWord("3Oclock"); return new MsgShortNews(buf.nameList[0], buf.emotionList[0], buf.pointList[0]);
                    case 4: buf = getChatWord("4Oclock"); return new MsgShortNews(buf.nameList[0], buf.emotionList[0], buf.pointList[0]);
                    case 5: buf = getChatWord("5Oclock"); return new MsgShortNews(buf.nameList[0], buf.emotionList[0], buf.pointList[0]);
                    case 6: buf = getChatWord("6Oclock"); return new MsgShortNews(buf.nameList[0], buf.emotionList[0], buf.pointList[0]);
                    case 7: buf = getChatWord("7Oclock"); return new MsgShortNews(buf.nameList[0], buf.emotionList[0], buf.pointList[0]);
                    case 8: buf = getChatWord("8Oclock"); return new MsgShortNews(buf.nameList[0], buf.emotionList[0], buf.pointList[0]);
                    case 9: buf = getChatWord("9Oclock"); return new MsgShortNews(buf.nameList[0], buf.emotionList[0], buf.pointList[0]);
                    case 10: buf = getChatWord("10Oclock"); return new MsgShortNews(buf.nameList[0], buf.emotionList[0], buf.pointList[0]);
                    case 11: buf = getChatWord("11Oclock"); return new MsgShortNews(buf.nameList[0], buf.emotionList[0], buf.pointList[0]);
                    case 12: buf = getChatWord("12Oclock"); return new MsgShortNews(buf.nameList[0], buf.emotionList[0], buf.pointList[0]);
                    case 13: buf = getChatWord("13Oclock"); return new MsgShortNews(buf.nameList[0], buf.emotionList[0], buf.pointList[0]);
                    case 14: buf = getChatWord("14Oclock"); return new MsgShortNews(buf.nameList[0], buf.emotionList[0], buf.pointList[0]);
                    case 15: buf = getChatWord("15Oclock"); return new MsgShortNews(buf.nameList[0], buf.emotionList[0], buf.pointList[0]);
                    case 16: buf = getChatWord("16Oclock"); return new MsgShortNews(buf.nameList[0], buf.emotionList[0], buf.pointList[0]);
                    case 17: buf = getChatWord("17Oclock"); return new MsgShortNews(buf.nameList[0], buf.emotionList[0], buf.pointList[0]);
                    case 18: buf = getChatWord("18Oclock"); return new MsgShortNews(buf.nameList[0], buf.emotionList[0], buf.pointList[0]);
                    case 19: buf = getChatWord("19Oclock"); return new MsgShortNews(buf.nameList[0], buf.emotionList[0], buf.pointList[0]);
                    case 20: buf = getChatWord("20Oclock"); return new MsgShortNews(buf.nameList[0], buf.emotionList[0], buf.pointList[0]);
                    case 21: buf = getChatWord("21Oclock"); return new MsgShortNews(buf.nameList[0], buf.emotionList[0], buf.pointList[0]);
                    case 22: buf = getChatWord("22Oclock"); return new MsgShortNews(buf.nameList[0], buf.emotionList[0], buf.pointList[0]);
                    case 23: buf = getChatWord("23Oclock"); return new MsgShortNews(buf.nameList[0], buf.emotionList[0], buf.pointList[0]);
                    case 0: buf = getChatWord("24Oclock"); return new MsgShortNews(buf.nameList[0], buf.emotionList[0], buf.pointList[0]);

                    default:
                        return result;
                }
            }
            catch (Exception)
            {
                return new MsgShortNews("[?]%", 1, 1);
            }
        }
Example #16
0
        protected void standupGreet()
        {
            //挨拶の選定
            liplisNowTopic = olc.getGreetMessage(LiplisDefine.CHAT_DEF_GREET);

            //空だったらろーでぃんぐなう♪
            if (liplisNowTopic.getMessage().Equals(""))
            {
                liplisNowTopic = new MsgShortNews("ろーでぃんぐなう♪", 0, 0);
            }

            //チャット情報の初期化
            initChatInfo();

            //トークアクティビティの初期化
            initActivityTalk();

            //おしゃべりスレッドスタート
            chatStart();
        }
Example #17
0
        public void talk(MsgShortNews talkMessage)
        {
            try
            {
                //チャットを停止させておく
                chatStop();

                //なうトピックを上書き
                liplisNowTopic = talkMessage;

                //チャット情報の初期化
                initChatInfo();

                //トークアクティビティの初期化
                initActivityTalk();

                //おしゃべりスレッドスタート
                chatStart();
            }
            catch (Exception err)
            {
                LpsLogControllerCus.writingLog(this.GetType().Name, MethodBase.GetCurrentMethod().Name, err.ToString());
            }
        }
        protected MsgShortNews convertRlSumNjToMsg(ResLpsChatResponse rlsn2)
        {
            //ディスクリプションチェック
            if (rlsn2 == null || rlsn2.descriptionList.Count < 1)
            {
                return lips.getOlc().getChatWord("noreply");
            }

            //結果メッセージを作成
            MsgShortNews msg = new MsgShortNews();

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

            //ネームリスト、等作成
            foreach (string desc in rlsn2.descriptionList)
            {
                try
                {
                    string[] bufList = desc.Split(';');

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

                        if (bufList2.Length == 3)
                        {
                            msg.nameList.Add(bufList2[0]);
                            msg.emotionList.Add(int.Parse(bufList2[1]));
                            msg.pointList.Add(int.Parse(bufList2[2]));
                            sbResult.Append(bufList2[0]);
                        }
                        else
                        {

                        }
                    }
                }
                catch
                {

                }
            }

            //データの作成
            msg.result = sbResult.ToString();
            msg.sorce = sbResult.ToString();
            msg.title = "";

            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.calcNewsEmotion();

            //
            if(rlsn2.opList.Count == 2)
            {
                this.context = rlsn2.opList[0];
                this.mode = rlsn2.opList[1];
            }

            return msg;
        }
 public void addLog(MsgShortNews msg, Bitmap charBody)
 {
     addPanel(msg.url, msg.title, msg.sorce, msg.jpgUrl, msg.newsEmotion, msg.newsPoint, charBody);
 }
Example #20
0
        public void updateTopicList(RssReader rr)
        {
            int idx = 0;

            //更新件数チェック
            if (rr.urlList.Count <= 0)
            {
                return;
            }

            //ヌチェック
            if (topicList == null) { topicList = new List<MsgShortNews>(); }

            //URL1件目チェック
            if (this.topicList.Count > 0)
            {
                //1件目が同じなら未更新と判断
                if (this.topicList[0].url.Equals(rr.urlList[0]))
                {
                    return;
                }
            }

            List<MsgShortNews> newTopicList = new List<MsgShortNews>();

            //更新する
            foreach (string url in rr.urlList)
            {
                MsgShortNews n = new MsgShortNews();
                try
                {
                    n.url = url;
                    n.title = rr.urlTitleList[idx];
                }
                catch
                {
                    Console.WriteLine("ニュース収集エラー");
                }

                newTopicList.Add(n);

                idx++;
            }

            //更新完了
            topicList = newTopicList;
        }
Example #21
0
        public static MsgShortNews getSummaryNews(string uid, string toneUrl, string newsFlg)
        {
            MsgShortNews msg = new MsgShortNews();
            try
            {
                LpsLogControllerCus.d("getSummaryNews");
                NameValueCollection ps = new NameValueCollection();
                ps.Add("tone", toneUrl);                //TONE_URLの指定
                ps.Add("newsFlg", newsFlg);             //NEWS_FLGの指定

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

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

                //2013/06/23 ver3.0.2タグ付与のタイミングを変更
                //タグの付与
                FctTagFactory.setTag(msg);

                //結果を返す
                return convertRlSumNjToMsg(result);
            }
            catch
            {
                return msg;
            }
        }
Example #22
0
 protected bool checkEndError()
 {
     try
     {
         chatStop();
         liplisNowTopic = null;
         return true;
     }
     catch(Exception err)
     {
         LpsLogControllerCus.writingLog(this.GetType().Name, MethodBase.GetCurrentMethod().Name, err.ToString());
         return false;
     }
 }
Example #23
0
        private static MsgShortNews convertRlShtNjToMsg(ResLpsShortNews2Json rlsn2)
        {
            //結果メッセージを作成
            MsgShortNews msg = new MsgShortNews();

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

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

            foreach (string buf in bufList)
            {
                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]);
            }

            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;
        }
        public MsgShortNews getBatteryInfo(int batteryLevel, bool batteryExists)
        {
            MsgShortNews result;
            MsgShortNews batteryWord;
            String resStr = "";

            try
            {
                if (!batteryExists)
                {
                    //メッセージ作成
                    batteryWord = getChatWord("batteryNotFound");
                    return new MsgShortNews(batteryWord.nameList[0], batteryWord.emotionList[0], batteryWord.pointList[0]);
                }

                //電池容量のセリフを取得
                resStr = getChatWordStr("batteryInfo");

                //空だったら、電池格納用ワードを入れておく
                if (resStr.Equals(""))
                {
                    resStr = "[?]%";
                }

                //バッテリーレベルによってセリフを変える
                if (batteryLevel > 70)
                {
                    batteryWord = getChatWord("batteryHi");
                }
                else if (batteryLevel > 30)
                {
                    batteryWord = getChatWord("batteryMid");
                }
                else if (batteryLevel > 0)
                {
                    batteryWord = getChatWord("batteryLow");
                }
                else
                {
                    batteryWord = new MsgShortNews();
                }

                //メッセージ作成
                resStr = resStr + batteryWord.nameList[0];
                resStr = resStr.Replace("[?]", batteryLevel.ToString());
                result = new MsgShortNews(resStr, batteryWord.emotionList[0], batteryWord.pointList[0]);

                return result;
            }
            catch (Exception)
            {
                return new MsgShortNews("[?]%", 1, 1);
            }
        }