User:MiniBot/Code/BotScript

From eRepublik Official Wiki
Jump to: navigation, search

Note: the commented code isn't mine, but I left it for you to learn.

This code just prepares for a Bot execution

using System;
using DotNetWikiBot;

class MyBot : Bot{
	/// The entry point function. Start coding here.
	public static void Main(){
		// Here are some code examples:
		Console.WriteLine(">Enter password:");
		string pwd=Console.ReadLine();
		Site site = new Site("http://wiki.erepublik.com", "MiniBot", pwd);

		//Do Something here: e.g.:

		//BotProtect p=new BotProtect();
		//p.Protect(site);

		//UserPager p=new UserPager();
		//p.Page(site);

		//PoliticalCleaner p=new PoliticalCleaner();
		//p.Clean(site);

		Console.WriteLine("End");
	}
}

Here you have some example code, taken from the library

p.SaveToFile("dir\\file.txt");
p.LoadFromFile("dir\\file.txt");
p.ResolveRedirect();
site.ShowNamespaces();
Console.WriteLine(p.GetNamespace());
p.text = "test string";
Bot.editComment = "test";
Bot.isMinorEdit = true;
p.Save();

string[] arr = {"Art", "Poetry", "Cinematography", "Camera", "Image"};
PageList pl = new PageList(site, arr);
pl.LoadEx();
pl.FillFromAllPages("Sw", 0, true, 100);
pl.FillFromFile("dir\\text.txt");
pl.FillFromCategory("Category:Cinematography");
pl.FillFromAllPageLinks("Cinematography");
pl.FillFromLinksToPage("Cinematography");
pl.RemoveEmpty();
pl.RemoveDisambigs();
pl.ResolveRedirects();
Console.WriteLine(pl[2].text);
pl[1].text = "#REDIRECT [[Some Page]]";
pl.FilterNamespaces(new int[] {0,3});
pl.RemoveNamespaces(new int[] {2,4});
pl.SaveTitlesToFile("dir\\text.txt");
pl.Clear();
Bot.editComment = "my edit comment";
isMinorEdit = true;
pl.Save();