A library for writing Wikipedia bots. Used by the FACBot and MilHistBot.
$ dotnet add package Wikimedia.LibraryThe Wikimedia library is designed to facilitate the writing of Wikipedia command line tools and bots in the C# language.
Source code can be downloaded from https://gitlab.wikimedia.org/toolforge-repos/milhistbot-wikimedia
Here is an example of a C# program that uses the library
using Wikimedia;
class Example
{
static void Main(string[] args)
{
Cred.Instance.Showtime("Started");
Cred.Version();
Cred.Instance.User = "your userid";
Cred.Instance.Password = "your password";
Cred.Instance.MailList = [ "your email address" ];
Cred.Instance.Showtime("Job = " + Cred.Instance.Job);
Cred.Instance.Showtime("User = " + Cred.Instance.User);
Cred.Instance.Showtime("Logs directory = " + Cred.Instance.LogsDirectory);
var page = PageFactory.GetPage ("Word count");
page.Load();
Console.WriteLine("Word count = " + page.WordsCount());
Cred.Instance.Showtime("Finished");
}
}
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
<PackageReference Include="wikimedia.library" Version="2.1.13" />
</ItemGroup>
</Project>
Now you can build it with:
dotnet build
And run it with:
dotnet run
var page = new ArticlePage("Word count");
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>