User:SDrewthbot/AWB modules

removing &#91;&#91;Category:\d\d\d\d works]], replace with year in header
create October 2010 public string ProcessArticle(string ArticleText, string ArticleTitle, int wikiNamespace, out string Summary, out bool Skip) {       Summary ="remove category tag and add as year field in header, tidy header (custom module)"; Skip = false; // captures 2 fields either side of pipe if present, otherwise just one String year = @"\[\?([^\+)?\]\]"; String notes = @"(\n\s*\|\s*notes)";

Match m = Regex.Match(ArticleText, year); Match n = Regex.Match(ArticleText, notes); if (m.Success) { String yearnotes = m.Result(" | year = $1") + n.Result("$1"); ArticleText = Regex.Replace(ArticleText, notes, yearnotes); ArticleText = Regex.Replace(ArticleText, year, ""); }

// check for an existing DEFAULTSORT, if not present then add it with sort info Match d = Regex.Match(ArticleText, "DEFAULTSORT"); if (!d.Success) { // if second parameter (sort) was captured from category test then makes that DefSort if (m.Result("$2") != "") { ArticleText = ArticleText + "\n" + m.Result(""); }       }

return ArticleText; }

match override author and &lt;pages
created Sep 2010 — billinghurst  sDrewth  23:39, 13 September 2010 (UTC) public string ProcessArticle(string ArticleText, string ArticleTitle, int wikiNamespace, out string Summary, out bool Skip) {       Summary =""; Match m = Regex.Match(ArticleText, "override_author"); Match n = Regex.Match(ArticleText, "<pages"); Skip = (m.Success && n.Success); return ArticleText; }

removing indexes and replacing with portal parameter in header
created Mar 2011; in response to Bot requests

public string ProcessArticle(string ArticleText, string ArticleTitle, int wikiNamespace, out string Summary, out bool Skip) {       Summary ="remove  template and add data to portal parameter in header (custom module)"; Skip = false; // captures data for portal parameter, and notes parameter String indexes = @"\{\{[Ii]ndexes\|\s?([^\}]+)\}\}"; String notes = @"(\n\s*\|\s*notes)";

Match m = Regex.Match(ArticleText, indexes); Match n = Regex.Match(ArticleText, notes); // where successful, replace any "|" character between $1 $2 $3 ... and replace with "/" character if (m.Success) { string portal = m.Result("$1").Replace("|", "/"); String portalnotes = " | portal = " + portal +  n.Result("$1"); ArticleText = Regex.Replace(ArticleText, notes, portalnotes); ArticleText = Regex.Replace(ArticleText, indexes, ""); }      return ArticleText;

}