Documentation ¶
Index ¶
- func BotAllowed(pageContent string) bool
- func CanEdit() bool
- func CreateAndAuthenticateClient() *mwclient.Client
- func EditLimit() bool
- func FetchWikitext(pageID string) (content string, err error)
- func FetchWikitextFromTitle(pageTitle string) (content string, err error)
- func GetCategorisationTimestampFromPage(page *jason.Object, category string) (timestamp string)
- func GetContentFromPage(page *jason.Object) (content string, err error)
- func GetPagesFromQuery(resp *jason.Object) []*jason.Object
- func GetThingFromQuery(resp *jason.Object, thing string) []*jason.Object
- func LoadJSONFromPageID(pageID string) *jason.Object
- func LoadJSONFromPageTitle(pageTitle string) *jason.Object
- func PanicErr(v ...interface{})
- func ParseTaskConfig(cobj interface{})
- func SaveEditLimit()
- func SerializeToJSON(serializable interface{}) string
- func SetupBot(taskname string, botuser string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BotAllowed ¶ added in v0.1.1
BotAllowed take a page content and determines if the botUser is allowed to edit the page per the applicable templates.
func CanEdit ¶ added in v1.3.0
func CanEdit() bool
CanEdit checks if the task has been killed, and then checks if the bot is edit limited. This *must* be used for all edits apart from those which only affect the bot's own userspace, or those which must run even if the task is killed (e.g. updating JSON files which describe the run which was just done).
func CreateAndAuthenticateClient ¶ added in v0.1.6
func CreateAndAuthenticateClient() *mwclient.Client
CreateAndAuthenticateClient uses the details already passed into ybtools in setup.go to return a fully-authenticated mwclient
func EditLimit ¶ added in v0.1.5
func EditLimit() bool
EditLimit can be called to increment the current edit count Returns true if allowed to edit or false if not Remember to call SaveEditLimit at the end of the program if using this!
func FetchWikitext ¶
FetchWikitext takes 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 FetchWikitextFromTitle ¶ added in v1.2.0
FetchWikitextFromTitle takes a title and gets the wikitext of that page.
func GetCategorisationTimestampFromPage ¶
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 ¶
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 ¶
GetPagesFromQuery takes a query and returns an array of Pages. Convenience wrapper for GetThingFromQuery.
func GetThingFromQuery ¶ added in v1.1.0
GetThingFromQuery takes a query and a key that's being looked for, and returns the inner thing array.
func LoadJSONFromPageID ¶ added in v1.2.0
LoadJSONFromPageID takes a pageID, then loads and deserializes the contained JSON. It returns the deserialised JSON in a jason.Object pointer.
func LoadJSONFromPageTitle ¶ added in v1.2.0
LoadJSONFromPageTitle takes a title string, then loads and deserializes the contained JSON. It returns the deserialised JSON in a jason.Object pointer.
func PanicErr ¶ added in v1.3.0
func PanicErr(v ...interface{})
PanicErr panics the program with a specified message, also sending a message to the tool inbox on Toolforge explaining the issue.
func ParseTaskConfig ¶ added in v0.1.6
func ParseTaskConfig(cobj interface{})
ParseTaskConfig takes in a pointer to a config object and populates the config object with the task configuration
func SaveEditLimit ¶ added in v0.1.5
func SaveEditLimit()
SaveEditLimit saves the current edit limit to the edit limit file, assuming that there is an edit limit usage to save This function must be called at the end of the program for edit limiting to work
func SerializeToJSON ¶ added in v1.2.0
func SerializeToJSON(serializable interface{}) string
SerializeToJSON takes in any serializable object and returns the serialized JSON string
Types ¶
This section is empty.