Jump to content

User:FritzpollBot/Code for task 3

From Wikipedia, the free encyclopedia
Private Sub ExecuteTask3(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim s As New DotNetWikiBot.Site(sourceSite.Text, "Fritzpoll", ''password redacted'')

        Dim p As New DotNetWikiBot.PageList(s)

        Dim prefix As String = Mid(sourceSite.Text, 1, InStr(sourceSite.Text, ".") - 1)
        Dim returner As New ArrayList()

        p.FillSubsFromCategory(sourceCategory.Text)
        p.Insert(New DotNetWikiBot.Page(s, s.CorrectNSPrefix("Category:" & sourceCategory.Text)), 0)


        For Each cat As DotNetWikiBot.Page In p
            returner.Add(vbCrLf & "===[[:" & prefix & ":" & cat.title & "]]===" & vbCrLf)

            Dim pList As New DotNetWikiBot.PageList(s)
            pList.FillFromCategory(cat.title)

            For Each pg As DotNetWikiBot.Page In pList.pages
                Dim interWiki As String()
                pg.Load()
                If pg.IsEmpty() Then
                    Continue For
                End If
                interWiki = pg.GetInterWikiLinks(False)

                Dim enFound As Boolean = False
                For Each ss As String In interWiki
                    If InStr(ss, "en:") <> 0 Then
                        enFound = True
                        Exit For
                    End If
                Next

                If Not enFound Then
                    returner.Add("[[" & pg.title & "]] ([[:" & prefix & ":" & pg.title & "|" & prefix & "]])")
                End If
            Next
        Next


        s = New DotNetWikiBot.Site("en.wikipedia.org", "FritzpollBot", ''password redacted'')

        Dim pp As New DotNetWikiBot.Page(s, targetPage.Text)
        pp.Load()


        Dim j As Integer
        pp.text = ""
        For j = 0 To returner.Count - 1
            pp.text = pp.text & returner(j) & vbCrLf

        Next

        pp.Save("Updating - test edit", False)

        MessageBox.Show("Done")
End Sub