Пример #1
0
 private PutBlobResult(ContentHash hash, long blobSize, bool alreadyInRedis = false, long?newRedisCapacity = null, string?redisKey = null, SkipReason skipReason = SkipReason.NotSkipped, string?extraMsg = null)
     : base(succeeded: true)
 {
     _hash             = hash;
     _blobSize         = blobSize;
     _alreadyInRedis   = alreadyInRedis;
     _newRedisCapacity = newRedisCapacity;
     _redisKey         = redisKey;
     _extraMsg         = extraMsg;
     _skipReason       = skipReason;
 }
Пример #2
0
 internal PutBlobResult(
     ShortHash?hash        = null,
     long?blobSize         = null,
     bool alreadyInRedis   = false,
     long?newRedisCapacity = null,
     string?redisKey       = null,
     SkipReason skipReason = SkipReason.NotSkipped,
     string?extraMsg       = null)
 {
     _hash             = hash;
     _blobSize         = blobSize;
     _alreadyInRedis   = alreadyInRedis;
     _newRedisCapacity = newRedisCapacity;
     _redisKey         = redisKey;
     _extraMsg         = extraMsg;
     _skipReason       = skipReason;
 }
Пример #3
0
		private static string Skipping(ref string EditSummary, string DefaultEditSummary, SkipReason SkipReason, string ArticleText, ref bool Skip, string ArticleTitle = null, int NS = Namespace.Talk)
		{
			EditSummary = BotMode ? "This article should have been skipped" : DefaultEditSummary;

			switch (SkipReason) {
				case SkipReason.BadNamespace:
					PluginSettings.PluginStats.SkippedNamespaceIncrement();
					AWBForm.TraceManager.SkippedArticle(PluginName, "Incorrect namespace");
					break;
				case SkipReason.ProcessingMainArticleDoesntExist:
					PluginSettings.PluginStats.SkippedRedLinkIncrement();
					AWBForm.TraceManager.SkippedArticle(PluginName, "Article doesn't exist");
					break;
				case SkipReason.ProcessingTalkPageArticleDoesntExist:
					PluginSettings.PluginStats.SkippedRedLinkIncrement();
					AWBForm.TraceManager.SkippedArticleRedlink(PluginName, ArticleTitle, NS);
					break;
				case SkipReason.BadTag:
					AWBForm.TraceManager.SkippedArticleBadTag(PluginName, ArticleTitle, NS);
					break;
				case SkipReason.NoChange:
					AWBForm.TraceManager.SkippedArticle(PluginName, "No change");
					break;
				case SkipReason.Regex:
					AWBForm.TraceManager.SkippedArticle(PluginName, "Article text matched a skip-if-found regular expression");
					break;
				case SkipReason.Other:
					AWBForm.TraceManager.SkippedArticle(PluginName, "");
					break;
			}

			Skip = true;
			return ArticleText;
		}
Пример #4
0
        private static string Skipping(ref string editSummary, string defaultEditSummary, SkipReason skipReason,
                                       string articleText, ref bool Skip, string articleTitle = null, int ns = Namespace.Talk)
        {
            editSummary = BotMode ? "This article should have been skipped" : defaultEditSummary;

            switch (skipReason)
            {
            case SkipReason.BadNamespace:
                _pluginSettings.PluginStats.SkippedNamespaceIncrement();
                AWBForm.TraceManager.SkippedArticle(PluginName, "Incorrect namespace");
                break;

            case SkipReason.ProcessingMainArticleDoesntExist:
                _pluginSettings.PluginStats.SkippedRedLinkIncrement();
                AWBForm.TraceManager.SkippedArticle(PluginName, "Article doesn't exist");
                break;

            case SkipReason.ProcessingTalkPageArticleDoesntExist:
                _pluginSettings.PluginStats.SkippedRedLinkIncrement();
                AWBForm.TraceManager.SkippedArticleRedlink(PluginName, articleTitle, ns);
                break;

            case SkipReason.BadTag:
                AWBForm.TraceManager.SkippedArticleBadTag(PluginName, articleTitle, ns);
                break;

            case SkipReason.NoChange:
                AWBForm.TraceManager.SkippedArticle(PluginName, "No change");
                break;

            case SkipReason.Regex:
                AWBForm.TraceManager.SkippedArticle(PluginName,
                                                    "Article text matched a skip-if-found regular expression");
                break;

            case SkipReason.Other:
                AWBForm.TraceManager.SkippedArticle(PluginName, "");
                break;
            }

            Skip = true;
            return(articleText);
        }
