Page MenuHomePhabricator

Vandalism information command
Closed, WontfixPublic

Description

Create a command to show the current vandalism information for enwiki.

Tech spec

As this command and it's templates are very enwiki-focused, we'll hard-code this for enwiki rather than using the API frameworks.

  1. Find out how to get the current vandalism level - possibly using the API with a request like this
  2. Create a new class under src/Helpmebot/Legacy/Commands, in namespace helpmebot6.Commands called Vandalinfo, inheriting from GenericCommand
  3. Give the new class an empty constructor calling the base constructor: public Vandalinfo(LegacyUser source, string channel, string[] args, ICommandServiceHelper commandServiceHelper) : base(source, channel, args, commandServiceHelper) { }
  4. Create a new method in the class: protected override CommandResponseHandler ExecuteCommand(). This method is the body of the command, so in this method we can implement the command. For now, make it do return new CommandResponseHandler("Hello World!");, and give it a test - it should now print "Hello World!" when you call !vandalinfo from IRC.
  5. Create a new method private string GetVandalismInformation(), which performs a web request to the API to retrieve the relevant information. The rough process you want to use is to pass the URL to HttpRequest.Get(url).ToStream(), which should return a Stream you can pass to XDocument.Load(new StreamReader(stream)) to get an instance of an XDocument. You can then use this to get the relevant bit out of the API result. See ExtensionMethods/MediaWikiSiteExtensions for some guidance, see how you get on. Make this method return the text you want to display as a string.
  6. Modify your ExecuteCommand() method to call the GetVandalismInformation() method, and print that to IRC instead.