Bots Home
|
Create an App
Cassie's Spanking Special
Author:
cassie
Description
Source Code
Launch Bot
Current Users
Created by:
Cassie
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){ "use strict"; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } var cli = require('../domain/cli'); var spank = require('../domain/spanking'); var user = require('../domain/user'); cb.settings_choices = [{ name: 'tokenGoal', type: 'int', label: 'Number of tokens to collect (the goal to reach)', defaultValue: '100' }, { name: 'tokensPerStroke', type: 'int', label: 'The price of one stroke in tokens', defaultValue: '5' }, { name: 'startColor', type: 'str', label: 'Color code for start/stop announcements (i.e. #3464eb)', defaultValue: '#3464eb' }, { name: 'updateColor', type: 'str', label: 'Color code for update announcements (i.e. #eb9c34)', defaultValue: '#eb9c34' }]; function setupSpankingSpecial(router) { var printer = new spank.DefaultPrinter(cb, new spank.Style(cb.settings.startColor, null, 'bolder'), new spank.Style(cb.settings.updateColor, null, 'bold')); var special = new spank.SpankingSpecial(printer, cb.settings.tokenGoal, cb.settings.tokensPerStroke); router.help('### Cassie\'s Spanking Special ####', 'While the special is running, tip to add spanks to the tally.'); router.add('spanking').action(function (args) { return router.showHelp(); }).help('Show this help screen'); router.add('spanking start').role('broadcaster', 'mod').action(function (args) { return special.start(args[0], args[1]); }).help('Start a new spanking special (and abort a running one)'); router.add('spanking stop').role('broadcaster', 'mod').action(function (args) { return special.stop(); }).help('Stop the currently running special'); return special; } var MyPrinter = /*#__PURE__*/function () { function MyPrinter() { _classCallCheck(this, MyPrinter); } _createClass(MyPrinter, [{ key: "printString", value: function printString(str) { cb.sendNotice(str); } }]); return MyPrinter; }(); var router = new cli.Router('!', new MyPrinter()); var special = setupSpankingSpecial(router); cb.onMessage(function (msg) { router.execute(msg.m, user.msgToUser(msg, cb.room_slug)); }); cb.onTip(function (tip) { special.registerTip(tip['amount']); }); },{"../domain/cli":2,"../domain/spanking":3,"../domain/user":4}],2:[function(require,module,exports){ "use strict"; function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } var Router = /*#__PURE__*/function () { function Router(prefix, printer) { _classCallCheck(this, Router); this._prefix = prefix || '!'; this._printer = printer || new RouterPrinter(); this._commands = []; this._help = ''; } _createClass(Router, [{ key: "help", value: function help() { for (var _len = arguments.length, text = new Array(_len), _key = 0; _key < _len; _key++) { text[_key] = arguments[_key]; } this._help = text.join('\n'); return this; } }, { key: "add", value: function add(name) { var cmd = new Command(name); this._commands.push(cmd); this._commands.sort(function (a, b) { return b._name.length - a._name.length; }); return cmd; } }, { key: "execute", value: function execute(str, user) { if (!str.startsWith(this._prefix)) { return; } var roles = user ? user.roles : []; // normalize whitespace and strip prefix var cmdline = str.replace(/\s+/g, ' ').substring(this._prefix.length); var _iterator = _createForOfIteratorHelper(this._commands), _step; try { for (_iterator.s(); !(_step = _iterator.n()).done;) { var command = _step.value; if (command.matches(cmdline, roles)) { return command.run(cmdline); } } } catch (err) { _iterator.e(err); } finally { _iterator.f(); } } }, { key: "showHelp", value: function showHelp() { var _this = this; var cmds = this._commands.slice(); cmds.sort(function (a, b) { return b._name - a._name; }); var out = cmds.map(function (cmd) { return "Type \"".concat(_this._prefix).concat(cmd._name, "\" - ").concat(cmd._help); }); if (this._help) { out.unshift(this._help); } this._printer.printString(out.join('\n')); } }]); return Router; }(); var Command = /*#__PURE__*/function () { function Command(name) { _classCallCheck(this, Command); this._name = name; this._help = ''; this._action = function () {}; // no-op this._roles = []; // access for everyone } _createClass(Command, [{ key: "help", value: function help(text) { this._help = text; return this; } }, { key: "action", value: function action(func) { this._action = func; return this; } }, { key: "role", value: function role() { for (var _len2 = arguments.length, roles = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { roles[_key2] = arguments[_key2]; } this._roles = roles; return this; } }, { key: "matches", value: function matches(cmdline, roles) { return (cmdline === this._name || cmdline.startsWith(this._name + ' ')) && (this._roles.length == 0 || this._roles.some(function (e) { return roles.includes(e); })); } }, { key: "run", value: function run(cmdline) { return this._action(this.getArgs(cmdline)); } }, { key: "getArgs", value: function getArgs(cmdline) { var remainingArgs = cmdline.substring(this._name.length + 1).trim(); // strip command from args return remainingArgs.length > 0 ? remainingArgs.split(/\s+/) : []; } }]); return Command; }(); var RouterPrinter = /*#__PURE__*/function () { function RouterPrinter() { _classCallCheck(this, RouterPrinter); } _createClass(RouterPrinter, [{ key: "printString", value: function printString(str) { console.log(str); } }]); return RouterPrinter; }(); module.exports.Router = Router; module.exports.RouterPrinter = RouterPrinter; },{}],3:[function(require,module,exports){ "use strict"; function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } var SpankingSpecial = /*#__PURE__*/function () { function SpankingSpecial(printer, defaultTokenGoal, defaultTokensPerStroke) { _classCallCheck(this, SpankingSpecial); _defineProperty(this, "printer", new DefaultPrinter()); _defineProperty(this, "defaultTokenGoal", 20); _defineProperty(this, "defaultTokensPerStroke", 2); _defineProperty(this, "tokenGoal", 0); _defineProperty(this, "tokensPerStroke", 0); _defineProperty(this, "currentTokens", 0); _defineProperty(this, "active", false); this.printer = printer || this.printer; this.defaultTokenGoal = defaultTokenGoal || this.defaultTokenGoal; this.defaultTokensPerStroke = defaultTokensPerStroke || this.defaultTokensPerStroke; } _createClass(SpankingSpecial, [{ key: "start", value: function start(tokenGoal, tokensPerStroke) { this.tokenGoal = parseInt(tokenGoal || this.defaultTokenGoal); this.tokensPerStroke = parseInt(tokensPerStroke || this.defaultTokensPerStroke); this.currentTokens = 0; this.active = true; this.printer.start(this.tokenGoal, this.tokensPerStroke); } }, { key: "registerTip", value: function registerTip(amount) { if (!this.active) { return; } this.currentTokens = Math.min(this.currentTokens + amount, this.tokenGoal); if (this.isComplete()) { this.active = false; this.printer.complete(this.currentTokens, this.getStrokes()); } else { this.printer.tally(this.currentTokens, this.getStrokes(), this.tokensPerStroke); } } }, { key: "stop", value: function stop() { if (!this.active) { return; } this.printer.complete(this.currentTokens, this.getStrokes()); this.active = false; } }, { key: "isActive", value: function isActive() { return this.active; } }, { key: "isComplete", value: function isComplete() { return this.currentTokens >= this.tokenGoal; } }, { key: "getStrokes", value: function getStrokes() { return this.tokensPerStroke ? Math.floor(this.currentTokens / this.tokensPerStroke) : 0; } }, { key: "getTokensLeft", value: function getTokensLeft() { return this.tokenGoal - this.currentTokens; } }, { key: "getPricePerStroke", value: function getPricePerStroke() { return this.tokensPerStroke; } }]); return SpankingSpecial; }(); var DefaultPrinter = /*#__PURE__*/function () { function DefaultPrinter(cb, startStyle, updateStyle) { _classCallCheck(this, DefaultPrinter); this.cb = cb; this.startStyle = startStyle || new Style(); this.updateStyle = updateStyle || new Style(); } _createClass(DefaultPrinter, [{ key: "start", value: function start(tokenGoal, tps) { var _this$cb; (_this$cb = this.cb).sendNotice.apply(_this$cb, ["Spanking Special has started! Up to ".concat(tokenGoal, " tokens, ").concat(tps, " tokens per stroke."), ''].concat(_toConsumableArray(this.startStyle.toArray()))); } }, { key: "tally", value: function tally(tokens, strokes, tps) { var _this$cb2; (_this$cb2 = this.cb).sendNotice.apply(_this$cb2, ["Splat! ".concat(tokens, " tokens and ").concat(strokes, " strokes so far."), ''].concat(_toConsumableArray(this.updateStyle.toArray()))); } }, { key: "complete", value: function complete(tokens, strokes) { var _this$cb3; (_this$cb3 = this.cb).sendNotice.apply(_this$cb3, ["Spanking Special completed! ".concat(tokens, " tokens and ").concat(strokes, " strokes collected. Ouch!"), ''].concat(_toConsumableArray(this.startStyle.toArray()))); } }]); return DefaultPrinter; }(); var Style = /*#__PURE__*/function () { // HTML color codes, weight is "normal", "bold", "bolder" function Style(foreground, background, weight) { _classCallCheck(this, Style); this.foreground = foreground; this.background = background; this.weight = weight; } _createClass(Style, [{ key: "toArray", value: function toArray() { return [this.background, this.foreground, this.weight]; } }]); return Style; }(); module.exports.SpankingSpecial = SpankingSpecial; module.exports.DefaultPrinter = DefaultPrinter; module.exports.Style = Style; },{}],4:[function(require,module,exports){ "use strict"; function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); } function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } var User = /*#__PURE__*/function () { function User(name, gender) { _classCallCheck(this, User); this.name = name; this.gender = gender; for (var _len = arguments.length, roles = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { roles[_key - 2] = arguments[_key]; } this.roles = roles; } _createClass(User, [{ key: "toMsg", value: function toMsg(msg) { return { m: msg, user: this.name, gender: this.gender, is_mod: this.roles.includes('mod'), in_fanclub: this.roles.includes('fan'), has_tokens: this.roles.includes('has_tokens'), tipped_recently: this.roles.includes('tipped_recently'), tipped_alot_recently: this.roles.includes('tipped_alot_recently'), tipped_tons_recently: this.roles.includes('tipped_tons_recently') }; } }]); return User; }(); function msgToUser(msg, roomName) { var roles = []; if (msg.user === roomName) roles.push('broadcaster'); if (msg.is_mod) roles.push('mod'); if (msg.in_fanclub) roles.push('fan'); if (msg.has_tokens) roles.push('has_tokens'); if (msg.tipped_recently) roles.push('tipped_recently'); if (msg.tipped_alot_recently) roles.push('tipped_alot_recently'); if (msg.tipped_tons_recently) roles.push('tipped_tons_recently'); return _construct(User, [msg.user, msg.gender].concat(roles)); } module.exports.User = User; module.exports.msgToUser = msgToUser; },{}]},{},[1]);
© Copyright Chaturbate 2011- 2024. All Rights Reserved.