Bots Home
|
Create an App
newtestbotjim
Author:
jimdev
Description
Source Code
Launch Bot
Current Users
Created by:
Jimdev
(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"; Object.defineProperty(exports, "__esModule", { value: true }); exports.App = void 0; var _PubSub = require("./PubSub"); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 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 App = function App() { _classCallCheck(this, App); _defineProperty(this, "init", function () { cb.onStart(function (user) { _PubSub.pubSub.publish('botStart', user); }); cb.onTip(function (tip) { _PubSub.pubSub.publish('newTip', tip); }); cb.onEnter(function (user) { _PubSub.pubSub.publish('userEnter', user); cb.sendNotice('User Entered'); }); cb.onLeave(function (user) { _PubSub.pubSub.publish('userLeave', user); }); cb.onMessage(function (msg) { _PubSub.pubSub.publish('newMsg', msg); cb.sendNotice('Message Sent'); }); }); this.init(); }; exports.App = App; },{"./PubSub":2}],2:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.pubSub = void 0; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 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 PubSub = function PubSub() { var _this = this; _classCallCheck(this, PubSub); _defineProperty(this, "subscribe", function (evName, fn) { _this.events[evName] = _this.events[evName] || []; _this.events[evName].push(fn); }); _defineProperty(this, "unsubscribe", function (evName, fn) { if (_this.events[evName]) { _this.events[evName] = _this.events[evName].filter(function (func) { return func !== fn; }); } }); _defineProperty(this, "publish", function (evName, data) { if (_this.events[evName]) { _this.events[evName].forEach(function (func) { return func(data); }); } }); this.events = {}; }; var pubSub = new PubSub(); exports.pubSub = pubSub; },{}],3:[function(require,module,exports){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.User = void 0; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 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 User = function User(user) { var _this = this; var _options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; _classCallCheck(this, User); _defineProperty(this, "updateUser", function () { var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; _this.in_fanclub = options.in_fanclub || _this.in_fanclub; _this.has_tokens = options.has_tokens || _this.has_tokens; _this.is_mod = options.is_mod || _this.is_mod; _this.tipped_recently = options.tipped_recently || _this.tipped_recently; _this.tipped_alot_recently = options.tipped_alot_recently || _this.tipped_alot_recently; _this.tipped_tons_recently = options.tipped_tons_recently || _this.tipped_tons_recently; _this.gender = options.gender || _this.gender; return _this; }); this.user = user; this.in_fanclub = _options.in_fanclub; this.has_tokens = _options.has_tokens; this.is_mod = _options.is_mod; this.tipped_recently = _options.tipped_recently; this.tipped_alot_recently = _options.tipped_alot_recently; this.tipped_tons_recently = _options.tipped_tons_recently; this.gender = _options.gender; }; exports.User = User; },{}],4:[function(require,module,exports){ "use strict"; var _PubSub = require("./core/PubSub"); var _UserData = require("./plugins/UserData"); var _App = require("./core/App"); var app = new _App.App(); // cb.onStart((user) => { // pubSub.publish('botStart', user); // }); // cb.onTip((tip) => { // pubSub.publish('newTip', tip); // }); // cb.onEnter((user) => { // pubSub.publish('userEnter', user); // }); // cb.onLeave((user) => { // pubSub.publish('userLeave', user); // }); // cb.onMessage((msg) => { // pubSub.publish('newMsg', msg); // }); },{"./core/App":1,"./core/PubSub":2,"./plugins/UserData":5}],5:[function(require,module,exports){ "use strict"; function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } Object.defineProperty(exports, "__esModule", { value: true }); exports.userData = void 0; var _PubSub = require("../core/PubSub"); var _User2 = require("../core/User"); function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; } function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } 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 _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 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 UserData = function UserData() { var _this = this; _classCallCheck(this, UserData); _defineProperty(this, "createUserOnStart", function () { cb.getRoomUsersData(function (usersData) { if (usersData.success) { usersData.data.dark_purple.forEach(function (name) { _this.userEnter({ user: name, tipped_tons_recently: true }); }); usersData.data.light_purple.forEach(function (name) { _this.userEnter({ user: name, tipped_alot_recently: true }); }); usersData.data.dark_blue.forEach(function (name) { _this.userEnter({ user: name, tipped_recently: true }); }); usersData.data.light_blue.forEach(function (name) { _this.userEnter({ user: name }); }); usersData.data.grey.forEach(function (name) { _this.userEnter({ user: name, tipped_recently: false }); }); usersData.data.fanclub.forEach(function (name) { _this.userEnter({ user: name, in_fanclub: true, tipped_recently: true }); }); usersData.data.moderator.forEach(function (name) { _this.userEnter({ user: name, is_mod: true }); }); } }); }); _defineProperty(this, "userEnter", function (cbUser) { var user = cbUser.user, rest = _objectWithoutProperties(cbUser, ["user"]); var roomUser = _this.getUserByName(user); if (roomUser) { roomUser.updateUser(rest).setColor(_this.getColor(roomUser)); _this.currentUsers.push(roomUser); var str = JSON.stringify(roomUser); cb.sendNotice("".concat(str)); } else { var newUser = new RoomUser(user, rest); newUser.setColor(_this.getColor(newUser)); _this.totalUsers.push(newUser); _this.currentUsers.push(newUser); var _str = JSON.stringify(newUser); cb.sendNotice("".concat(_str)); } }); _defineProperty(this, "updateUserOnMsg", function (cbMsg) { var newProps = { in_fanclub: cbMsg.in_fanclub, has_tokens: cbMsg.has_tokens, is_mod: cbMsg.is_mod, tipped_recently: cbMsg.tipped_recently }; var roomUser = _this.getUserByName(cbMsg.user); roomUser.updateUser(newProps); var str = JSON.stringify(roomUser); cb.sendNotice("".concat(str)); return cbMsg; }); _defineProperty(this, "updateUserOnTip", function (cbTip) { var newProps = { in_fanclub: cbTip.from_user_in_fanclub, has_tokens: cbTip.from_user_has_tokens, is_mod: tip.from_user_is_mod, tipped_recently: cbTip.from_user_tipped_recently, tipped_alot_recently: cbTip.from_user_tipped_alot_recently, tipped_tons_recently: cbTip.from_user_tipped_tons_recently, gender: cbTip.from_user_gender }; var roomUser = _this.getUserByName(cbTip.from_user); roomUser.updateUser(newProps).setColor(_this.getColor(roomUser)).updateTips(cbTip); var str = JSON.stringify(roomUser); cb.sendNotice("".concat(str)); }); _defineProperty(this, "updateUserOnLeave", function (cbUser) { var roomUser = _this.getUserByName(cbUser.user); var index = _this.currentUsers.indexOf(roomUser); _this.currentUsers.splice(index, 1); }); _defineProperty(this, "getUserByName", function (userName) { if (_this.totalUsers.some(function (obj) { return obj.user === userName; })) { return _this.totalUsers.find(function (obj) { return obj.user === userName; }); } else return false; }); _defineProperty(this, "getColor", function (roomUser) { // const roomUser = this.getUserByName(userName); if (roomUser.tipped_tons_recently) { return 'Dark Purple'; } else if (roomUser.tipped_alot_recently) { return 'Purple'; } else if (roomUser.tipped_recently) { return 'Dark Blue'; } else if (roomUser.has_tokens) { return 'Light Blue'; } else { return 'Grey'; } }); this.totalUsers = []; this.currentUsers = []; // this.mods = []; // this.fans = []; _PubSub.pubSub.subscribe('botStart', this.createUserOnStart); _PubSub.pubSub.subscribe('userEnter', this.userEnter); _PubSub.pubSub.subscribe('newMsg', this.updateUserOnMsg); _PubSub.pubSub.subscribe('newTip', this.updateUserOnTip); _PubSub.pubSub.subscribe('userLeave', this.updateUserOnLeave); }; var userData = new UserData(); /** * Class for Users in this plugin */ exports.userData = userData; var RoomUser = /*#__PURE__*/function (_User) { _inherits(RoomUser, _User); var _super = _createSuper(RoomUser); function RoomUser(user) { var _this2; var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; _classCallCheck(this, RoomUser); _this2 = _super.call(this, user, options); _defineProperty(_assertThisInitialized(_this2), "setColor", function (color) { _this2.color = color; return _assertThisInitialized(_this2); }); _defineProperty(_assertThisInitialized(_this2), "updateTips", function (cbTip) { var amount = parseInt(cbTip.amount); if (_this2.total_tips == null) { _this2.total_tips = amount; } else { _this2.total_tips += amount; } if (_this2.highest_tip == null) { _this2.highest_tip = amount; } else { if (amount > _this2.highest_tip) { _this2.highest_tip = amount; } } return _assertThisInitialized(_this2); }); _this2.color = options.color; _this2.total_tips = null; _this2.highest_tip = null; //this.numAnonTips //this.timeInRoom //this.timeEnterRoom //this.timeLeaveRoom return _this2; } return RoomUser; }(_User2.User); },{"../core/PubSub":2,"../core/User":3}]},{},[4]);
© Copyright Chaturbate 2011- 2024. All Rights Reserved.