This user account is a bot operated by Luis150902 (talk). It is used to make repetitive automated or semi-automated edits that would be extremely tedious to do manually, in accordance with the bot policy. This bot does not yet have the approval of the community, or approval has been withdrawn or expired, and therefore shouldn't be making edits that appear to be unassisted except in the operator's or its own user and user talk space. Administrators: if this bot is making edits that appear to be unassisted to pages not in the operator's or its own userspace, please block it. |
This bot was formerly designed to remove {{Sockpuppeteer}}
templates after 5 minutes with no sockpuppet investigation created, but has never edited and is inactive.
Source code
editusing System;
using DotNetWikiBot;
namespace LuisBot01
{
// This bot removes sockpuppeteers with no sockpuppet investigations casepage.
public class MyBot : Bot
{
public static void Main()
{
Console.Write("Password: ");
Site enWiki = new Site("http://en.wikipedia.org", "LuisBot01", Console.ReadLine());
PageList pl = new PageList(enWiki);
PageList usernames = new PageList(enWiki), usernames2 = new PageList(enWiki);
int cycleNumber = 0;
while (true)
{
pl.FillFromCategory("Category:Wikipedia sockpuppeteers");
pl.FilterNamespaces(new int[] { 2, 3 });
usernames2 = new PageList(enWiki);
foreach (Page p in pl)
{
usernames2.Add(p);
}
foreach (Page p in usernames)
{
string s = p.title.Remove(0, p.GetNamespace() == 3 ? 10 : 5);
Page spi = new Page(enWiki, "Wikipedia:Sockpuppet investigations/" + s);
spi.Load();
if (!spi.Exists())
{
// In the case of an edit conflict, i increments and we retry to save up to 5 times.
for (int i = 0; i < 5; i++)
{
try
{
p.Load();
p.RemoveTemplate("Sockpuppeteer");
p.RemoveFromCategory("Category:Wikipedia sockpuppeteers");
p.Save(string.Format("Removing {0} from user with no [[Wikipedia:Sockpuppet investigations/{1}|SPI]] (DotNetWikiBot 3.15)", "{{[[Template:Sockpuppeteer|Sockpuppeteer]]}}", s));
}
catch (InsufficientRightsException e)
{
// Ignore InsufficientRightsException.
Console.WriteLine("Caught exception when trying to edit, and stopped: ");
Console.WriteLine(e.ToString());
break;
}
catch (BotDisallowedException e)
{
// Ignore BotDisallowedException.
Console.WriteLine("Caught exception when trying to edit, and stopped: ");
Console.WriteLine(e.ToString());
break;
}
catch (WikiBotException e)
{
if (e is EditConflictException)
{
if (i != 4)
{
// Let's retry.
Console.WriteLine("Edit conflict. Retry #" + (i + 1));
}
continue;
}
// Ignore WikiBotException.
Console.WriteLine("Caught exception when trying to edit, and stopped: ");
Console.WriteLine(e.ToString());
break;
}
}
}
}
// New cycle. Wait 5 minutes.
usernames = usernames2;
Console.WriteLine("Cycle {0} done.", cycleNumber++);
Bot.Wait(300);
}
}
}
}