Example #1
0
		/// <summary>
		/// ChatのNGチェックを行う
		/// 結果はchatオブジェクトのIFilterdChatインターフェースの実装に格納される
		/// </summary>
		/// <param name="chat"></param>
		public void Check(OcvChat chat)
		{

			if (chat.IsOwnerComment && chat.Message.StartsWith("/ng")) {

				OperateNgCommand(chat);

			} else if (!chat.IsOwnerComment) {
				lock (this) {

					if (_normalFilter != null) {
						Match m = _normalFilter.Match(chat.Message);

						if (m.Success) {
							chat.NgType = Hal.NCSPlugin.NGType.Word;
							chat.NgSource = m.Value;
							return;
						}
					}

					if (_unifyFilter != null) {
						string com = normaliza(chat.Message);
						Match m = _unifyFilter.Match(com);
						if (m.Success) {
							chat.NgType = Hal.NCSPlugin.NGType.Word;
							chat.NgSource = m.Value;
							return;
						}
					}

					if (_idCollections.Count != 0 && !string.IsNullOrEmpty(chat.UserId)) {
						if (_idCollections.Contains(chat.UserId)) {
							chat.NgType = Hal.NCSPlugin.NGType.Id;
							chat.NgSource = chat.UserId;
							return;
						}
					}

					if (_commandCollections.Count != 0 && !string.IsNullOrEmpty(chat.Mail)) {
						if (!string.IsNullOrEmpty(chat.Mail) && chat.Mail != "184") {
							foreach (string cc in chat.Mail.Split(' ')) {
								if (_commandCollections.Contains(cc)) {
									chat.NgType = Hal.NCSPlugin.NGType.Command;
									chat.NgSource = cc;
									return;
								}
							}

						}
					}
				}
			}

		}
Example #2
0
		/// <summary>
		/// チャットを受け取ったことを各システムに通知する
		/// </summary>
		/// <param name="chat"></param>
		private void NotifyReceiveChat(OcvChat chat)
		{
			_chats.Add(chat);
			_ngChecker.Check(chat);

			//プラグインに通知
			foreach (Hal.NCSPlugin.IPlugin plugin in _plugins) {
				plugin.OnComment(chat);
			}
		}
Example #3
0
		public bool InsertPluginChat(Hal.NCSPlugin.IChat chat)
		{
			if (_mainview != null) {
				OcvChat ochat = new OcvChat(chat);
				if (_form.InvokeRequired) {
					_form.BeginInvoke(new Action<OcvChat>(NotifyReceiveChat), ochat);
				} else {
					NotifyReceiveChat(ochat);
				}
			}

			return true;
		}
Example #4
0
		/// <summary>
		/// メッセージサーバーからチャットを受け取ったときに実行される
		/// ただし、過去ログ分については呼び出されない
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		protected virtual void OnReceivedChat(object sender, NicoApiSharp.Streaming.ChatReceiver.ChatReceiveEventArgs e)
		{
			if (_mainview != null) {
				OcvChat ochat = new OcvChat(e.Chat);
				NotifyReceiveChat(ochat);
			}
		}