Esempio n. 1
0
        /// <summary>
        /// コメント受信イベント処理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void PluginHost_ReceivedComment(object sender, ReceivedCommentEventArgs e)
        {
            int count = e.CommentDataList.Count;

            if (count < 1)
            {
                return;
            }

            NicoLibrary.NicoLiveData.LiveCommentData commentData = e.CommentDataList[count - 1];

            string commentNo = commentData.No;
            string anonymity = commentData.Anonymity;
            string comment   = commentData.Comment;
            string userId    = commentData.UserId;
            string kotehan   = "184";

            UserSettingInPlugin userSetting = pluginHost.GetUserSettingInPlugin();

            foreach (UserSettingInPlugin.UserData userData in userSetting.UserDataList)
            {
                if (userData.UserId.Equals(userId))
                {
                    kotehan = userData.NickName;
                }
            }

            viWindow.AddVideoInfoCommand(commentNo, kotehan, comment);
        }
Esempio n. 2
0
        //コメント受信時イベントハンドラ
        void _host_ReceivedComment(object sender, ReceivedCommentEventArgs e)
        {
            //受信したコメント数を取り出す
            int count = e.CommentDataList.Count;

            if (count == 0)
            {
                return;
            }

            //最新のコメントデータを取り出す
            NicoLibrary.NicoLiveData.LiveCommentData commentData = e.CommentDataList[count - 1];
            string comment = commentData.Comment;

            if (((commentData.PremiumBits & NicoLibrary.NicoLiveData.PremiumFlags.ServerComment) == NicoLibrary.NicoLiveData.PremiumFlags.ServerComment))
            {
                form.addOpeCommentArray(comment);
            }
            else
            {
                if (form.getCheckBox() != true)
                {
                    //コメント文字列を取り出す
                    string user = commentData.Name;
                    form.addCommentArray(user, comment);
                }
            }
        }
        private void Host_ReceivedComment(object sender, ReceivedCommentEventArgs e)
        {
            if (gadget != null && e.CommentDataList.Count > 0)
            {
                // コメントデータ一覧
                var data = e.CommentDataList.Last();

                // ユーザー設定取得
                var userSetting = Host.GetUserSettingInPlugin();

                var userData
                    = userSetting.UserDataList.FindAll(s => { return(s.UserId == data.UserId); }).ToArray();

                // 挿入データ
                var info = new CommentData();
                {
                    info.Visible            = true;
                    info.IsOwner            = data.Premium == 3 ? true : false;
                    info.Nickname           = userData.Length > 0 ? userData[0].NickName : "";
                    info.Comment            = data.Comment;
                    info.CommentColor       = CheckMailToColor(data.Mail);
                    info.BackgroundColor    = userData.Length > 0 ? userData[0].BGColor : (Color)setting.Background_Color;
                    info.FadeStringPosition = setting.Gadget_Height;
                    info.FadeR    = gadget.Data.Last().FadeR;
                    info.FadeG    = gadget.Data.Last().FadeG;
                    info.FadeB    = gadget.Data.Last().FadeB;
                    info.PostTime = DateTime.Now;
                }

                // データ追加
                gadget.Data.Add(info);
            }
        }
Esempio n. 4
0
        //コメント受信時イベントハンドラ
        void _host_ReceivedComment(object sender, ReceivedCommentEventArgs e)
        {
            //受信したコメント数を取り出す
            int count = e.CommentDataList.Count;

            if (count == 0)
            {
                return;
            }
            //最新のコメントデータを取り出す
            NicoLibrary.NicoLiveData.LiveCommentData commentData = e.CommentDataList[count - 1];
            //コメント文字列を取り出す
            string comment = commentData.Comment;
            string UserId  = commentData.UserId;
            string resMsg  = UserId + "\t" + comment;

            Output(resMsg);
        }
