using System;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections;
using System.Xml;
using System.Threading;
using DotNetWikiBot;
class MyBot : Bot
{
public void MyFunction1()
{
// Write your own function here
}
/// The entry point function. Start coding here.
public static void Main()
{
int antal = 0;
string[] korrekta = {"en", "fr", "de", "cs", "ru", "es", "it", "pt", "el", "fi", "ja"};
Site site = new Site("http://sv.wikiversity.org", "Innocent bot", "********");
PageList pl = new PageList(site);
/*
pl.FillFromAllPages("!", 0, false,1000);
pl.FillFromAllPages("H", 0, false,1000);
pl.FillFromAllPages("S", 0, false,1000);
pl.FillFromAllPages("V", 0, false,1000);
pl.FillFromAllPages("!", 4, false,1000);
pl.FillFromAllPages("H", 4, false,1000);
pl.FillFromAllPages("S", 4, false,1000);
pl.FillFromAllPages("V", 4, false,1000);
/**/
pl.FillFromAllPages("!", 10, false,1000);
pl.FillFromAllPages("H", 10, false,1000);
pl.FillFromAllPages("S", 10, false,1000);
pl.FillFromAllPages("V", 10, false,1000);
pl.RemoveRecurring();
foreach(Page p in pl)
{
p.LoadEx();
string tmpStr = p.text;
//if (p.Exists())
//Console.WriteLine(p.text);
foreach(string iw in p.GetInterWikiLinks())
{
string pre = iw.Substring(0,iw.IndexOf(":"));
int temp = 0;
foreach(string k in korrekta)
{
if(k == pre)
temp = 1;
}
Console.WriteLine(pre);
if(temp == 0)
{
p.text = p.text.Replace("\n[["+iw+"]]", "");
p.text = p.text.Replace("[["+iw+"]]", "");
}
}
if(p.text != tmpStr)
{
Bot.editComment = "Tar bort iw-länk(ar) till projekt som inte finns på Wikiversity";
Bot.isMinorEdit = true;
p.Save();
Thread.Sleep(25000);
antal++;
Console.WriteLine(antal);
Console.WriteLine(p.title);
}
}
}
}