/** * Module for interacting with a Szurubooru instance */ let { AbstractModule } = require('../abstract'); let { logger } = require('../../logging'); let szurubooruClient = require('./client'); class SzurubooruModule extends AbstractModule { constructor() { super( "Szurubooru", "Interact with a Szurubooru instance", "szurubooru" ); this.helpAndUsage = `Usage: '!szurubooru [...]' display a random post that matches tags '!szurubooru config' prints config information for the room '!szurubooru config upload' toggles uploading images from room messages '!szurubooru iqdb' get an IQDB link for the last displayed post '!szurubooru need []' show a random post that needs additional tags '!szurubooru post ' retrieve a post and publish the image to the room '!szurubooru random [...]' display a random image from szurubooru that matches tags if preset '!szurubooru random update' update the random counts '!szurubooru recent [ (1)]' display a recent random image within the last '!szurubooru related' display related posts to the last displayed post '!szurubooru tag [...]' add tags to the last displayed post '!szurubooru tag clone ' clone tags from to the last displayed post '!szurubooru tag remove [...]' remove tags from the last displayed post '!szurubooru tags' list of all tags by popularity '!szurubooru tags [...]' list tags similar to each '!szurubooru upload ' upload a remote file to szurubooru`; this.needConfig = true; this.defaultCommand = 'random'; } postInit() { super.postInit(); this.client = new szurubooruClient.Client( this.get("url"), this.get("username"), this.get("token") ) } getConfigSensitiveFields() { return ["token"]; } /* Commands * All methods starting with cmd_ will be parsed at initialization to expose those methods as commdands to the user */ cmd_random(event, ...args) { return this.client.getRandomPost().then((data) => { logger.info("Random post: %o", data); return data; }); } } exports.module = new SzurubooruModule();