User:Mithbot/Scripts: Difference between revisions
From Tolkien Gateway
m (Added RemoveNamespaces for future reference) |
m (Added list of jobs) |
||
Line 19: | Line 19: | ||
}</pre> | }</pre> | ||
To avoid certain namespaces, add this before <code>p.LoadEx();</code>, User and Template in this example:- | To avoid certain namespaces, add this before <code>p.LoadEx();</code>, User and Template in this example:- | ||
<pre> | <pre> | ||
p.RemoveNamespaces(new int[] {2,10});</pre> | |||
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: | 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: | ||
*Bilbo to [[Bilbo Baggins]] (14 June 2010); | *''Bilbo'' to [[Bilbo Baggins]] (14 June 2010); | ||
*Siriondil of Gondor to [[Siriondil (King of Gondor)]] (14 June 2010); | *''Siriondil of Gondor'' to [[Siriondil (King of Gondor)]] (14 June 2010); | ||
*Calmacil of Gondor to [[Calmacil (King of Gondor)]] (14 June 2010); | *''Calmacil of Gondor'' to [[Calmacil (King of Gondor)]] (14 June 2010); | ||
*Cemendur of Gondor to [[Cemendur (King of Gondor)]] (14 June 2010); | *''Cemendur of Gondor'' to [[Cemendur (King of Gondor)]] (14 June 2010); | ||
*''Eärendil of Gondor'' to [[Eärendil (King of Gondor)]] (14 June 2010); | |||
*''Anardil of Gondor'' to [[Anardil (King of Gondor)]] (14 June 2010); | |||
*''Turambar of Gondor'' to [[Turambar (King of Gondor)]] (14 June 2010); | |||
*''Eldacar of Gondor'' to [[Eldacar (King of Gondor)]] (14 June 2010); | |||
*''Tarondor of Gondor'' to [[Tarondor (King of Gondor)]] (14 June 2010); | |||
*''Calimehtar, King of Gondor'' to [[Calimehtar (King of Gondor)]] (14 June 2010); | |||
*''Amandil of Andúnië'' to [[Amandil (Lord of Andúnië)]] (14 June 2010); | |||
*''Anárion son of Elendil'' to [[Anárion]] (14 June 2010); | |||
*Changing "||" to "|" - fixing own mistake (15 June 2010); | |||
*''Eärendur, Lord of Andúnië'' to [[Eärendur (Lord of Andúnië)]] (15 June 2010); | |||
*''Valandil of Númenor'' to [[Valandil (Lord of Andúnië)]] (15 June 2010); | |||
*''Silmarien'' to [[Silmariën]] (15 June 2010); | |||
*''Ardamir son of Axantur'' to [[Ardamir (son of Axantur)]] (15 June 2010); | |||
*''Eärendur, son of Tar-Amandil'' to [[Eärendur (son of Tar-Amandil)]] (15 June 2010); | |||
*''Cemendur of Númenor'' to [[Cemendur (son of Axantur)]] (15 June 2010); | |||
*''Aulendil of Númenor'' to [[Aulendil (son of Vardamir)]] (15 June 2010); | |||
*''Eärendur, King of Arnor'' to [[Eärendur (King of Arnor)]] (15 June 2010); | |||
*''Elendur, son of Isildur'' to [[Elendur (son of Isildur)]] (15 June 2010); | |||
*''Elendur, King of Arnor'' to [[Elendur (King of Arnor)]] (15 June 2010); | |||
*''Tarondor of Arnor'' to [[Tarondor (King of Arnor)]] (15 June 2010); | |||
*''Valandil of Arnor'' to [[Valandil (King of Arnor)]] (15 June 2010); | |||
*''Eldacar of Arnor'' to [[Eldacar (King of Arnor)]] (15 June 2010); | |||
*''Beleg of Arthedain'' to [[Beleg (King of Arthedain)]] (15 June 2010); | |||
*''Faramir son of Ondoher'' to [[Faramir (son of Ondoher)]] (15 June 2010); | |||
*''Beregond, Steward of Gondor'' to [[Beregond (Steward of Gondor)]] (15 June 2010); | |||
*''Boromir I'' and ''Boromir son of Denethor I'' to [[Boromir (Steward of Gondor)]] (15 June 2010); | |||
*''Dior of Gondor'' to [[Dior (Steward of Gondor)]] (15 June 2010); | |||
*''Steward Cirion'' to [[Cirion]] (15 June 2010); | |||
*''Barahir son of Hador'' to [[Barahir (Steward of Gondor)]] (15 June 2010); | |||
*''Hador of Gondor'' to [[Hador (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); |
Revision as of 13:23, 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:
- Bilbo to Bilbo Baggins (14 June 2010);
- Siriondil of Gondor to Siriondil (King of Gondor) (14 June 2010);
- Calmacil of Gondor to Calmacil (King of Gondor) (14 June 2010);
- Cemendur of Gondor to Cemendur (King of Gondor) (14 June 2010);
- Eärendil of Gondor to Eärendil (King of Gondor) (14 June 2010);
- Anardil of Gondor to Anardil (King of Gondor) (14 June 2010);
- Turambar of Gondor to Turambar (King of Gondor) (14 June 2010);
- Eldacar of Gondor to Eldacar (King of Gondor) (14 June 2010);
- Tarondor of Gondor to Tarondor (King of Gondor) (14 June 2010);
- Calimehtar, King of Gondor to Calimehtar (King of Gondor) (14 June 2010);
- Amandil of Andúnië to Amandil (Lord of Andúnië) (14 June 2010);
- Anárion son of Elendil to Anárion (14 June 2010);
- Changing "||" to "|" - fixing own mistake (15 June 2010);
- Eärendur, Lord of Andúnië to Eärendur (Lord of Andúnië) (15 June 2010);
- Valandil of Númenor to Valandil (Lord of Andúnië) (15 June 2010);
- Silmarien to Silmariën (15 June 2010);
- Ardamir son of Axantur to Ardamir (son of Axantur) (15 June 2010);
- Eärendur, son of Tar-Amandil to Eärendur (son of Tar-Amandil) (15 June 2010);
- Cemendur of Númenor to Cemendur (son of Axantur) (15 June 2010);
- Aulendil of Númenor to Aulendil (son of Vardamir) (15 June 2010);
- Eärendur, King of Arnor to Eärendur (King of Arnor) (15 June 2010);
- Elendur, son of Isildur to Elendur (son of Isildur) (15 June 2010);
- Elendur, King of Arnor to Elendur (King of Arnor) (15 June 2010);
- Tarondor of Arnor to Tarondor (King of Arnor) (15 June 2010);
- Valandil of Arnor to Valandil (King of Arnor) (15 June 2010);
- Eldacar of Arnor to Eldacar (King of Arnor) (15 June 2010);
- Beleg of Arthedain to Beleg (King of Arthedain) (15 June 2010);
- Faramir son of Ondoher to Faramir (son of Ondoher) (15 June 2010);
- Beregond, Steward of Gondor to Beregond (Steward of Gondor) (15 June 2010);
- Boromir I and Boromir son of Denethor I to Boromir (Steward of Gondor) (15 June 2010);
- Dior of Gondor to Dior (Steward of Gondor) (15 June 2010);
- Steward Cirion to Cirion (15 June 2010);
- Barahir son of Hador to Barahir (Steward of Gondor) (15 June 2010);
- Hador of Gondor to Hador (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);