User:MiniBot/Code/BotProtect
From eRepublik Official Wiki
< User:MiniBot | Code
Revision as of 02:21, 14 July 2008 by MiniBill (Talk | contribs) (New page: I, the author, release this code as public domain <pre> using System; using System.IO; using System.Threading; using System.Collections.Generic; using DotNetWikiBot; namespace MiniBot{ p...)
I, the author, release this code as public domain
using System; using System.IO; using System.Threading; using System.Collections.Generic; using DotNetWikiBot; namespace MiniBot{ public class BotProtect{ public static Dictionary<string,string> pages=new Dictionary<string,string>(); public static string[] pageNames=new string[]{"Community","Romania","Presidents - May 2008","Presidents - June 2008","Template:PresidentTable"}; public static void LoadPages(){ foreach(string page in pageNames) using(StreamReader s=File.OpenText(page+".txt")) pages.Add(page,s.ReadToEnd()); } public BotProtect(){ if(pages.Count==0) LoadPages(); } public void Protect(Site site){ bool c=true; while(true){ c=!c; foreach(string page in pageNames){ Page p=new Page(site,page); p.Load(true); Console.Write(c?".":":"); int e=0; while(e<p.text.Length&&p.text[e]==pages[page][e]) e++; if(e!=p.text.Length){ Console.WriteLine(page); p.text=pages[page]; if(p.lastUser!="MiniBot") p.Save(); else Console.WriteLine("???"); } } Thread.Sleep(500); } } } }