User:KingAragorn Bot/Scripts
From Tolkien Gateway
Here will be an archive of past C# scripts used for this bot.
Note:This code may need to be updated or edited for different wikis.
Add Category to Recently Uploaded Images
using System; using DotNetWikiBot; class MyBot : Bot { public static void Main() { Site site = new Site("http://tolkiengateway.net", "KingAragorn Bot", "PASSWORD"); PageList p = new PageList(site); p.FillFromCustomSpecialPage("Log/Upload", 29); p.Load(); p.AddToCategory("Images of Tengwar"); p.SaveSmoothly(3, "Bot Comment: adding category", true); } }
Removal of Spoiler Template from every page which has it
using System; using DotNetWikiBot; class MyBot : Bot { public static void Main() { Site site = new Site("http://lotr.wikia.com", "KingAragorn Bot", "Password"); PageList p = new PageList(site); p.FillFromCustomSpecialPage("Whatlinkshere/Template:Spoiler", 500); p.Load(); p.RemoveTemplate("Spoiler"); p.SaveSmoothly(3, "Bot Comment: removing spoiler template", true); } }
Reverting a Vandal Accounts Contributions(unused)
using System; using DotNetWikiBot; class MyBot : Bot { public static void Main() { Site enLOTR = new Site("http://lotr.wikia.com/wiki/", "KingAragorn Bot", "Password") p.FillFromUserContributions ("VANDAL USERNAME" "500",); p.Load(); p.Revert("Bot Comment: Automatic Reverting of a vandal accounts contributions", false); } }
Adding the Stub template to all pages in Special:Shortpages
using System; using DotNetWikiBot; class MyBot : Bot { public static void Main() { Site enLOTR = new Site("http://lotr.wikia.com/wiki/", "KingAragorn Bot", "PASSWORD"); PageList p = new PageList(enLOTR); p.FillFromCustomSpecialPage("Shortpages", 1000); p.Load(); p.RemoveTemplate("stub"); p.AddTemplate("{{stub}}"); p.SaveSmoothly(5, "Bot Comment: Adding stub template - article is listed under [[Special:Shortpages]]", true); } }
Changing Categories
using System; using DotNetWikiBot; class MyBot : Bot { public static void Main() { Site enLOTR = new Site("http://lotr.wikia.com/wiki/", "KingAragorn Bot", "PASSWORD"); PageList p = new PageList(enLOTR); p.FillAllFromCategory("Mountains of Middle-earth"); p.load(); p.RemoveFromCategory("Mountains of Middle-earth ") p.AddToCategory("Mountains") p.SaveSmoothly(5, "Bot Comment: Changing Categories", true) } }