using System;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections;
using System.Xml;
using DotNetWikiBot;
using System.Threading;
class MyBot : Bot
{
public void MyFunction1()
{
// Write your own function here
}
public static void Main()
{
Site site = new Site("http://sv.wikipedia.org", user, password);
PageList pl = new PageList(site);
pl.FillSubsFromCategory("Seriefigurer efter introduktionsår");
pl.RemoveNamespaces(new int[] {0});
string tmpStr = "";
string oldStr = "";
string newStr = "";
string year = "";
int start = 0;
int end = 0;
bool isNum;
int ar;
foreach (Page myPage in pl)
{
myPage.Load();
tmpStr = myPage.text;
start = tmpStr.IndexOf("[[en:Category:");
if(start > 0)
{
end = tmpStr.Substring(start).IndexOf("]]");
oldStr = tmpStr.Substring(start, end + 2);
Console.WriteLine(oldStr);
year = oldStr.Substring(14, 4);
Console.WriteLine(year);
isNum = int.TryParse(year, out ar);
if(isNum)
{
newStr = "[[en:Category:Comics characters introduced in " + year + "]]";
Console.WriteLine(newStr);
tmpStr = myPage.text.Replace(oldStr, newStr);
myPage.Save(tmpStr, "Byter interwiki för enwp efter namnbyte där", true);
Thread.Sleep(7000);
}
}
}
}
}