Пример #5
0
        private static string FinaliseArticleProcessing(Article theArticle, ref bool skip, ref string summary,
                                                        string articleText, bool reqPhoto)
        {
            SkipReason skipReason = SkipReason.Other;

            if (theArticle.PluginManagerGetSkipResults == SkipResults.NotSet)
            {
                _pluginSettings.PluginStats.Tagged += 1;
            }
            else
            {
                switch (theArticle.PluginManagerGetSkipResults)
                {
                case SkipResults.SkipBadTag:
                    // always skip
                    if (_pluginSettings.SkipBadTags)
                    {
                        _pluginSettings.PluginStats.SkippedBadTagIncrement();
                        if (_pluginSettings.OpenBadInBrowser)
                        {
                            theArticle.EditInBrowser();
                        }
                        skip = true;
                        // always skip
                        skipReason = SkipReason.BadTag;
                    }
                    else
                    {
                        // the plugin manager stops processing when it gets a bad tag. We know however
                        // that one plugin found a bad template and possibly replaced it with
                        // conTemplatePlaceholder. We're also not skipping, so we need to remove the placeholder
                        theArticle.AlteredArticleText =
                            theArticle.AlteredArticleText.Replace(Constants.TemplaterPlaceholder, "");
                        MessageBox.Show("Bad tag. Please fix it manually or click ignore.", "Bad tag",
                                        MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        _pluginSettings.PluginStats.Tagged += 1;
                    }
                    break;

                case SkipResults.SkipRegex:
                case SkipResults.SkipNoChange:
                    if (theArticle.ProcessIt)
                    {
                        _pluginSettings.PluginStats.Tagged += 1;
                    }
                    else
                    {
                        if (theArticle.PluginManagerGetSkipResults == SkipResults.SkipRegex)
                        {
                            _pluginSettings.PluginStats.SkippedMiscellaneousIncrement();
                            skip       = true;
                            skipReason = SkipReason.Regex;
                            // No change:
                        }
                        else
                        {
                            if (_pluginSettings.SkipWhenNoChange)
                            {
                                _pluginSettings.PluginStats.SkippedNoChangeIncrement();
                                skipReason = SkipReason.NoChange;
                                skip       = true;
                            }
                            else
                            {
                                _pluginSettings.PluginStats.Tagged += 1;
                                skip = false;
                            }
                        }
                    }
                    break;
                }
            }

            if (skip)
            {
                return(Skipping(ref summary, theArticle.EditSummary, skipReason, articleText, ref skip));
            }

            if (reqPhoto)
            {
                theArticle.AlteredArticleText = ReqPhotoNoParamsRegex.Replace(theArticle.AlteredArticleText, "");
                theArticle.DoneReplacement("{{reqphoto}}", "template param(s)");
                theArticle.ArticleHasAMajorChange();
            }

            theArticle.FinaliseEditSummary();
            summary = theArticle.EditSummary;
            return(theArticle.AlteredArticleText);
        }
        private static string FinaliseArticleProcessing(Article TheArticle, ref bool Skip, ref string Summary, string ArticleText, bool ReqPhoto)
        {
            SkipReason SkipReason = SkipReason.Other;

            if (TheArticle.PluginManagerGetSkipResults == SkipResults.NotSet)
            {
                PluginSettings.PluginStats.Tagged += 1;
            }
            else
            {
                var _with6 = PluginSettings.PluginStats;
                switch (TheArticle.PluginManagerGetSkipResults)
                {
                case SkipResults.SkipBadTag:
                    // always skip
                    if (PluginSettings.SkipBadTags)
                    {
                        _with6.SkippedBadTagIncrement();
                        if (PluginSettings.OpenBadInBrowser)
                        {
                            TheArticle.EditInBrowser();
                        }
                        Skip = true;
                        // always skip
                        SkipReason = SkipReason.BadTag;
                    }
                    else
                    {
                        // the plugin manager stops processing when it gets a bad tag. We know however
                        // that one plugin found a bad template and possibly replaced it with
                        // conTemplatePlaceholder. We're also not skipping, so we need to remove the placeholder
                        TheArticle.AlteredArticleText = TheArticle.AlteredArticleText.Replace(Constants.conTemplatePlaceholder, "");
                        MessageBox.Show("Bad tag. Please fix it manually or click ignore.", "Bad tag", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        PluginSettings.PluginStats.Tagged += 1;
                    }
                    break;

                case SkipResults.SkipRegex:
                case SkipResults.SkipNoChange:
                    if (TheArticle.ProcessIt)
                    {
                        PluginSettings.PluginStats.Tagged += 1;
                    }
                    else
                    {
                        if (TheArticle.PluginManagerGetSkipResults == SkipResults.SkipRegex)
                        {
                            _with6.SkippedMiscellaneousIncrement();
                            Skip       = true;
                            SkipReason = SkipReason.Regex;
                            // No change:
                        }
                        else
                        {
                            if (PluginSettings.SkipWhenNoChange)
                            {
                                _with6.SkippedNoChangeIncrement();
                                SkipReason = SkipReason.NoChange;
                                Skip       = true;
                            }
                            else
                            {
                                PluginSettings.PluginStats.Tagged += 1;
                                Skip = false;
                            }
                        }
                    }
                    break;
                }
            }

            if (Skip)
            {
                return(Skipping(ref Summary, TheArticle.EditSummary, SkipReason, ArticleText, ref Skip));
            }
            var _with7 = TheArticle;

            if (ReqPhoto)
            {
                _with7.AlteredArticleText = ReqPhotoNoParamsRegex.Replace(_with7.AlteredArticleText, "");
                _with7.DoneReplacement("{{[[template:reqphoto|reqphoto]]}}", "template param(s)", true, PluginName);
                _with7.ArticleHasAMajorChange();
            }

            _with7.FinaliseEditSummary();
            Summary = _with7.EditSummary;
            return(_with7.AlteredArticleText);
        }