User:Mithbot/Scripts: Difference between revisions

From Tolkien Gateway
m (→‎Changing Internal Links: Added some more; corrected some early errors in records)
m (Added more recent acts)
Line 152: Line 152:
*''Amon Hen journal'' to [[Amon Hen (journal)]] (6 July 2010);
*''Amon Hen journal'' to [[Amon Hen (journal)]] (6 July 2010);
*''Andreas Moehn'' to [[Andreas Möhn]] (7 July 2010);
*''Andreas Moehn'' to [[Andreas Möhn]] (7 July 2010);
*''Angaráto'' to [[Angaráto]] (7 July 2010);
*''Angaráto'' to [[Angrod]] (7 July 2010);
*''Anglo-Saxon'' to [[Old English]] (7 July 2010);
*''Anglo-Saxon'' to [[Old English]] (7 July 2010);
*''Angrenost'' to [[Isengard]] (7 July 2010);
*''Angrenost'' to [[Isengard]] (7 July 2010);
*''Anke Eissman'' to [[Anke Eißmann]] (7 July 2010);
*''Anke Eissman'' to [[Anke Eißmann]] (7 July 2010);
*''Annals of Aman'' to [[The Annals of Aman]] (7 July 2010);
*''Appendices'' and ''The Appendices'' to [[The Lord of the Rings Appendices]] (7 July 2010);
*''North-kingdom'' to [[Arnor]] (7 July 2010);
*''Nirnaeth Arnoediad'' and ''Battle of Unnumbered Tears'' to [[Nírnaeth Arnoediad]] (5 August 2010);
*''Bëor the Old'' to [[Bëor]] (5 August 2010);
*''Dragon'' to [[Dragons]] (5 August 2010);
*''EA'' to [[Electronic Arts]] (5 August 2010);
*''Barrow Downs'' to [[Barrow-downs]] (6 August 2010);
*''Barrow-wight'' to [[Barrow-wights]] (6 August 2010);
*''Battle of Pelennor Fields'' to [[Battle of the Pelennor Fields]] (7 August 2010);
*''Farewell Party'' and ''Bilbo's Birthday Party'' to [[Bilbo's Farewell Party]] (7 August 2010);
*''Amon Sûl'' to [[Weathertop]] (7 August 2010);
*''Beleg Strongbow'' and ''Beleg Cúthalion'' to [[Beleg]] (7 August 2010);
*''Aragorn II Elessar'', ''Aragorn Elessar'' and ''Aragorn II'' to [[Aragorn]] (7 August 2010);
*''Beren Erchamion'' to [[Beren]] (8 August 2010);
*''Category:Dates'' to <nowiki><noinclude>[[Category:Dates]]</noinclude></nowiki> (10 August 2010);
*''User:Mith'' to <nowiki>[[User:Mith/sig]]</nowiki> (1 September 2010);
*''CATEGORY'' to Category (1 September 2010);
*''Minas Tirith of Gondor'' to [[Minas Tirith]] (3 September 2010);
*Categorisation of uncategorised TG images and meeting templates (3 September 2010);
*''Image:Maedhros_sketch.jpeg'' to [[:Image:Ivanneth Maedhros.jpg]] (21 September 2010);
*''Category:Tolkien Gateway:Users'' to [[:Category:Gatekeepers]] (7 October 2010);
*''Category:User lore-3'' to <nowiki>[[Category:User lore-3|{{PAGENAME}}]]</nowiki> (7 October 2010);
*''Category:IRC users'' to <nowiki>[[Category:IRC users|{{PAGENAME}}]]</nowiki> (7 October 2010);
*''<nowiki>[[Category:Sandboxes| K]]</nowiki>'' to <nowiki>[[Category:Sandboxes|K]]</nowiki> (7 October 2010);
*''<nowiki>[[Category:Sandboxes]]</nowiki>'' to <nowiki>[[Category:Sandboxes|{{PAGENAME}}]]</nowiki> (7 October 2010);
*''The Book of Lost Tales 1'' to [[The Book of Lost Tales Part 1]] (12 October 2010);
*''The Book of Lost Tales 2'' and ''The Book of Lost Tales Party Two'' to [[The Book of Lost Tales Part 2]] (12 October 2010);
*''Borondir Udalraph'' to [[Borondir]] (15 October 2010);
*''<nowiki>[[Faramir|Faramir]]</nowiki>'' to [[Faramir]] (15 October 2010);
*''<nowiki>[[Boromir|Boromir]]</nowiki>'' to [[Boromir]] (15 October 2010);
*''<nowiki>[[Beleg|Beleg]]</nowiki>'' to [[Beleg]] (15 October 2010);
*''<nowiki>[[Minas Tirith|Minas Tirith]]</nowiki>'' to [[Minas Tirith]] (15 October 2010);
*''<nowiki>[[Gandalf|Gandalf]]</nowiki>'' to [[Gandalf]] (15 October 2010);
*''<nowiki>[[Malach|Malach]]</nowiki>'' to [[Malach]] (16 October 2010);
*''<nowiki>[[Elros|Elros]]</nowiki>'' to [[Elros]] (16 October 2010);
*''<nowiki>[[Barahir|Barahir]]</nowiki>'' to [[Barahir]] (16 October 2010);
*''<nowiki>[[Anárion|Anárion]]</nowiki>'' to [[Anárion]] (16 October 2010);
*''<nowiki>[[Electronic Arts|Electronic Arts]]</nowiki>'' to [[Electronic Arts]] (16 October 2010);
*''<nowiki>[[Bilbo's Farewell Party|Bilbo's Farewell Party]]</nowiki>'' to [[Bilbo's Farewell Party]] (16 October 2010);
*''<nowiki>[[Lords of Andúnië|Lords of Andúnië]]</nowiki>'' to [[Lords of Andúnië]] (16 October 2010);
*''<nowiki>[[Samwise Gamgee|Samwise Gamgee]]</nowiki>'' to [[Samwise Gamgee]] (16 October 2010);
*''<nowiki>[[Peregrin Took|Peregrin Took]]</nowiki>'' to [[Peregrin Took]] (16 October 2010);
*''<nowiki>[[Hobson|Hobson]]</nowiki>'' to [[Hobson]] (16 October 2010);

Revision as of 22:40, 16 October 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: