User:Autotroph

From Nookipedia, the Animal Crossing wiki
Jump to navigation Jump to search
Autotroph
Flowers.jpg
"Autotrophs are organisms that produce their own food. Contrast this to heterotrophs such as decomposers."
Status Bot
Edit Count 4,703 ( in mainspace)
Gender Unknown
Service bot
Appearances Unknown


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

Sonchou stuff[edit]

Apparently Nookipedia:AutoWikiBrowser exists... Oh well.

Example usage[edit]

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)
	}

}

Recategorization project[edit]

Or cleaning up Category:Images. For now I'm creating subcategories for each game. Heavily based from discussion found in Nookipedia talk:Community Fountain#Image category organization.

If some task is completed their appropriate code will be placed here.

Number of uncategorized images[edit]

Hopefully by the end of the year this becomes zero. Use ~~~~~: COUNT.

  • 10:14, February 8, 2020 (EST): 6688
  • 05:10, February 9, 2020 (EST): 7418
  • 02:04, February 29, 2020 (EST): 8204 (probably from decategorizing from meta-categories (Category:Game Screenshots and the like)
  • 05:14, February 29, 2020 (EST): 7052 (although there are still images that have been non-categorized in their placed metacategories)
  • 06:39, February 29, 2020 (EST): 7011

Cards[edit]

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[edit]

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"},
	)
}

Fanart[edit]

func recategorizeFanart(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:Fanart - ") {
				return mediawiki.DidNothingError{Pagename: pagename}
			}
			return mediawiki.Recategorize(pagename, client, []string{}, []string{"Fanart"})
		},
		client,
	)
}

Letters[edit]

func recategorizeToLetters(client *mwclient.Client) chan error {
	return mediawiki.PerformInPageChannel(
		mediawiki.QueryUncategorizedImages(client),
		func(pagename string, client *mwclient.Client, optional ...interface{}) error {
			if !strings.Contains(pagename, "Letter") {
				return mediawiki.DidNothingError{Pagename: pagename}
			}
			return mediawiki.Recategorize(pagename, client, optional...)
		},
		client,
		[]string{},
		[]string{`Letters`},
	)
}

Category:Wild World images[edit]

func recategorizeWWcharacters(client *mwclient.Client) chan error {
	return mediawiki.PerformInPageChannel(
		mediawiki.QueryCategoryMembers("Wild World characters", client),
		func(pagename string, client *mwclient.Client, optional ...interface{}) error {
			filename := "File:" + pagename + " WW.png"
			glog.Infof("Performing on %v...", filename)
			return mediawiki.Recategorize(filename, client, []string{"Wild World images"}, []string{"Wild World character art"})
		},
		client,
	)
}
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 recategorizeWWpictures(client *mwclient.Client) chan error {
	return mediawiki.PerformInPageChannel(
		mediawiki.QueryCategoryMembers("Wild World images", client),
		func(pagename string, client *mwclient.Client, optional ...interface{}) error {
			if !strings.HasPrefix(pagename, "File:") || !strings.HasSuffix(pagename, "PicACWW.png") {
				return mediawiki.DidNothingError{Pagename: pagename}
			}
			return mediawiki.Recategorize(pagename, client, []string{"Wild World images"}, []string{"Wild World pictures"})
		},
		client,
	)
}
func recategorizeWWhouses(client *mwclient.Client) chan error {
	return mediawiki.PerformInPageChannel(
		mediawiki.QueryCategoryMembers("Wild World images", client),
		func(pagename string, client *mwclient.Client, optional ...interface{}) error {
			if !strings.HasPrefix(pagename, "File:House of ") {
				return mediawiki.DidNothingError{Pagename: pagename}
			}
			return mediawiki.Recategorize(pagename, client, []string{"Wild World images"}, []string{"Wild World villager houses"})
		},
		client,
	)
}
func recategorizeWWmodelRenders(client *mwclient.Client) chan error {
	return mediawiki.PerformInPageChannel(
		mediawiki.QueryCategoryMembers("Wild World images", client),
		func(pagename string, client *mwclient.Client, optional ...interface{}) error {
			if !strings.HasPrefix(pagename, "File:") || !strings.HasSuffix(pagename, " WW Model.png") {
				return mediawiki.DidNothingError{Pagename: pagename}
			}
			return mediawiki.Recategorize(pagename, client, []string{"Wild World images"}, []string{"Wild World model renders"})
		},
		client,
	)
}

Category:City Folk images[edit]

func recategorizeCFfishImages(client *mwclient.Client) chan error {
	return mediawiki.PerformInPageChannel(
		mediawiki.QueryFiles("Fish/City Folk", client),
		func(pagename string, client *mwclient.Client, optional ...interface{}) error {
			if !strings.HasPrefix(pagename, "File:") || !strings.HasSuffix(pagename, " (City Folk).png") {
				return mediawiki.DidNothingError{Pagename: pagename}
			}
			return mediawiki.Recategorize(pagename, client, []string{"City Folk images", "Fish Images", "Icon Sprites"}, []string{"City Folk fish images"})
		},
		client,
	)
}
func recategorizeCFbugImages(client *mwclient.Client) chan error {
	return mediawiki.PerformInPageChannel(
		mediawiki.QueryFiles("Bugs/City Folk", client),
		func(pagename string, client *mwclient.Client, optional ...interface{}) error {
			if !strings.HasPrefix(pagename, "File:") || !strings.HasSuffix(pagename, " (City Folk).png") {
				return mediawiki.DidNothingError{Pagename: pagename}
			}
			return mediawiki.Recategorize(pagename, client, []string{"City Folk images", "Insect images", "Icon Sprites"}, []string{"City Folk bug images"})
		},
		client,
	)
}
func recategorizeToCFclothingTextures(client *mwclient.Client) chan error {
	return mediawiki.PerformInPageChannel(
		mediawiki.QueryUncategorizedImages(client),
		func(pagename string, client *mwclient.Client, optional ...interface{}) error {
			if !strings.Contains(pagename, `(CF)`) { // kinda naïve
				return mediawiki.DidNothingError{Pagename: pagename}
			}
			return mediawiki.Recategorize(pagename, client, optional...)
		},
		client,
		[]string{},
		[]string{`City Folk clothing textures`},
	)
}

Category:New Leaf images[edit]

func recategorizeToNLprereleaseScreenshots(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:AC3") {
				return mediawiki.DidNothingError{Pagename: pagename}
			}
			return mediawiki.Recategorize(pagename, client, optional...)
		},
		client,
		[]string{},
		[]string{`New Leaf pre-release screenshots`},
	)
}

Category:Welcome amiibo images[edit]

These will be subcats of their types (WA character art is subcat of Category:Character art) but not of the NL cat (Category:New Leaf character art).

func recategorizeWAimagesToWAhouses(client *mwclient.Client) chan error {
	return mediawiki.PerformInPageChannel(
		mediawiki.QueryCategoryMembers("Welcome amiibo images", client),
		func(pagename string, client *mwclient.Client, optional ...interface{}) error {
			if !strings.HasPrefix(pagename, "File:House of ") || !strings.HasSuffix(pagename, " NLa.jpg") {
				return mediawiki.DidNothingError{Pagename: pagename}
			}
			return mediawiki.Recategorize(pagename, client, optional...)
		},
		client,
		[]string{"Welcome_amiibo_images"},
		[]string{"Welcome_amiibo_villager_houses"},
	)
}

Category:Happy Home Designer images[edit]

  • Recategorized all images in Uncat that contain "HHD"
