ybtools

package module
v0.0.0-...-a466290 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 19, 2020 License: GPL-3.0 Imports: 4 Imported by: 0

README

Yapperbot Tools

A set of imports used by other Wikipedia bots I've created. These probably won't be of much use to anyone else, but you're welcome to them in accordance with the license if you like!

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FetchWikitext

func FetchWikitext(w *mwclient.Client, pageID string) (content string, err error)

FetchWikitext takes a client and a pageId and gets the wikitext of that page. The default functionality in the library does not work for this in my experience; it just returns an empty string for some reason. So we're rolling our own!

func GetCategorisationTimestampFromPage

func GetCategorisationTimestampFromPage(page *jason.Object, category string) (timestamp string)

GetCategorisationTimestampFromPage takes a page, and gets the timestamp at which the page was categorised. All the errors in this function are Fatal, because frankly, if something's gone wrong with the timestamp reading, we're not really going to be able to run the algorithm correctly anyway.

func GetContentFromPage

func GetContentFromPage(page *jason.Object) (content string, err error)

GetContentFromPage turns a *jason.Object for a Page into the main slot content, and/or an applicable error.

Yes, there is a function to do this already in the library (GetPagesByName). No, I don't want to use it. Why? We've already got the page content here - making another request to get it again is wasteful when we could just locally parse what we already have.

func GetPagesFromQuery

func GetPagesFromQuery(resp *jason.Object) []*jason.Object

GetPagesFromQuery takes a query and returns an array of Pages.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL