Utilisateur:LoveBot/Sources/Main.cs
Apparence
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using DotNetWikiBot;
namespace LoveBot
{
class Program
{
static void Main(string[] args)
{
Site site = new Site("http://fr.wikipedia.org", "LoveBot", "******");
FilterManager helper = new FilterManager();
// Utile à l'arrêt d'urgence.
Page talkPage = new Page(site, "Discussion utilisateur:LoveBot");
talkPage.watched = true;
talkPage.Load();
string lastTalkText = talkPage.text;
// Pages scannées.
PageList collection = new PageList(site);
collection.FillAllFromCategoryTree("Catégorie:******");
// Boucle de traitement.
foreach (Page article in collection)
{
bool isConcerned = true;
if (article.title.Length >= "Discussion:".Length)
{
if (article.title.Substring(0, "Discussion:".Length) == "Discussion:")
{
isConcerned = false;
}
}
if (isConcerned)
{
bool obsolete = true;
article.Load();
string data = article.text;
string dataInit = data;
obsolete = helper.SearchAndSolveObsoleteModels(ref data, article.title);
// Chargement de la page de discussion.
talkPage.Load();
if (talkPage.text.Length > lastTalkText.Length)
{
// Arrêt d'urgence.
string[] talkPageParseSeparator = new string[1];
talkPageParseSeparator[0] = lastTalkText;
string[] talkPageParseResult = talkPage.text.Split(talkPageParseSeparator, 2, StringSplitOptions.RemoveEmptyEntries);
if (talkPageParseResult.Length > 0)
{
int index = talkPageParseResult[0].IndexOf("Stopper_LoveBot");
if (index != -1)
break;
}
}
if (data.Length != dataInit.Length)
{
article.text = data;
//Ici, remplacer par SaveSmoothly qui intègre le timer.
try
{
article.Save("Robot Remplace modèles obsolètes.", true);
System.Threading.Thread.Sleep(25000);// wait 25 secondes.
}
catch (Exception e)
{
string message = e.Message.ToString();
}
}
}
}
}
}
}