User:IlyaHaykinson/Wikinewsbot

I've started development on a framework for MediaWiki bots. I refuse to accept that the existing Interwiki bot framework in python is as good as it can get, so I'm trying to write an easy to understand, extensible bot framework in .NET.

The primary goal is to be able to receive images from the Wikinews:WeatherChecker process and to be able to auto-upload them and update the relevant pages to relink to the new images.

Current development

edit

The state of development is outlined for those interested. The application has been released under the GPL and is available at http://www.tiredbrain.com/wikinews/wikinewsbot/

Implemented

edit
  • bot framework started
  • login and edit-page fetch is working
  • request throttling in place
    • wikinews has no policy on bots.
  • ability to save pages
  • ability upload images
  • support for XML config files (not like the one below, but similar)
  • fully automated test on Commons image upload, Wikinews file editing. Please see page listed under "current development" for CVS etc info.

Future work

edit
  • more commands
  • better global / local variable separation
  • rate limiting fix
  • better international support
  • complileable framework for command extensions kind of like the data below
<bot wiki="$$wikisite">
	<command name="Login">
		<param name="username" value="$$username" />
		<param name="password" value="$$password" />
	</command>
	<command name="GeneratePageList">
		<output value="$pagelist" />
		<param name="startDate" value="January 12, 2005"/>
		<param name="endDate" value="January 31, 2005" />
		<script>
			<references lib="System" />
			<code classname="DateTimeRangePageListDataProvider">
				public class DateTimeRangePageListDataProvider : PageListDataProvider
				{
					DateTime _current;
					DateTime _last;

					public GeneratePageListDataProvider(CommandParams parameters) 
					{
						_current = DateTime.Parse(parameters["startDate"].ToString());
						_last = DateTime.Parse(parameters["endDate"].ToString());
					}

					public override bool GetPage(out string pageName)
					{
						DateTime toReturn = _current;

						pageName = _current.ToString("MMMM d, yyyy");

						_current.AddDays(1);
						return _current <= _last;
					}
				}
			</code>
		</script>
	</command>
	<command name="ProcessPageList">
		<param name="source" value="$pagelist" />
		<script>
			<references lib="System" />
			<references lib="System.Text" />
			<references lib="System.Text.RegularExpressions" />
			<code classname="AddDateTemplatePageProcessor">
				public class AddDateTemplatePageProcessor : PageProcessor
				{
				
					PageList _pageList;
				
					public AddDateTemplatePageProcessor(CommandParams parameters)
					{
						_pageList = parameters["source"] as PageList;
					}
					
					public override void Process(WikiPage page)
					{
						//code to look for {{datecategory|date-for-this-page-title... in the page wikitext
						
						//if not found, code to insert before everything else {{datecategory|blah...}}
					}
				}
			</code>
		</script>
	</command>
</bot>        
  • implement snippet compilation for command plugins