Jump to content

User:ShepBot/AWB Module

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Stepshep (talk | contribs) at 20:04, 28 May 2008 (people are complicated). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
public string ProcessArticle(string ArticleText, string ArticleTitle, int wikiNamespace, out string Summary, out bool Skip)
        {
            Skip = false;
            Summary = "";
            string Tag = "";
            string template = "WPOHIO";
 
            Match m = Regex.Match(ArticleText, @"\{\{" + template + "(.*?)\\|(.*?)class=", RegexOptions.Singleline | RegexOptions.IgnoreCase);
            Match c = Regex.Match(ArticleText, @"\|(\s|)class(\s|)=(\s|)stub", RegexOptions.IgnoreCase);
            Match f = Regex.Match(ArticleText, @"\|(\s|)class(\s|)=(\s|)fa", RegexOptions.IgnoreCase);
            Match l = Regex.Match(ArticleText, @"\|(\s|)class(\s|)=(\s|)fl", RegexOptions.IgnoreCase);
            Match g = Regex.Match(ArticleText, @"\|(\s|)class(\s|)=(\s|)ga", RegexOptions.IgnoreCase);
            Match s = Regex.Match(ArticleText, @"\|(\s|)class(\s|)=(\s|)start", RegexOptions.IgnoreCase);
            Match b = Regex.Match(ArticleText, @"\|(\s|)class(\s|)=(\s|)b", RegexOptions.IgnoreCase);
            Match r = Regex.Match(ArticleText, @"\|(\s|)class(\s|)=(\s|)list", RegexOptions.IgnoreCase);
            Match d = Regex.Match(ArticleText, @"\|(\s|)class(\s|)=(\s|)d(ab|isambig)", RegexOptions.IgnoreCase);
 
            string pageClass = "";
 
            if (c.Success) pageClass = "Stub";
 
            if (f.Success) pageClass = "FA";
 
            if (l.Success) pageClass = "FL";
 
            if (g.Success) pageClass = "GA";
 
            if (s.Success) pageClass = "Start";
 
            if (b.Success) pageClass = "B";            
 
            if (r.Success) pageClass = "List";
 
            if (d.Success) pageClass = "Dab";
 
            Tag = "{{" + template + "|class=" + pageClass + "}}";
 
            if (m.Success) ArticleText = ArticleText.Insert(m.Index + m.Length, pageClass);
            else ArticleText = Tag + "\r\n" + ArticleText;
 
            return ArticleText;
        }

Stolen from Richard0612, which was tweaked by Reedy, which was slightly modified by me. The code is a custom module for AWB.