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 static void Main()
{
Site site = new Site("http://sv.wikisource.org", "Innocent bot", "********");
//string slutmapp = "Klar";
{
string mapp = Directory.GetCurrentDirectory() + "\\OCR";
foreach(string fil in Directory.GetFiles(mapp, "*.txt"))
{
string titel = Path.GetFileName(fil);
//Hur man får fram titeln på sidan, varierar naturligtvis med typ av fil...
titel = titel.Substring(0,titel.IndexOf(".txt"));
titel = "Sida:"+titel+".jpg";
Page myPage = new Page(site, titel);
myPage.Load();
if(myPage.Exists())
{
string text = myPage.text.Substring(0,myPage.text.IndexOf("</noinclude>")+12);
text = text + File.ReadAllText(fil);
text = text + myPage.text.Substring(myPage.text.Substring(15).IndexOf("<noinclude>")+15);
myPage.text = text;
}
else
myPage.LoadFromFile(fil);
Bot.editComment = "Lägger in OCR-text";
Bot.isMinorEdit = false;
myPage.Save();
File.Move(fil, Directory.GetCurrentDirectory() + "\\OCR\\Klar\\" + Path.GetFileName(fil));
Thread.Sleep(7000);
}
}
}
}