User:Yobot/CatsCheck
public string ProcessArticle(string ArticleText, string ArticleTitle, int wikiNamespace, out string Summary, out bool Skip)
{
Skip = false;
Summary = "test";
List
ArticleText = ("\r\n" + "Current cats" + "\r\n");
foreach(Article x in cats)
ArticleText += (x.Name + "\r\n");
List
ArticleText += "\r\n" + "After cats" + "\r\n";
foreach(Article x in catsAfter)
ArticleText += (x.Name + "\r\n");
return ArticleText;
}
// report categories currently on given page
public static List
{
WikiFunctions.Lists.Providers.CategoriesOnPageListProvider x = new WikiFunctions.Lists.Providers.CategoriesOnPageListProvider();
List
return cats;
}
// report categories that would be on given page with given input article text
public static List
{
WikiFunctions.Controls.Lists.ListMaker lm = new WikiFunctions.Controls.Lists.ListMaker();
// https://en.wikipedia.org/w/api.php?format=xml&action=parse&prop=categories&title=a&text=a{{dn}}
string url = @"https://en.wikipedia.org/w/api.php?format=xml&action=parse&prop=categories&title=" +
System.Web.HttpUtility.UrlEncode(ArticleTitle) + "&text=" + System.Web.HttpUtility.UrlEncode(ArticleText);
string res = Tools.GetHTML(url);
Regex r = new Regex(@">([^<>]+)");
List
foreach(Match m in r.Matches(res))
cats.Add(new Article(lm.NormalizeTitle("Category:" + m.Groups[1].Value.Replace("_", " "))));
return cats;
}