Difference between revisions of "User:MiniBot/Code/UserCategorize"

From eRepublik Official Wiki
Jump to: navigation, search
m (Added full code)
 
(No difference)

Latest revision as of 04:08, 14 July 2008

I, the author, release this code as public domain

using System;
using DotNetWikiBot;

namespace MiniBot{
	public class UserPager{
		public UserPager(){
		}
		public void Page(Site s){
			Page users=new Page(site,"Special:Allpages");
			users.Load("&namespace=2");
			Regex good=new Regex("/index.php/User:[^/]*?\"");
			foreach(Match m in good.Matches(users.text)){
				Page p=new Page(site,m.Value.Substring(11,m.Value.Length-12));
				p.Load();
				if(!Contains(p.GetAllCategories(),"Category:Citizen")){
					p.AddToCategory("Citizen");
					p.Save();
				}
			}
		}
		public static bool Contains(string[] db,string val){
			foreach(string s in db)
				if(s==val)
					return true;
			return false;
		}
	}
}