User:KitanBot/Completed Tasks/Wwclub
From WoWWiki
Contents |
Overview
| Completed: | 2007/04/05 |
| Run Time: | 1 hours |
| Page Count: | ~40 pages |
Task
There was a Bot Request to deprecate {{500club}}, et al, for {{Wwclub}}.
Issues
- CrazyJack and Varghedin were edited manually. They had special characters that looked like √ and û but their pages actually contained those characters and not the escape code. I decided to just switch these manually to not have them wait.
- So were Jeoh, who had Template:2500club instead of {{2500club}}, and Hobinheim whose reference was in his bio template which Bot did not pick up.
- Gryphon was unedited, and the only one left using the deprecated templates, because he is protected.
- Bot had some special character issues besides the above. Fixed and 5 of the 7 special character issues were taken into account. Seems like unicode needs to be considered.
- Bot's retry page update, due to timeout etc, needs to be rewritten to be faster.
- Bot had a few minor connection issues.
- Bot's webcrawler had a minor issue that was taken care of.
Algorithm
namespace WikiUpdateAlgorithmWwclub
{
public class WikiUpdateAlgorithmWwclub : IWikiUpdaterAlgorithm
{
public string UpdateWiki(string CurrentWiki)
{
//Objects Required
string SearchWiki = CurrentWiki.ToLower();
StringBuilder Current = new StringBuilder(CurrentWiki);
Dictionary<string, string> Replacements = new Dictionary<string, string>();
//Primatives
string[] Templates = { "{{500club}}", "{{1000club}}", "{{2500club}}", "{{5000club}}", "{{10000club}}", "{{25000club}}", "{{50000club}}"};
int Position;
bool Continue;
foreach (string Template in Templates)
{
Position = 0;
Continue = true;
while (Continue)
{
Position = SearchWiki.IndexOf(Template, Position);
if (Position >= 0)
{
Replacements.Add(CurrentWiki.Substring(Position, Template.Length), "{{Wwclub|" + Template.Replace("{{", " ").Replace("club}}", " ").Trim() + "}}");
Position += Template.Length;
}
else
{
Continue = false;
}
}
}
foreach (KeyValuePair<string, string> Replacement in Replacements)
{
Current.Replace(Replacement.Key, Replacement.Value);
}
return Current.ToString();
}
/// <summary>
/// Returns the update summary for the post action.
/// </summary>
/// <returns></returns>
public string UpdateSummary()
{
return "Updated page to use the Wwclub Template.";
}
}
}