Esempio n. 5
0
        /// <summary>
        /// コメント受信時の処理
        /// </summary>
        /// <param name="?"></param>
        void ReceivedComment(object sender, ReceivedCommentEventArgs e)
        {
            Logger.write("=== BEGIN ===");
            try
            {
                if (!isAlive)
                {
                    return;
                }

                if (e.CommentDataList.Count == 0)
                {
                    Logger.write(string.Format("sender:{0}, ReceivedCommentEventArgs{1}",
                                               sender.ToString(), e.ToString()));

                    return;
                }

                Logger.write(string.Format("e.CommentDataList.Count: {0}",
                                           e.CommentDataList.Count));
                LiveCommentData data = e.CommentDataList[e.CommentDataList.Count - 1];

                Logger.write(string.Format("Comment:{0}, UserId:{1}",
                                           data.Comment, data.UserId));
                // 天気予報
                string weatherPattern = string.Format("^{0}「(?<city>.*?)」{1}「(?<day>.*?)」{2}$",
                                                      form.WeatherPrefixMsg, form.WeatherMiddleMsg, form.WeatherSuffixMsg);
                //Match wmatch = Regex.Match(chat.Message, @"^みっくりさん「(?<city>.*?)」の「(?<day>.*?)」の天気(を?)教えて");
                Match wmatch = Regex.Match(data.Comment, weatherPattern);
                if (wmatch.Success)
                {
                    Logger.write(string.Format("天気予報マッチ({0})", data.Comment));
                    if (data != null && !string.IsNullOrEmpty(data.UserId))
                    {
                        long timeLeft = kenOpe.ConfirmWebAccess(data.UserId, form.WaitTime);
                        if (timeLeft == 0)
                        {
                            string city = wmatch.Groups["city"].Value;
                            string day  = wmatch.Groups["day"].Value;
                            Utility.PostMessage(host,
                                                string.Format(">>{0} {1}", data.No,
                                                              kenOpe.GetWeatherMsg(city, day, form.WeatherNotCityMsg, form.WeatherNotDayMsg, form.SuccessSuffixMsg)));
                        }
                        else
                        {
                            Utility.PostMessage(host,
                                                string.Format(">>{0}番さんが次に検索できるのは、あと{1}秒後です(同一IDでの検索は{2}秒間空けてください)", data.No, timeLeft, form.WaitTime));
                        }
                    }
                    return;
                }
                // キーワード検索
                string keywordPattern = string.Format("^{0}「(?<keyword>.*?)」{1}$",
                                                      form.KeywordPrefixMsg, form.KeywordSuffixMsg);
                //Match kmatch = Regex.Match(chat.Message, @"みっくりさん「(?<keyword>.*?)」ってなに?");
                Match kmatch = Regex.Match(data.Comment, keywordPattern);
                if (kmatch.Success)
                {
                    if (data != null && !string.IsNullOrEmpty(data.UserId))
                    {
                        long timeLeft = kenOpe.ConfirmWebAccess(data.UserId, form.WaitTime);
                        if (timeLeft == 0)
                        {
                            string keyword = kmatch.Groups["keyword"].Value;
                            Utility.PostMessage(host,
                                                string.Format(">>{0} {1}", data.No,
                                                              Utility.InsertBr(
                                                                  kenOpe.GetKeywordSearchMsg(keyword, form.NotFoundMsg, form.SuccessSuffixMsg))));
                        }
                        else
                        {
                            Utility.PostMessage(host,
                                                string.Format(">>{0}番さんが次に検索できるのは、あと{1}秒後です(同一IDでの検索は{2}秒間空けてください)", data.No, timeLeft, form.WaitTime));
                        }
                    }
                    return;
                }
            }
            catch (Exception ex)
            {
                Logger.write(ex.Message);
                MessageBox.Show(ex.Message);
            }
            finally
            {
                Logger.write("=== END ===");
            }
        }
