User:Mithbot/Scripts: Difference between revisions

From Tolkien Gateway
m (Added list of jobs)
m (Added more jobs)
Line 58: Line 58:
*''Egalmoth, Steward of Gondor'' to [[Egalmoth (Steward of Gondor)]] (15 June 2010);
*''Egalmoth, Steward of Gondor'' to [[Egalmoth (Steward of Gondor)]] (15 June 2010);
*''Faramir son of Denethor II'', ''Faramir, son of Denethor II'' and ''Faramir (son of Denethor II)'' to [[Faramir]] (15 June 2010);
*''Faramir son of Denethor II'', ''Faramir, son of Denethor II'' and ''Faramir (son of Denethor II)'' to [[Faramir]] (15 June 2010);
*''Mardil'' to [[Mardil Voronwë]] (15 June 2010);
*''Orodreth of Gondor'' to [[Orodreth (Steward of Gondor)]] (15 June 2010);
*''Turgon of Gondor'' to [[Turgon (Steward of Gondor)]] (15 June 2010);
*''Baranor of Gondor'' to [[Baranor (Man of Gondor)]] (15 June 2010);
*''Beregond, soldier of Gondor'' to [[Beregond (soldier of Gondor)]] (15 June 2010);
*''Barahir grandson of Faramir'' to [[Barahir (grandson of Faramir)]] (15 June 2010);
*''Boromir son of Denethor II'', ''Boromir II'', ''Boromir, son of Denethor II'' ''Boromir (son of Denethor II)'' to [[Boromir]] (15 June 2010);

Revision as of 18:04, 15 June 2010

Changing Internal Links

using System;
using DotNetWikiBot;
class MyBot : Bot 
{ 
	public static void Main() 
	{ 
		Site site = new Site("http://tolkiengateway.net", "Mithbot", "PASSWORD"); 

		PageList p = new PageList(site);
 		p.FillFromLinksToPage("Bilbo");
		p.LoadEx();
		foreach (Page i in p)
			i.text = i.text.Replace("[[Bilbo]]", "[[Bilbo Baggins]]");
		p.SaveSmoothly(1, "Bot Message: changing link to [[Bilbo Baggins]]", true);
	} 

}

To avoid certain namespaces, add this before p.LoadEx();, User and Template in this example:-

		p.RemoveNamespaces(new int[] {2,10});

The above code is used to change links to a particular page in order to remove redirects. By changing "Bilbo" and "Bilbo Baggins" this script can be re-used again and again to edit internal links. So far, it has been used for changing: