Beispiel #1
0
		/// <summary>
		/// NGを追加する
		/// </summary>
		/// <param name="liveId"></param>
		/// <param name="type"></param>
		/// <param name="source"></param>
		/// <returns></returns>
		public static bool AddNg(string liveId, NGType type, string source) {
			if (LoginManager.DefaultCookies != null) {
				return AddNg(liveId, type, source, LoginManager.DefaultCookies);
			}

			return false;
		}
        //公式NG機能から削除する
        public void UnregisterNGComment(NGType type, string content, string token)
        {
            var pair = new Dictionary <string, string>();

            pair["mode"]     = "delete";
            pair["language"] = "0";
            pair["type"]     = type == NGType.Word ? "word" : "id";
            pair["token"]    = token;
            pair["source"]   = content;

            try {
                var request = new HttpRequestMessage(HttpMethod.Post, NGApi);

                request.Content = new FormUrlEncodedContent(pair);

                var a = NicoNicoWrapperMain.Session.GetAsync(request).Result;

                var xml = new XmlDocument();
                xml.LoadXml(a);
                if (xml.SelectSingleNode("/response_ngclient").Attributes["status"].Value != "ok")
                {
                    throw new RequestFailed(FailedType.Failed);
                }
            } catch (RequestTimeout) {
                throw new RequestFailed(FailedType.TimeOut);
            }
        }
        public void AddNGEntry(NGType type, string content) {

            var entry = new NGCommentEntry();
            entry.IsEnabled = true;
            entry.Type = type;
            entry.Content = content;

            Settings.Instance.NGList.Add(entry);
        }
        public void AddNGEntry(NGType type, string content)
        {
            var entry = new NGCommentEntry();

            entry.IsEnabled = true;
            entry.Type      = type;
            entry.Content   = content;
            NGFilter.AddNGEntry(entry);
        }
Beispiel #5
0
        public void AddNGEntry(NGType type, string content)
        {
            var entry = new NGCommentEntry();

            entry.IsEnabled = true;
            entry.Type      = type;
            entry.Content   = content;

            Settings.Instance.NGList.Add(entry);
        }
Beispiel #6
0
		/// <summary>
		/// NGを削除する
		/// </summary>
		/// <param name="type"></param>
		/// <param name="src"></param>
		private void DelNg(NGType type, string src)
		{
			DelNg(new NgClient(type, src, DateTime.Now));
		}
Beispiel #7
0
        //公式NG機能から削除する
        public void UnregisterNGComment(NGType type, string content, string token)
        {
            var pair = new Dictionary<string, string>();
            pair["mode"] = "delete";
            pair["language"] = "0";
            pair["type"] = type == NGType.Word ? "word" : "id";
            pair["token"] = token;
            pair["source"] = content;

            try {

                var request = new HttpRequestMessage(HttpMethod.Post, NGApi);

                request.Content = new FormUrlEncodedContent(pair);

                var a = NicoNicoWrapperMain.Session.GetAsync(request).Result;

                var xml = new XmlDocument();
                xml.LoadXml(a);
                if(xml.SelectSingleNode("/response_ngclient").Attributes["status"].Value != "ok") {

                    throw new RequestFailed(FailedType.Failed);
                }
            } catch(RequestTimeout) {

                throw new RequestFailed(FailedType.TimeOut);
            }
        }
Beispiel #8
0
		/// <summary>
		/// NGを削除する
		/// </summary>
		/// <param name="liveId"></param>
		/// <param name="type"></param>
		/// <param name="source"></param>
		/// <param name="cookies"></param>
		/// <returns></returns>
		public static bool DeleteNg(string liveId, NGType type, string source, System.Net.CookieContainer cookies)
		{
			string res = SendNgCommand(liveId, "del", type.ToString(), source, cookies);
			return (res != null && res.Contains("status=\"ok\""));
		}
Beispiel #9
0
		private void Parse(XmlNode node)
		{
			_source = Utility.Unsanitizing(node["source"].InnerText);
			if (node["register_time"] != null && !string.IsNullOrEmpty(node["register_time"].InnerText)) {
				_regTime = Utility.UnixTimeToDateTime(int.Parse(node["register_time"].InnerText));
			}
			switch (node["type"].InnerText) {
				case "word":
					_type = NGType.Word;
					break;
				case "id":
					_type = NGType.Id;
					break;
				case "command":
					_type = NGType.Command;
					break;
			}

			if (node.Attributes["readonly"] != null && node.Attributes["readonly"].Value == "true") {
				_options |= NGOption.Readonly;
			}

			if (node.Attributes["use_case_unify"] != null && node.Attributes["use_case_unify"].Value == "true") {
				_options |= NGOption.UseCaseUnify;
			}

			if (node.Attributes["is_regex"] != null && node.Attributes["is_regex"].Value == "true") {
				_options |= NGOption.IsRegex;
			}


		}
Beispiel #10
0
		/// <summary>
		/// パラメータを指定してNgClientを生成する
		/// </summary>
		/// <param name="type"></param>
		/// <param name="source"></param>
		/// <param name="regTime"></param>
		public NgClient(NGType type, string source, DateTime regTime)
		{
			_type = type;
			_source = source;
			_regTime = regTime;
		}
 public void setNGLevel(NGType NGType)
 {
     this.currentNGType = NGType;
 }