Wikipedia:AutoWikiBrowser/Custom Modules
From Wikipedia, the free encyclopedia
Contents |
[edit] Mass AfD Tagging
Go to "Tools" → "Make module" and paste the following code:
public string ProcessArticle(string ArticleText, string ArticleTitle, int wikiNamespace, out string Summary, out bool Skip) { Skip = false; Summary = "EDIT_SUMMARY_HERE"; ArticleText = "TAG_TO_ADD_HERE\r\n" + ArticleText; return ArticleText; }
Replacing EDIT_SUMMARY_HERE with the desired edit summary (keep the quotes around the summary; if you want actual quotes in the summary write them as \") and TAG_TO_ADD_HERE with the tag you want to add to the top of the page (again keep the quotes around the summary and the \r\n after it). If you want the tag to be at the end of the page replace the line
ArticleText = "TAG_TO_ADD_HERE\r\n" + ArticleText;
With
ArticleText = ArticleText + "TAG_TO_ADD_HERE\r\n";
Then check the "Enabled" box, press "Make module", and then "Done". Keep the "edit summary" box in the main AWB form empty.
[edit] Passing text to external program for processing
Note: An interface now exists in AWB for this
public string ProcessArticle(string ArticleText, string ArticleTitle, int wikiNamespace, out string Summary, out bool Skip) { string OrigText = ArticleText; Skip = false; Summary = ""; try { System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo(); psi.WorkingDirectory = "C:\\Path"; psi.FileName = "script.ext"; psi.Arguments = ""; System.IO.StreamWriter writer = new System.IO.StreamWriter("input.txt"); writer.Write(ArticleText); writer.Close(); System.Diagnostics.Process p = System.Diagnostics.Process.Start(psi); p.WaitForExit(); if (System.IO.File.Exists(psi.WorkingDirectory + "\\output.txt")) { System.IO.StreamReader reader = System.IO.File.OpenText(psi.WorkingDirectory + "\\output.txt"); ArticleText = reader.ReadToEnd(); reader.Close(); if (ArticleText == OrigText) Skip = true; } else Skip = true; return ArticleText; } catch { Skip = true; return OrigText; } }
psi.WorkingDirectory = "C:\\Path"; psi.FileName = "script.ext"; psi.Arguments = "";
So, working directory, is where the file you want to run is. File name is obvious, arguments, is probably how you want to pass it the article text or similar.
[edit] Inserting text just before categories
Could be easily adapted for inserting into other parts of the page.
public string ProcessArticle(string ArticleText, string ArticleTitle, int wikiNamespace, out string Summary, out bool Skip) { Skip = false; Summary = ""; Match m = Regex.Match(ArticleText, @"\[\[[Cc]ategory:"); if (m.Success) ArticleText = ArticleText.Insert(m.Index, "foo\r\n"); else ArticleText += "\r\nfoo"; return ArticleText; }

