User:Autotroph

From Nookipedia, the Animal Crossing wiki
CF Watering Flowers.jpg
"Autotrophs are organisms that produce their own food. Contrast this to heterotrophs such as decomposers."
Status
Bot
Edit count 5,740 (0 in mainspace)
Service bot

I'm a bot employed by User:Decomposer. Send all inquiries to my master.

As of 2021 October 31, sonchou doesn't seem to work. Hmm

Sonchou stuff

Apparently Nookipedia:AutoWikiBrowser exists... Oh well.

Example usage

Use one of the recategorization functions below.

package main

import (
	"flag"
	"fmt"
	"os"
	"strings"

	"gitlab.com/melancholera/go-mwclient"
	"gitlab.com/melancholera/sonchou/pkg/mediawiki"
)

// Go to nookipedia.com/wiki/Special:BotPasswords to get your own.
const username = "Your bot username"
const password = "Your bot password (this one is invalid)"

func errorAndExit(err error) {
	if err == nil {
		return // do nothing
	}
	fmt.Printf("error: %T %v\n", err, err)
	fmt.Printf("stack trace:\n%+v\n", err)
	os.Exit(1)
}

func recategorizeWWfishImages(client *mwclient.Client) chan error {
	return mediawiki.PerformInPageChannel(
		mediawiki.QueryFiles("Fish/Wild World", client),
		func(pagename string, client *mwclient.Client, optional ...interface{}) error {
			if !strings.HasPrefix(pagename, "File:") || !strings.HasSuffix(pagename, " WW.png") {
				return mediawiki.DidNothingError{Pagename: pagename}
			}
			return mediawiki.Recategorize(pagename, client, []string{"Wild World images"}, []string{"Wild World fish images"})
		},
		client,
	)
}

func main() {
	flag.Parse()
	client, err := mwclient.New(mediawiki.NookipediaAPIUrl, mediawiki.DefaultUserAgent)
	errorAndExit(err)

	err = client.Login(username, password)
	errorAndExit(err)

	for err = range recategorizeWWfishImages(client) {
		fmt.Println(err)
	}

}

Run this stuff with go run main.go --stderrthreshold INFO

Recategorization functions

Cards

func recategorizeJapaneseAmiibo(client *mwclient.Client) chan error {
	return mediawiki.PerformInPageChannel(
		mediawiki.QueryUncategorizedImages(client),
		func(pagename string, client *mwclient.Client, optional ...interface{}) error {
			if !strings.HasPrefix(pagename, "File:") || !strings.HasSuffix(pagename, " amiibo JP.png") {
				return mediawiki.DidNothingError{Pagename: pagename}
			}
			return mediawiki.Recategorize(pagename, client, []string{}, []string{"Japanese amiibo cards"})
		},
		client,
	)
}
func recategorizeToDnMeCards(client *mwclient.Client) chan error {
	return mediawiki.PerformInPageChannel(
		mediawiki.QueryUncategorizedImages(client),
		func(pagename string, client *mwclient.Client, optional ...interface{}) error {
			if strings.HasPrefix(pagename, `File:Animal Crossing-e 1-`) {
				return mediawiki.Recategorize(pagename, client, []string{}, []string{`Animal Crossing-e Series 1`})
			}
			if strings.HasPrefix(pagename, `File:Animal Crossing-e 2-`) {
				return mediawiki.Recategorize(pagename, client, []string{}, []string{`Animal Crossing-e Series 2`})
			}
			if strings.HasPrefix(pagename, `File:Animal Crossing-e 3-`) {
				return mediawiki.Recategorize(pagename, client, []string{}, []string{`Animal Crossing-e Series 3`})
			}
			if strings.HasPrefix(pagename, `File:Animal Crossing-e 4-`) {
				return mediawiki.Recategorize(pagename, client, []string{}, []string{`Animal Crossing-e Series 4`})
			}
			return mediawiki.DidNothingError{Pagename: pagename}
		},
		client,
	)
}

3DS themes

func recategorize3DSThemes(client *mwclient.Client) []error {
	return mediawiki.PerformInFiles(
		"List of 3DS themes",
		func(pagename string, client *mwclient.Client, optional ...interface{}) error {
			if !strings.HasPrefix(pagename, "File:3DS Theme - ") || !strings.HasSuffix(pagename, ".png") {
				return mediawiki.DidNothingError{Pagename: pagename}
			}
			return mediawiki.Perform(pagename, mediawiki.Recategorize, client, []string{}, []string{"Nintendo 3DS themes"})
		},
		client)
}
  • Moved images from uncat
func recategorizeTo3DSThemes(client *mwclient.Client) chan error {
	return mediawiki.PerformInPageChannel(
		mediawiki.QueryUncategorizedImages(client),
		func(pagename string, client *mwclient.Client, optional ...interface{}) error {
			if !strings.HasPrefix(pagename, "File:3DS Theme - ") {
				return mediawiki.DidNothingError{Pagename: pagename}
			}
			return mediawiki.Recategorize(pagename, client, optional...)
		},
		client,
		[]string{},
		[]string{"Nintendo 3DS themes"},
	)
}

Caught screenshots: remove "Game" Screenshots cat

func recategorizeNHCaughts(client *mwclient.Client) chan error {
	toCat := make(chan string, 100)
	go func() {
		cats := []string{
			"New Horizons caught item screenshots",
			"New Horizons caught sea creature screenshots",
			"New Horizons caught bug screenshots",
			"New Horizons caught fish screenshots",
		}
		for _, cat := range cats {
			for vv := range mediawiki.QueryCategoryMembers(cat, client) {
				toCat <- vv
			}
		}

		close(toCat)
	}()

	return mediawiki.PerformInPageChannel(
		toCat,
		func(pagename string, client *mwclient.Client, optional ...interface{}) error {
			if !strings.HasPrefix(pagename, "File:") {
				return mediawiki.DidNothingError{Pagename: pagename}
			}
			return mediawiki.Recategorize(pagename, client, []string{"New Horizons screenshots"}, []string{})
		},
		client,
	)
}