Esempio n. 6
0
        /// <summary>
        /// コメント受信時に発生するイベントメソッド
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void _Host_ReceivedComment(object sender, ReceivedCommentEventArgs e)
        {
            try
            {
                // 多重処理防止
                if (_LastLiveId == _Host.GetPlayerStatus().LiveNum)
                {
                    return;
                }
                _LastLiveId = _Host.GetPlayerStatus().LiveNum;

                // インデックスチェック
                int commentLastIndex = e.CommentDataList.Count - 1;
                if (commentLastIndex < 0)
                {
                    return;
                }

                // 放送主時以外の受信は無視
                if (!_Host.GetPlayerStatus().Stream.IsOwner.Equals("1"))
                {
                    return;
                }

                // [設定] 運営コメントは無視
                var ownerFlag = NicoLibrary.NicoLiveData.PremiumFlags.Premium | NicoLibrary.NicoLiveData.PremiumFlags.ServerComment;
                if (excludeOwnerComment.Checked && ((e.CommentDataList[commentLastIndex].PremiumBits & (ownerFlag)) == ownerFlag))
                {
                    return;
                }

                // [設定] No1のコメントが運営コメントの場合、No2を1Get処理する
                if (No2AsNo1Comment.Checked && commentLastIndex == 1)
                {
                    if ((e.CommentDataList[0].PremiumBits & (ownerFlag)) != ownerFlag)
                    {
                        // No1が運営コメントではない
                        return;
                    }
                }
                // No1のコメント以外は無視
                else if (!e.CommentDataList[commentLastIndex].No.Equals("1"))
                {
                    return;
                }


                string userId           = e.CommentDataList[commentLastIndex].UserId;
                string nickname         = _Host.GetUserSettingInPlugin().UserDataList.Find(x => x.UserId == e.CommentDataList[e.CommentDataList.Count - 1].UserId)?.NickName;
                int    acquisitionCount = 1;

                HistoryData historyData = _HistoryDataList.FirstOrDefault(x => x.UserId.Equals(userId));
                if (historyData == null)
                {
                    // 新規登録
                    historyData = new HistoryData
                    {
                        UserId           = userId,
                        NickName         = nickname,
                        AcquisitionCount = 1,
                        RegisterDate     = DateTime.Now
                    };
                    _HistoryDataList.Add(historyData);
                }
                else
                {
                    // 更新
                    historyData.NickName          = nickname;
                    historyData.AcquisitionCount += 1;

                    acquisitionCount = historyData.AcquisitionCount;
                }

                // 運営コメント送信有無
                if (!ReplyCommentToggle.Checked)
                {
                    return;
                }

                // 運営コメント編集
                string ownerComment = ReplyCommentTextBox.Text;
                ownerComment = ownerComment.Replace("{Nickname}", !string.IsNullOrEmpty(nickname) ? nickname : "名無し")
                               .Replace("{Count}", acquisitionCount.ToString());


                // 運営コメント送信
                _Host.SendOwnerComment(ownerComment);
            }
            catch
            {
                // TODO: 例外処理
                // 報告しやすい(してもらいやすい)形式で出力する
            }
        }
Esempio n. 7
0
        /// <summary>
        /// コメント受信イベント処理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void PluginHost_ReceivedComment(object sender, ReceivedCommentEventArgs e)
        {
            int count = e.CommentDataList.Count;
            if (count < 1) { return; }

            NicoLibrary.NicoLiveData.LiveCommentData commentData = e.CommentDataList[count - 1];

            string commentNo = commentData.No;
            string anonymity = commentData.Anonymity;
            string comment = commentData.Comment;
            string userId = commentData.UserId;
            string kotehan = "184";

            UserSettingInPlugin userSetting = pluginHost.GetUserSettingInPlugin();

            foreach (UserSettingInPlugin.UserData userData in userSetting.UserDataList)
            {
                if (userData.UserId.Equals(userId))
                {
                    kotehan = userData.NickName;                    
                }
            }

            viWindow.AddVideoInfoCommand(commentNo, kotehan, comment);
            
        }
Esempio n. 8
0
        private void Host_ReceivedComment(object sender, ReceivedCommentEventArgs e)
        {
            var comment = e.CommentDataList.First().Comment;

            _comments.Enqueue(comment);
        }