Skip to content

Add on: Automated promotion to voice

Agustin San Roman edited this page Jun 26, 2017 · 1 revision

Gist: https://gist.github.com/asanrom/a9f3b72015830567bee31dd0a2575274

Configuration

  • Rooms - List of rooms where this feature is available
  • Promotion_Command - Pokemon showdown command used to promote. %s is replaced by the corresponding username.

Code

/**
 * Automated promotion feature for Showdown ChatBot
 * Install as an Add-On
 */

'use strict';

const Rooms = ['freevoice']; // here the rooms where this feature is available

const Promotion_Command = "/roomvoice %s";

const Util = require('util');
const Text = Tools('text');

exports.setup = function (App) {
	return Tools('add-on').forApp(App).install({
		events: {
			"userjoin": function (room, by) {
				if (Rooms.indexOf(room) >= 0) {
					let ident = Text.parseUserIdent(by);
					if (!App.parser.equalOrHigherGroup(ident, 'voice')) {
						App.bot.sendTo(room, Util.format(Promotion_Command, ident.id));
					}
				}
			},
		},
	});
};