Wikipedia:Projekt DotNetWikiBot Framework/Innocent bot/Ny parameter i Mall Ishockeyspelare
Utseende
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 void MyFunction1() { // Write your own function here } public static void Main() { Site site = new Site("http://sv.wikipedia.org", "Innocent bot", "********"); PageList pl = new PageList(site); pl.FillFromLinksToPage("Mall:Ishockeyspelare"); pl.RemoveNamespaces(new int[] {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,100,101}); foreach(Page p in pl) { p.Load(); string namn = ""; foreach(string s1 in p.GetTemplateParameter("Ishockeyspelare" , "namn")) namn = s1; if(namn != "") { //Console.WriteLine(namn); } else { namn = p.title; if(namn.IndexOf("(") != -1) namn = namn.Substring(0, namn.IndexOf("(")); p.SetTemplateParameter("Ishockeyspelare", "namn", namn, true); Bot.editComment = "Lägger in parameter 'namn' enl [[WP:RH]]"; isMinorEdit = true; p.Save(); Thread.Sleep(30000); } } } }