MWBot.net 1.3.2

dotnet add package MWBot.net --version 1.3.2                
NuGet\Install-Package MWBot.net -Version 1.3.2                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MWBot.net" Version="1.3.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add MWBot.net --version 1.3.2                
#r "nuget: MWBot.net, 1.3.2"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install MWBot.net as a Cake Addin
#addin nuget:?package=MWBot.net&version=1.3.2

// Install MWBot.net as a Cake Tool
#tool nuget:?package=MWBot.net&version=1.3.2                

MWBot.net

Base library to create tools for sites based on Mediawiki software. - Base para crear herramientas para sitios basados en el software Mediawiki.

Simple usage examples - Ejemplos simples de uso

Loading a page, editing it and saving it. - Cargar una página, editarla y guardarla.

  • C#
using System;
using MWBot.net;
using MWBot.net.WikiBot;

namespace MyProgram
{
    class Program
    {
        static void TestMethod()
        {
            string configPath = @"c:\Config.cfg";
            string logPath = @"c:\log.psv";
            string usersPath = @"c:\users.psv";
            string botName = "MyCoolBotName";

            SimpleLogger EventLogger = new SimpleLogger(logPath, usersPath, botName, true);
            Bot Workerbot = new Bot(configPath, EventLogger);
            
            Page examplepage = Workerbot.GetPage("Example page");
            string newtext = examplepage.Content.Replace("Text", "NewText");
            //Do something
            examplepage.Save(newtext, "Test edit using C#!"); 
        }
    }
}
  • Visual Basic
Imports System
Imports MWBot.net
Imports MWBot.net.WikiBot

Namespace MyProgram
   Class Program   
      Public Shared Sub TestMethod()      
         Dim configPath As String = "c:\Config.cfg"
         Dim logPath As String = "c:\log.psv"
         Dim usersPath As String = "c:\users.psv"
         Dim botName As String = "MyCoolBotName"

         Dim EventLogger As New SimpleLogger(logPath, usersPath, botName, True)
         Dim Workerbot As Bot = New Bot(configPath, EventLogger)
        
         Dim examplepage as Page = Workerbot.Getpage("Example page")
         Dim newtext as String = examplepage.Content.Replace("Text", "Newtext")
         
         'Do something
         examplepage.Save(newtext, "Test edit using VB!")
      End Sub      
   End Class   
End Namespace
  • Template manipulation on VB
Imports System
Imports MWBot.net
Imports MWBot.net.WikiBot

Namespace MyProgram
   Class Program   
      Public Shared Sub TestMethod()      
        Dim configPath As String = "c:\Config.cfg"
        Dim logPath As String = "c:\log.psv"
        Dim usersPath As String = "c:\users.psv"
        Dim botName As String = "MyCoolBotName"

        Dim EventLogger As New SimpleLogger(logPath, usersPath, botName, True)
        Dim Workerbot As Bot = New Bot(configPath, EventLogger)

        'Load page
        Dim examplePage As Page = Workerbot.Getpage("Example page")
        Dim pageContent As String = examplePage.Content

        'Do something
        Dim templateName As String = "Cool template name"
        Dim oldParameterName As String = "Old parameter name"
        Dim newParameterName As String = "New and cool parameter name"

        If Template.IsTemplatePresentInText(pageContent, templateName) Then
            Dim templates As List(Of Template) = Template.GetTemplates(pageContent)
            For Each t As Template In templates
                Dim originalTemplateText As String = t.Text
                If t.Name.Trim.Equals(templateName.Trim) Then
                    If t.ContainsParameter(oldParameterName) Then
                        t.ChangeNameOfParameter(oldParameterName, newParameterName) 'This will remove the parameter from the template object changing the Text property of it.
                    End If
                End If
                pageContent = pageContent.Replace(originalTemplateText, t.Text) 'Replace the old template text with the new template text
            Next
        End If

        Dim minorEdit As Boolean = False
        Dim botEdit As Boolean = True
        Dim replaceBlacklistedLinks As Boolean = True
        Dim editSummary As String = "Cool template manipulation"

        examplePage.Save(pageContent, editSummary, minorEdit, botEdit, replaceBlacklistedLinks)
      End Sub      
   End Class   
End Namespace
  • Template Manipulation on C#
using System;
using MWBot.net;
using MWBot.net.WikiBot;
namespace MyProgram
{
    class Program
    {
        public static void TestMethod()
        {
            string configPath = @"c:\Config.cfg";
            string logPath = @"c:\log.psv";
            string usersPath = @"c:\users.psv";
            string botName = "MyCoolBotName";

            SimpleLogger EventLogger = new SimpleLogger(logPath, usersPath, botName, true);
            Bot Workerbot = new Bot(configPath, EventLogger);

            // Load page
            Page examplePage = Workerbot.Getpage("Example page");
            string pageContent = examplePage.Content;

            // Do something
            string templateName = "Cool template name";
            string oldParameterName = "Old parameter name";
            string newParameterName = "New and cool parameter name";

            if (Template.IsTemplatePresentInText(pageContent, templateName))
            {
                List<Template> templates = Template.GetTemplates(pageContent);
                foreach (Template t in templates)
                {
                    string originalTemplateText = t.Text;
                    if (t.Name.Trim.Equals(templateName.Trim()))
                    {
                        if (t.ContainsParameter(oldParameterName))
                            t.ChangeNameOfParameter(oldParameterName, newParameterName);// This will remove the parameter from the template object changing the Text property of it.
                    }
                    pageContent = pageContent.Replace(originalTemplateText, t.Text); // Replace the old template text with the new template text
                }
            }

            bool minorEdit = false;
            bool botEdit = true;
            bool replaceBlacklistedLinks = true;
            string editSummary = "Cool template manipulation";

            examplePage.Save(pageContent, editSummary, minorEdit, botEdit, replaceBlacklistedLinks);
        }
    }
}
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

1.3.2