func recategorizeToHHDimages(client *mwclient.Client) chan error {
	return mediawiki.PerformInPageChannel(
		mediawiki.QueryUncategorizedImages(client),
		func(pagename string, client *mwclient.Client, optional ...interface{}) error {
			if !strings.Contains(strings.ToLower(pagename), "hhd") { // case-insensitive
				return mediawiki.DidNothingError{Pagename: pagename}
			}
			return mediawiki.Recategorize(pagename, client, optional...)
		},
		client,
		[]string{},
		[]string{`Happy Home Designer images`},
	)
}
func recategorizeToHHDbugIcons(client *mwclient.Client) chan error {
	return mediawiki.PerformInPageChannel(
		mediawiki.QueryFiles("Bugs/New Leaf", client),
		func(pagename string, client *mwclient.Client, optional ...interface{}) error {
			if !strings.HasPrefix(pagename, "File:") || !strings.HasSuffix(pagename, " HHD Icon.png") {
				return mediawiki.DidNothingError{Pagename: pagename}
			}
			return mediawiki.Recategorize(pagename, client, []string{}, []string{"Happy Home Designer bug sprites"})
		},
		client,
	)
}
func recategorizeToHHDfishIcons(client *mwclient.Client) chan error {
	return mediawiki.PerformInPageChannel(
		mediawiki.QueryFiles("Fish/New Leaf", client),
		func(pagename string, client *mwclient.Client, optional ...interface{}) error {
			if !strings.HasPrefix(pagename, "File:") || !strings.HasSuffix(pagename, " HHD Icon.png") {
				return mediawiki.DidNothingError{Pagename: pagename}
			}
			return mediawiki.Recategorize(pagename, client, []string{}, []string{"Happy Home Designer fish sprites"})
		},
		client,
	)
}
func recategorizeToHHDdscIcons(client *mwclient.Client) chan error {
	return mediawiki.PerformInPageChannel(
		mediawiki.QueryFiles("Template:Deep sea creatures", client),
		func(pagename string, client *mwclient.Client, optional ...interface{}) error {
			if !strings.HasSuffix(pagename, " HHD Icon.png") {
				return mediawiki.DidNothingError{Pagename: pagename}
			}
			return mediawiki.Recategorize(pagename, client, []string{"Happy Home Designer furniture icons"}, []string{"Happy Home Designer deep sea creature sprites"})
		},
		client,
	)
}
// WARNING: Really naive!
func recategorizeHHDcharacterArt(client *mwclient.Client) []error {
	return mediawiki.PerformInCategory(
		"Happy Home Designer images",
		func(pagename string, client *mwclient.Client, optional ...interface{}) error {
			if !strings.HasPrefix(pagename, "File:") || !strings.HasSuffix(pagename, " HHD.png") {
				return mediawiki.DidNothingError{Pagename: pagename}
			}
			return mediawiki.Recategorize(pagename, client, []string{"Happy Home Designer images"}, []string{"Happy Home Designer character art"})
		},
		client,
	)
}
func recategorizeHHDimagesToHHDcharacterIcons(client *mwclient.Client) chan error {
	return mediawiki.PerformInPageChannel(
		mediawiki.QueryCategoryMembers(`Happy Home Designer images`, client),
		func(pagename string, client *mwclient.Client, optional ...interface{}) error {
			if !strings.HasSuffix(pagename, `HHDIcon.png`) {
				return mediawiki.DidNothingError{Pagename: pagename}
			}
			return mediawiki.Recategorize(pagename, client, optional...)
		},
		client,
		[]string{`Happy Home Designer images`},
		[]string{`Happy Home Designer character icons`},
	)
}
  • Category:Happy Home Designer villager houses
    • Move all images that end with HHD Request.png or HHD.png
func recategorizeHHDvillagerHouses(client *mwclient.Client) []error {
	return mediawiki.PerformInCategory(
		"Happy Home Designer images",
		func(pagename string, client *mwclient.Client, optional ...interface{}) error {
			// ONLY RUN AFTER RECAT'ING CHARACTER ART
			if !strings.HasPrefix(pagename, "File:") || !(strings.HasSuffix(pagename, " HHD Request.png") || strings.HasSuffix(pagename, "HHD.png")) {
				return mediawiki.DidNothingError{Pagename: pagename}
			}
			return mediawiki.Recategorize(pagename, client, []string{"Happy Home Designer images"}, []string{"Happy Home Designer villager houses"})
		},
		client,
	)
}
func recategorizeToHHDfurnitureIcons(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, " HHD Icon.png") {
				return mediawiki.DidNothingError{Pagename: pagename}
			}
			return mediawiki.Recategorize(pagename, client, []string{}, []string{"Happy Home Designer furniture icons"})
		},
		client,
	)
}

The following images may need to be manually recategorized due to permission restrictions: