Bots Home
|
Create an App
LanasRoom
Author:
entomy
Description
Source Code
Launch Bot
Current Users
Created by:
Entomy
var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); } return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var discount; (function (discount) { "use strict"; discount.fanclub = 1.0; discount.moderator = 1.0; function apply(item, user) { var in_fanclub = user.hasOwnProperty("from_user_in_fanclub") ? user.from_user_in_fanclub : user.in_fanclub; var is_mod = user.hasOwnProperty("from_user_is_mod") ? user.from_user_is_mod : user.is_mod; if (!in_fanclub && !is_mod) return item.cost; if (discount.fanclub <= discount.moderator) { if (in_fanclub) return Math.floor(item.cost * discount.fanclub); else if (is_mod) return Math.floor(item.cost * discount.moderator); } else if (discount.moderator <= discount.fanclub) { if (is_mod) return Math.floor(item.cost * discount.moderator); else if (in_fanclub) return Math.floor(item.cost * discount.fanclub); } return item.cost; } discount.apply = apply; })(discount || (discount = {})); var emblems; (function (emblems) { "use strict"; emblems.arrow = " :arrow16 "; emblems.ballot = " :ballot16 "; emblems.bb8 = " :miniBB-8 "; emblems.blank = " :blank16 "; emblems.bronzemedal = " :bronzemedal16c "; emblems.coppermedal = " :coppermedal16 "; emblems.crown = " :crown16 "; emblems.gavel = " :gavel16 "; emblems.goldmedal = " :goldmedal16 "; emblems.hitachi = " :hitachi16 "; emblems.notice = " :notice16 "; emblems.silvermedal = " :silvermedal16 "; emblems.song = " :song16 "; emblems.timer = " :timer16 "; emblems.tinmedal = " :tinmedal16 "; emblems.tipmenu = " :tipmenu16 "; emblems.token = " :token12 "; emblems.trusted = " :trusted16 "; emblems.whisper = " :whisper16 "; emblems.whispermod = " :whispermod16 "; })(emblems || (emblems = {})); var hightip; (function (hightip) { "use strict"; var slot; function compare(tip) { if (slot == null || tip.amount > slot.tipped) { slot = new tipper(tip.from_user, tip.amount); } } hightip.compare = compare; function help(message) { notice.add("/hightip --Get the highest single tipper"); notice.post(message.user); } hightip.help = help; function load(state) { var tipped = state.split(" ")[0]; var name = state.split(" ")[1]; slot = new tipper(name, Number(tipped)); } hightip.load = load; function name() { return slot == null ? null : slot.name; } hightip.name = name; function tipped() { return slot == null ? null : slot.tipped; } hightip.tipped = tipped; function tryParse(message) { var m = message.m.split(" "); if (m.length === 0) return false; var command = m.shift().toLowerCase(); switch (command) { case "/hightip": notice.send(slot.tipped + " " + slot.name, message.user); return true; default: return false; } } hightip.tryParse = tryParse; })(hightip || (hightip = {})); var leaderboard; (function (leaderboard) { "use strict"; leaderboard.lapse = 10; leaderboard.size = 5; function help(message) { notice.add("/leaderboard --Print the leaderboard"); notice.post(message.user); message['X-Spam'] = true; } leaderboard.help = help; function isPos(pos, tipper) { return tippers.top(pos)[pos - 1] === tipper; } leaderboard.isPos = isPos; function print(slots, sendTo) { if (slots === void 0) { slots = leaderboard.size; } if (sendTo === void 0) { sendTo = ""; } var top = tippers.top(slots); if (top != null && top.length != 0) notice.add("===== Leaderboard ====="); if (top[0] != null && top[0].tipped != 0) notice.add(emblems.goldmedal + top[0].name + " " + top[0].tipped); if (top[1] != null && top[1].tipped != 0) notice.add(emblems.silvermedal + top[1].name + " " + top[1].tipped); if (top[2] != null && top[2].tipped != 0) notice.add(emblems.bronzemedal + top[2].name + " " + top[2].tipped); if (top[3] != null && top[3].tipped != 0) notice.add(emblems.tinmedal + top[3].name + " " + top[3].tipped); if (top[4] != null && top[4].tipped != 0) notice.add(emblems.coppermedal + top[4].name + " " + top[4].tipped); notice.post(sendTo); } function rotate(slots) { if (slots === void 0) { slots = leaderboard.size; } print(slots); cb.setTimeout(rotate, leaderboard.lapse * 60 * 1000); } leaderboard.rotate = rotate; function tryParse(message) { var m = message.m.split(" "); if (m.length === 0) return false; var command = m.shift().toLowerCase(); switch (command) { case "/leaderboard": print(leaderboard.size, message.user); return true; default: return false; } } leaderboard.tryParse = tryParse; })(leaderboard || (leaderboard = {})); var menuitem = (function () { function menuitem(name, cost, handler) { var params = []; for (var _i = 3; _i < arguments.length; _i++) { params[_i - 3] = arguments[_i]; } this.name = name; this.cost = cost; this.handler = handler; this.params = params; } menuitem.prototype.handle = function (tip, params) { if (params === void 0) { params = this.params; } if (this.handler != null) { this.handler(tip, params); } }; return menuitem; }()); var menusection = (function () { function menusection(name) { var items = []; for (var _i = 1; _i < arguments.length; _i++) { items[_i - 1] = arguments[_i]; } this.items = []; this.name = name; this.items = items; } menusection.prototype.add = function (name, cost, handler) { var params = []; for (var _i = 3; _i < arguments.length; _i++) { params[_i - 3] = arguments[_i]; } this.items[this.items.length] = new menuitem(name, cost, handler, params); }; menusection.prototype.clear = function () { this.items = []; }; menusection.prototype.del = function (name) { this.items = cbjs.arrayRemove(this.items, this.lookup(name)); }; menusection.prototype.list = function () { return this.items; }; menusection.prototype.lookup = function (name) { for (var _i = 0, _a = this.items; _i < _a.length; _i++) { var item = _a[_i]; if (item.name.toLowerCase() === name.toLowerCase()) { return item; } } return null; }; menusection.prototype.match = function (tip) { var price; for (var _i = 0, _a = this.items; _i < _a.length; _i++) { var item = _a[_i]; if (tip.amount === price) { return item; } } return null; }; menusection.prototype.print = function (user, limit, discountMethod) { if (discountMethod === void 0) { discountMethod = null; } notice.add("===== " + this.name + " ====="); var price; for (var _i = 0, _a = this.items; _i < _a.length; _i++) { var item = _a[_i]; price = discountMethod != null ? discountMethod(item, user) : item.cost; if (limit != null && price >= limit) continue; notice.add(price + emblems.token + item.name); } notice.apply(emblems.tipmenu); notice.post(user.user); }; return menusection; }()); var notice; (function (notice_1) { "use strict"; notice_1.color = "#000000"; var buffer = []; function add(notice) { buffer[buffer.length] = notice; } notice_1.add = add; function adds() { var notices = []; for (var _i = 0; _i < arguments.length; _i++) { notices[_i] = arguments[_i]; } for (var _a = 0, notices_1 = notices; _a < notices_1.length; _a++) { var notice_2 = notices_1[_a]; add(notice_2); } } notice_1.adds = adds; function apply(emblem) { for (var _i = 0, buffer_1 = buffer; _i < buffer_1.length; _i++) { var notice_3 = buffer_1[_i]; notice_3 = emblem + notice_3; } } notice_1.apply = apply; function clear() { buffer = []; } notice_1.clear = clear; function help(message) { if (permissions.isAtLeastModerator(message)) { add("/note,notice <Message> --Send a notice to chat"); post(message.user); } } notice_1.help = help; function post(to, textcolor, weight, autoclear) { if (to === void 0) { to = ""; } if (textcolor === void 0) { textcolor = notice_1.color; } if (weight === void 0) { weight = "bold"; } if (autoclear === void 0) { autoclear = true; } var message = buffer.join("\n"); cb.sendNotice(message, to, "#FFFFFF", textcolor, weight); if (autoclear) clear(); } notice_1.post = post; function postGroup(to, textcolor, weight, autoclear) { if (textcolor === void 0) { textcolor = notice_1.color; } if (weight === void 0) { weight = "bold"; } if (autoclear === void 0) { autoclear = true; } var message = buffer.join("\n"); cb.sendNotice(message, "", "#FFFFFF", textcolor, weight, to); if (autoclear) clear(); } notice_1.postGroup = postGroup; function send(message, to, textcolor, weight) { if (to === void 0) { to = ""; } if (textcolor === void 0) { textcolor = notice_1.color; } if (weight === void 0) { weight = "bold"; } cb.sendNotice(message, to, "#FFFFFF", textcolor, weight); } notice_1.send = send; function sendGroup(message, to, textcolor, weight) { if (textcolor === void 0) { textcolor = notice_1.color; } if (weight === void 0) { weight = "bold"; } cb.sendNotice(message, "", "#FFFFFF", textcolor, weight, to); } notice_1.sendGroup = sendGroup; function tryParse(message) { if (permissions.isAtLeastModerator(message)) { var m = message.m.split(" "); if (m.length === 0) return false; var command = m.shift().toLowerCase(); switch (command) { case "/note": case "/notice": send(emblems.notice + m.join(" ")); return true; default: return false; } } return false; } notice_1.tryParse = tryParse; })(notice || (notice = {})); var permissions; (function (permissions) { "use strict"; var trusted = []; function entrust() { var users = []; for (var _i = 0; _i < arguments.length; _i++) { users[_i] = arguments[_i]; } for (var _a = 0, users_1 = users; _a < users_1.length; _a++) { var user_1 = users_1[_a]; trusted[trusted.length] = user_1; } } permissions.entrust = entrust; function detrust() { var users = []; for (var _i = 0; _i < arguments.length; _i++) { users[_i] = arguments[_i]; } for (var _a = 0, users_2 = users; _a < users_2.length; _a++) { var user_2 = users_2[_a]; trusted = cbjs.arrayRemove(trusted, user_2); } } permissions.detrust = detrust; function isBroadcaster(user) { return user.user === cb.room_slug; } permissions.isBroadcaster = isBroadcaster; function isTrusted(user) { return cbjs.arrayContains(trusted, user.user); } permissions.isTrusted = isTrusted; function isAtLeastTrusted(user) { return isBroadcaster(user) || isTrusted(user); } permissions.isAtLeastTrusted = isAtLeastTrusted; function isModerator(user) { return user.is_mod; } permissions.isModerator = isModerator; function isAtLeastModerator(user) { return isAtLeastTrusted(user) || isModerator(user); } permissions.isAtLeastModerator = isAtLeastModerator; function isInFanclub(user) { return user.in_fanclub; } permissions.isInFanclub = isInFanclub; function isAtLeastInFanclub(user) { return isAtLeastModerator(user) || isInFanclub(user); } permissions.isAtLeastInFanclub = isAtLeastInFanclub; function hasTippedTons(user) { return user.tipped_tons_recently; } permissions.hasTippedTons = hasTippedTons; function hasAtLeastTippedTons(user) { return isAtLeastInFanclub(user) || hasTippedTons(user); } permissions.hasAtLeastTippedTons = hasAtLeastTippedTons; function hasTippedAlot(user) { return user.tipped_alot_recently; } permissions.hasTippedAlot = hasTippedAlot; function hasAtLeastTippedAlot(user) { return hasAtLeastTippedTons(user) || hasTippedAlot(user); } permissions.hasAtLeastTippedAlot = hasAtLeastTippedAlot; function hasTipped(user) { return user.tipped_recently; } permissions.hasTipped = hasTipped; function hasAtLeastTipped(user) { return hasAtLeastTippedAlot(user) || hasTipped(user); } permissions.hasAtLeastTipped = hasAtLeastTipped; function hasTokens(user) { return user.has_tokens; } permissions.hasTokens = hasTokens; function hasAtLeastTokens(user) { return hasAtLeastTipped(user) || hasTokens(user); } permissions.hasAtLeastTokens = hasAtLeastTokens; function help(message) { if (permissions.isAtLeastTrusted(message)) { notice.add("/trust,trusted"); } if (permissions.isBroadcaster(message)) { notice.add(emblems.blank + "add <User>+ --Entrust the users"); notice.add(emblems.blank + "del,delete,rem,remove <User>+ --Detrust the users"); } if (permissions.isAtLeastTrusted(message)) { notice.add(emblems.blank + "list --List all trusted users"); notice.post(message.user); } } permissions.help = help; function tryParse(message) { if (permissions.isBroadcaster(message)) { var m = message.m.split(" "); if (m.length === 0) return false; var command = m.shift().toLowerCase(); switch (command) { case "/detrust": for (var _i = 0, m_1 = m; _i < m_1.length; _i++) { var user_3 = m_1[_i]; detrust(user_3); } return true; case "/entrust": for (var _a = 0, m_2 = m; _a < m_2.length; _a++) { var user_4 = m_2[_a]; entrust(user_4); } return true; case "/trust": case "/trusted": if (m.length === 0) return false; var operation = m.shift().toLowerCase(); switch (operation) { case "add": for (var _b = 0, m_3 = m; _b < m_3.length; _b++) { var user_5 = m_3[_b]; entrust(user_5); } return true; case "del": case "delete": case "rem": case "remove": for (var _c = 0, m_4 = m; _c < m_4.length; _c++) { var user_6 = m_4[_c]; detrust(user_6); } return true; case "help": help(message); return true; case "list": notice.send(trusted.join(", "), message.user); return true; default: return false; } } } return false; } permissions.tryParse = tryParse; })(permissions || (permissions = {})); var rotater; (function (rotater) { "use strict"; rotater.lapse = 3; var pool = []; var n = 0; function add(message) { pool[pool.length] = message; notice.send(emblems.notice + "'" + message + "' has been added to rotation"); } rotater.add = add; function del(message) { if (typeof message === "string") { pool = cbjs.arrayRemove(pool, message); notice.send(emblems.notice + "'" + message + "' has been removed from rotation"); } else if (typeof message === "number") { notice.send(emblems.notice + "'" + pool[message - 1] + "' has been removed from rotation"); pool = cbjs.arrayRemove(pool, pool[message - 1]); } } rotater.del = del; function help(message) { notice.add("/rotater,rotating,rotation"); if (permissions.isAtLeastModerator(message)) { notice.add(emblems.blank + "add <Message> --Add the notice to rotation"); } if (permissions.isAtLeastTrusted(message)) { notice.add(emblems.blank + "del,delete (<Message> | <Position>) --Delete the notice from rotation"); } notice.add(emblems.blank + "list,print --List all notices in rotation"); notice.post(message.user); notice.clear(); } rotater.help = help; function list() { return pool; } rotater.list = list; function print(user) { var i = 0; for (var _i = 0, pool_1 = pool; _i < pool_1.length; _i++) { var note = pool_1[_i]; notice.add(++i + ") " + note); } notice.post(user.user); notice.clear(); } rotater.print = print; function rotate() { notice.send(emblems.notice + pool[n++]); n %= pool.length; cb.setTimeout(rotate, rotater.lapse * 60 * 1000); } function start() { cb.setTimeout(rotate, rotater.lapse * 60 * 1000); } rotater.start = start; function tryParse(message) { var m = message.m.split(" "); if (m.length === 0) return false; var command = m.shift().toLowerCase(); switch (command) { case "/rotater": case "/rotating": case "/rotation": break; default: return false; } if (m.length === 0) return false; var operation = m.shift().toLowerCase(); switch (operation) { case "add": if (permissions.isAtLeastModerator(message)) { rotater.add(m.join(" ")); return true; } return false; case "del": case "delete": if (permissions.isAtLeastTrusted(message)) { var pos = m.shift(); if (isNaN(Number(pos))) { m.unshift(pos); rotater.del(m.join(" ")); } else { rotater.del(Number(pos)); } return true; } return false; case "help": help(message); return true; case "list": case "print": print(message); return true; default: return false; } } rotater.tryParse = tryParse; })(rotater || (rotater = {})); var tipmenu; (function (tipmenu) { "use strict"; tipmenu.specials = new menusection("Specials"); var special; (function (special) { function help(message) { if (permissions.isAtLeastTrusted(message)) { notice.add("/special,specials"); notice.add(emblems.blank + "add <Cost> <Name> --Add the special to the menu"); notice.add(emblems.blank + "clr,clear --Clear all specials"); notice.add(emblems.blank + "del,delete <Name> --Delete the special from the menu"); notice.post(message.user); } } special.help = help; function tryParse(message) { if (!permissions.isAtLeastTrusted(message)) return false; var m = message.m.split(" "); if (m.length === 0) return false; var command = m.shift().toLowerCase(); switch (command) { case "/special": case "/specials": break; default: return false; } if (m.length === 0) return false; var operation = m.shift().toLowerCase(); var name; switch (operation) { case "add": var cost = m.shift(); if (isNaN(Number(cost))) { m.unshift(cost); cost = m.pop(); if (isNaN(Number(cost))) return false; } name = m.join(" "); tipmenu.specials.add(name, Number(cost)); notice.send(emblems.tipmenu + "'" + name + "' added as a special for " + cost + emblems.token); return true; case "clr": case "clear": tipmenu.specials.clear(); notice.send(emblems.tipmenu + "All specials have been removed"); return true; case "del": case "delete": name = m.join(" "); tipmenu.specials.del(name); notice.send(emblems.tipmenu + "'" + name + "' has been removed from the specials"); return true; case "help": help(message); return true; default: return false; } } special.tryParse = tryParse; })(special = tipmenu.special || (tipmenu.special = {})); })(tipmenu || (tipmenu = {})); var stats; (function (stats) { "use strict"; function meanHalves(sendTo) { notice.add("Upper Mean: " + tippers.meanUpper()); notice.add("Lower Mean: " + tippers.meanLower()); notice.post(sendTo); } stats.meanHalves = meanHalves; function medianTip(sendTo) { notice.add("Median Tip: " + tippers.median()); notice.post(sendTo); } stats.medianTip = medianTip; function showDuration(sendTo) { var duration = timers.showDuration(); notice.add("Show Duration: " + duration[0] + ":" + duration[1] + ":" + duration[2]); notice.post(sendTo); } stats.showDuration = showDuration; function tippersTotal(sendTo) { notice.add("Tippers Total: " + tippers.count); notice.post(sendTo); } stats.tippersTotal = tippersTotal; function tokensPerHour(sendTo) { var duration = timers.showDuration(); var minutes = duration[0] * 60 + duration[1]; var rate = (tippers.tipped() / minutes) * 60; notice.add("Tokens Per Hour: " + rate); notice.post(sendTo); } stats.tokensPerHour = tokensPerHour; function tokensPerTipper(sendTo) { notice.add("Tokens Per Tipper: " + tippers.tipped() / tippers.count()); notice.post(sendTo); } stats.tokensPerTipper = tokensPerTipper; function tokensTotal(sendTo) { notice.add("Tokens Total: " + tippers.tipped()); notice.post(sendTo); } stats.tokensTotal = tokensTotal; })(stats || (stats = {})); var tallier; (function (tallier) { "use strict"; var tallies = []; function add(item, amount) { if (amount === void 0) { amount = 1; } var tally = lookup(item); if (tally == null) { tallies[tallies.length] = [item, amount]; } else { tally[1] += amount; } } tallier.add = add; function clear() { tallies = []; } tallier.clear = clear; function highest() { if (tallies == null || tallies === []) return null; var high = [null, 0]; for (var _i = 0, tallies_1 = tallies; _i < tallies_1.length; _i++) { var tally = tallies_1[_i]; if (tally[1] > high[1]) high = tally; } return high; } tallier.highest = highest; function lookup(item) { for (var _i = 0, tallies_2 = tallies; _i < tallies_2.length; _i++) { var tally = tallies_2[_i]; if (tally[0] === item) return tally; } return null; } tallier.lookup = lookup; })(tallier || (tallier = {})); var teamate = (function () { function teamate(tipper, points) { if (points === void 0) { points = 0; } this.tipper = tipper; this.points = points; } teamate.prototype.name = function () { return this.tipper.name; }; teamate.prototype.tipped = function () { return this.tipper.tipped; }; return teamate; }()); var team = (function () { function team(name, emblem, discount) { if (discount === void 0) { discount = 0; } this.members = []; this.name = ""; this.emblem = ""; this.discount = 0; this.name = name; this.emblem = emblem; this.discount = discount; } team.prototype.add = function (user, points) { if (points === void 0) { points = 0; } var member = this.lookup(user); if (member !== null) return; var tipper = tippers.lookup(user); if (tipper === null) { tippers.dummy(user); tipper = tippers.lookup(user); } this.members[this.members.length] = new teamate(tipper, points); }; team.prototype.adds = function () { var users = []; for (var _i = 0; _i < arguments.length; _i++) { users[_i] = arguments[_i]; } if (typeof users[0] === "string") { for (var _a = 0, _b = users; _a < _b.length; _a++) { var user_7 = _b[_a]; this.add(user_7); } } else { for (var _c = 0, _d = users; _c < _d.length; _c++) { var user_8 = _d[_c]; this.add(user_8[0], user_8[1]); } } }; team.prototype.applyEmblem = function (message) { if (this.isMember(message)) { return this.emblem + message.m; } else { return message.m; } }; team.prototype.applyDiscount = function (item, user) { if (!this.isMember(user)) { return item.cost; } else { return Math.floor(item.cost * (1 - this.discount)); } }; team.prototype.del = function (user) { cbjs.arrayRemove(this.members, this.lookup(user)); }; team.prototype.dels = function (users) { for (var _i = 0, users_3 = users; _i < users_3.length; _i++) { var user_9 = users_3[_i]; cbjs.arrayRemove(this.members, this.lookup(user_9)); } }; team.prototype.isMember = function (user) { var name; if (typeof user == "string") { name = user; } else { name = user.hasOwnProperty("from_user") ? user.from_user : user.user; } for (var _i = 0, _a = this.members; _i < _a.length; _i++) { var member = _a[_i]; if (member.name() == name) return true; } return false; }; team.prototype.length = function () { return this.members.length; }; team.prototype.list = function (withPoints) { if (withPoints === void 0) { withPoints = false; } this.sort(); var result = []; if (withPoints) { var points = void 0; for (var _i = 0, _a = this.members; _i < _a.length; _i++) { var member = _a[_i]; points = member.points + member.tipped(); result[result.length] = "[" + points + "] " + member.name(); } } else { for (var _b = 0, _c = this.members; _b < _c.length; _b++) { var member = _c[_b]; result[result.length] = member.name(); } } return result; }; team.prototype.load = function (state) { var users = state.trim().split(","); var name; var points; for (var _i = 0, users_4 = users; _i < users_4.length; _i++) { var user_10 = users_4[_i]; name = user_10.trim().split(" ")[0]; points = Number(user_10.trim().split(" ")[1]); this.add(name, points); } }; team.prototype.lookup = function (name) { for (var _i = 0, _a = this.members; _i < _a.length; _i++) { var member = _a[_i]; if (member.name() == name) { return member; } } return null; }; team.prototype.save = function () { this.sort(); var state = ""; for (var _i = 0, _a = this.members; _i < _a.length; _i++) { var member = _a[_i]; state += member.name() + " " + (member.points + member.tipped()) + ", "; } state = state.substring(0, state.length - 2); return state; }; team.prototype.sort = function () { this.members = this.members.sort(function (a, b) { return (b.points + b.tipped()) - (a.points + a.tipped()); }); }; team.prototype.points = function () { var result; for (var _i = 0, _a = this.members; _i < _a.length; _i++) { var member = _a[_i]; result += member.points; } return result; }; return team; }()); var fanteam = (function (_super) { __extends(fanteam, _super); function fanteam() { return _super !== null && _super.apply(this, arguments) || this; } fanteam.prototype.isMember = function (user) { return user.hasOwnProperty("from_user") ? user.from_user_in_fanclub : user.in_fanclub; }; return fanteam; }(team)); var modteam = (function (_super) { __extends(modteam, _super); function modteam() { return _super !== null && _super.apply(this, arguments) || this; } modteam.prototype.isMember = function (user) { return user.hasOwnProperty("from_user") ? user.from_user_is_mod : user.is_mod; }; return modteam; }(team)); var teams; (function (teams) { var pool = []; function addTeam(team) { pool[pool.length] = team; } teams.addTeam = addTeam; function addToTeam(user, teamName) { var name; if (typeof user === "string") { name = user; } else { name = user.hasOwnProperty("from_user") ? user.from_user : user.user; } var team = lookup(teamName); if (team == null) return; if (!team.isMember(user)) team.add(name); } teams.addToTeam = addToTeam; function applyDiscount(item, user) { cb.log("applyDiscount()"); var result = Number.MAX_VALUE; var discount = Number.MAX_VALUE; for (var _i = 0, pool_2 = pool; _i < pool_2.length; _i++) { var team = pool_2[_i]; discount = team.applyDiscount(item, user); cb.log("discount: " + discount); if (discount < result) { result = discount; cb.log("result: " + result); } } return result; } teams.applyDiscount = applyDiscount; function applyEmblem(message) { var team = memberOf(message); if (team !== null) { return team.applyEmblem(message); } else { return message.m; } } teams.applyEmblem = applyEmblem; function help(message) { if (permissions.isAtLeastModerator(message)) { notice.add("/team list --List the teams"); if (permissions.isAtLeastTrusted(message)) { notice.add("/team <Team> add <Users>+ --Add the specified users to the team"); notice.add("/team <Team> del,delete,rem,remove <Users>+ --Remove the specified users from the team"); } notice.add("/team <Team> list --List the members of the specifed team"); } notice.post(message.user); } teams.help = help; function isMember(user) { for (var _i = 0, pool_3 = pool; _i < pool_3.length; _i++) { var team = pool_3[_i]; if (team.isMember(user)) return true; } return false; } teams.isMember = isMember; function isMemberOf(user, teamName) { var team = lookup(teamName); if (team == null) return false; return team.isMember(user); } teams.isMemberOf = isMemberOf; function lookup(teamName) { for (var _i = 0, pool_4 = pool; _i < pool_4.length; _i++) { var team = pool_4[_i]; if (team.name == teamName) return team; } return null; } teams.lookup = lookup; function memberOf(user) { for (var _i = 0, pool_5 = pool; _i < pool_5.length; _i++) { var team = pool_5[_i]; if (team.isMember(user)) return team; } return null; } teams.memberOf = memberOf; function tryParse(message) { var m = message.m.split(" "); if (m.length === 0) return false; var command = m.shift().toLowerCase(); switch (command) { case "/team": case "/teams": break; default: return false; } if (m.length === 0) return false; var operation = m.shift().toLowerCase(); switch (operation) { case "help": help(message); return true; case "list": for (var _i = 0, pool_6 = pool; _i < pool_6.length; _i++) { var p = pool_6[_i]; notice.send(p.name, message.user); } return true; default: m.push(operation); break; } var teamName = m.shift().toLowerCase(); var team = lookup(teamName); if (team == null) { notice.send("The given team '" + teamName + "' does not seem to exist", message.user); return false; } if (m.length === 0) return false; operation = m.shift().toLowerCase(); switch (operation) { case "add": for (var _a = 0, m_5 = m; _a < m_5.length; _a++) { var user = m_5[_a]; team.adds(user); } return true; case "del": case "delete": case "rem": case "remove": for (var _b = 0, m_6 = m; _b < m_6.length; _b++) { var user = m_6[_b]; team.del(user); } case "list": case "print": for (var _c = 0, _d = team.list(); _c < _d.length; _c++) { var teamate = _d[_c]; notice.send(teamate, message.user); } return true; default: return false; } } teams.tryParse = tryParse; })(teams || (teams = {})); var timer = (function () { function timer(name, duration, delay, onStart, onStop) { if (delay === void 0) { delay = 0; } this.name = name; this.duration = duration; this.remaining = duration; this.delay = delay; this.onStart = onStart; this.onStop = onStop; } timer.prototype.extend = function (seconds) { this.duration += seconds; this.remaining += seconds; notice.send(emblems.timer + "'" + this.name + "' extended with " + seconds + "sec"); }; timer.prototype.isActive = function () { return this.delay > 0 || this.remaining > 0; }; timer.prototype.isDelayed = function () { return this.delay > 0; }; timer.prototype.isRunning = function () { return this.remaining < this.duration && this.remaining > 0; }; timer.prototype.tick = function () { if (this.delay === 0 && this.remaining === this.duration) { notice.send(emblems.timer + "'" + this.name + "' started with " + this.duration / 60 + "min"); if (this.onStart != null) this.onStart(); } else if (this.delay === 0 && this.remaining === 0) { notice.send(emblems.timer + "'" + this.name + "' has expired"); if (this.onStop != null) this.onStop(); } else if (this.delay === 0 && this.remaining % 60 === 0) { notice.send(emblems.timer + "'" + this.name + "' has " + this.remaining / 60 + "min remaining"); } if (this.delay > 0) { this.delay--; } else if (this.remaining > 0) { this.remaining--; } }; return timer; }()); var timers; (function (timers) { "use strict"; var pool = []; var showtime = 0; function add(name, duration, delay, onStart, onStop) { if (delay === void 0) { delay = 0; } pool[pool.length] = new timer(name, duration, delay, onStart, onStop); if (delay > 0) { notice.send(emblems.timer + "'" + name + "' will start in " + delay + "s"); } } timers.add = add; function clear() { pool = []; } timers.clear = clear; function del(timer) { if (typeof timer === "number") { notice.send(emblems.timer + "'" + pool[timer].name + "' has been removed"); pool = cbjs.arrayRemove(pool, pool[timer]); } else if (typeof timer === "string") { if (cbjs.arrayContains(pool, lookup(timer))) { notice.send(emblems.timer + "'" + timer + "' has been removed"); pool = cbjs.arrayRemove(pool, lookup(timer)); } } } timers.del = del; function extend(name, duration) { var timer = lookup(name); if (timer != null) { timer.extend(duration); } } timers.extend = extend; function help(message) { if (permissions.isAtLeastModerator(message)) { notice.add("/timer,timers"); notice.add(emblems.blank + "add,start <Duration> <Name> --Add and start the timer"); } if (permissions.isAtLeastTrusted(message)) { notice.add(emblems.blank + "clr,clear --Clear and stop all timers"); notice.add(emblems.blank + "del,delete (<Name> | <Position>) --Delete the timer without any stop events"); notice.add(emblems.blank + "ext,extend <Duration> <Name> --Extend the timer"); } notice.add(emblems.blank + "list,print --List all active timers"); if (permissions.isAtLeastTrusted(message)) { notice.add(emblems.blank + "stop (<Name | <Position>) --Stop the timer next tick"); } notice.post(message.user); } timers.help = help; function list() { return pool; } timers.list = list; function lookup(name) { for (var _i = 0, pool_7 = pool; _i < pool_7.length; _i++) { var timer_1 = pool_7[_i]; if (timer_1.name.toLowerCase() == name.toLowerCase()) { return timer_1; } } return null; } timers.lookup = lookup; function showDuration() { var hours = 0; var minutes = 0; var seconds = showtime; while (seconds >= 3600) { seconds -= 3600; hours += 1; } while (seconds >= 60) { seconds -= 60; minutes += 1; } return [hours, minutes, seconds]; } timers.showDuration = showDuration; function start() { cb.setTimeout(tick, 1000); } timers.start = start; function stop(timer) { if (typeof timer === "number") { if (pool[timer] != null) pool[timer].remaining = 0; } else if (typeof timer === "string") { var t = lookup(timer); if (t != null) { t.remaining = 0; } } } timers.stop = stop; function tick() { var keep = []; showtime += 1; for (var _i = 0, pool_8 = pool; _i < pool_8.length; _i++) { var timer_2 = pool_8[_i]; if (timer_2.isActive()) keep[keep.length] = timer_2; timer_2.tick(); } if (pool !== keep) { pool = keep; } cb.setTimeout(tick, 1000); } function tryParse(message) { var m = message.m.split(" "); if (m.length === 0) return false; var command = m.shift().toLowerCase(); switch (command) { case "/timer": case "/timers": break; default: return false; } if (m.length === 0) return false; var operation = m.shift().toLowerCase(); var name; var duration; var pos; switch (operation) { case "add": case "start": if (!permissions.isAtLeastModerator(message)) return false; duration = m.shift(); if (isNaN(Number(duration))) { m.unshift(duration); duration = m.pop(); if (isNaN(Number(duration))) return false; } name = m.join(" "); timers.add(name, Number(duration) * 60); return true; case "clr": case "clear": if (!permissions.isAtLeastTrusted(message)) return false; timers.clear(); return true; case "del": case "delete": if (!permissions.isAtLeastTrusted(message)) return false; pos = m.shift(); if (isNaN(Number(pos))) { m.unshift(pos); timers.del(m.join(" ")); } else { timers.del(Number(pos) - 1); } return true; case "ext": case "extend": if (!permissions.isAtLeastTrusted(message)) return false; duration = m.shift(); if (isNaN(Number(duration))) { m.unshift(duration); duration = m.pop(); if (isNaN(Number(duration))) return false; } name = m.join(" "); timers.extend(name, Number(duration) * 60); return true; case "help": help(message); return true; case "list": case "print": var i = 0; for (var _i = 0, pool_9 = pool; _i < pool_9.length; _i++) { var timer_3 = pool_9[_i]; notice.add(++i + ") '" + timer_3.name + "' with " + timer_3.remaining + "s"); } notice.apply(emblems.timer); notice.post(message.user); return true; case "stop": if (!permissions.isAtLeastTrusted(message)) return false; pos = m.shift(); if (isNaN(Number(pos))) { m.unshift(pos); timers.stop(m.join(" ")); } else { timers.stop(Number(pos) - 1); } return true; default: return false; } } timers.tryParse = tryParse; })(timers || (timers = {})); var tipper = (function () { function tipper(name, tipped) { this.name = name; this.tipped = tipped; } return tipper; }()); var tippers; (function (tippers) { "use strict"; var pool = []; function add(tip) { var candidate = lookup(tip.from_user); if (candidate == null) { pool[pool.length] = new tipper(tip.from_user, 0); candidate = pool[pool.length - 1]; } candidate.tipped += tip.amount; } tippers.add = add; function count() { return pool.length; } tippers.count = count; function dummy(name) { pool[pool.length] = new tipper(name, 0); } tippers.dummy = dummy; function lookup(user) { for (var _i = 0, pool_10 = pool; _i < pool_10.length; _i++) { var tipper_1 = pool_10[_i]; if (tipper_1.name === user) return tipper_1; } return null; } tippers.lookup = lookup; function meanLower() { sort(); var lower = pool.slice(0, pool.length); var total = 0; for (var _i = 0, lower_1 = lower; _i < lower_1.length; _i++) { var tipper_2 = lower_1[_i]; total += tipper_2.tipped; } return total / lower.length; } tippers.meanLower = meanLower; function meanUpper() { sort(); var upper = pool.slice(pool.length / 2, pool.length); var total = 0; for (var _i = 0, upper_1 = upper; _i < upper_1.length; _i++) { var tipper_3 = upper_1[_i]; total += tipper_3.tipped; } return total / upper.length; } tippers.meanUpper = meanUpper; function median() { sort(); if (pool[Math.floor(pool.length / 2)] == null) { return NaN; } else { return pool[Math.floor(pool.length / 2)].tipped; } } tippers.median = median; function sort() { pool = pool.sort(function (a, b) { return b.tipped - a.tipped; }); } tippers.sort = sort; function top(amount) { sort(); return pool.slice(0, amount); } tippers.top = top; function tipped() { var total = 0; for (var _i = 0, pool_11 = pool; _i < pool_11.length; _i++) { var tipper_4 = pool_11[_i]; total += tipper_4.tipped; } return total; } tippers.tipped = tipped; })(tippers || (tippers = {})); var viewers; (function (viewers) { "use strict"; viewers.current = 0; viewers.withTokens = 0; viewers.inFanclub = 0; viewers.claimMale = 0; viewers.claimFemale = 0; viewers.claimTrans = 0; viewers.claimCouple = 0; function enter(user) { viewers.current += 1; if (user.has_tokens) viewers.withTokens += 1; if (user.in_fanclub) viewers.inFanclub += 1; if (user.gender == "m") viewers.claimMale += 1; if (user.gender == "f") viewers.claimFemale += 1; if (user.gender == "s") viewers.claimTrans += 1; if (user.gender == "c") viewers.claimTrans += 1; } viewers.enter = enter; function leave(user) { viewers.current -= 1; if (user.has_tokens) viewers.withTokens -= 1; if (user.in_fanclub) viewers.inFanclub -= 1; if (user.gender == "m") viewers.claimMale -= 1; if (user.gender == "f") viewers.claimFemale -= 1; if (user.gender == "s") viewers.claimTrans -= 1; if (user.gender == "c") viewers.claimTrans -= 1; } viewers.leave = leave; })(viewers || (viewers = {})); cb.onEnter(function (user) { notice.adds("Welcome to my room!", "To see available commands, enter /roomhelp in chat", "Check out the tip menu with: /menu"); notice.apply(emblems.notice); notice.post(user.user); viewers.enter(user); }); cb.onLeave(function (user) { if (hightip.name() !== null && hightip.name() == user.user) { notice.send(emblems.notice + "King " + hightip.name() + " has left... Quick, steal the " + emblems.crown); } viewers.leave(user); }); cb.onMessage(function (message) { if (message.m.trim().charAt(0) === "/") message['X-Spam'] = true; var validCommand = false; if (!validCommand) validCommand = hightip.tryParse(message); if (!validCommand) validCommand = leaderboard.tryParse(message); if (!validCommand) validCommand = notice.tryParse(message); if (!validCommand) validCommand = permissions.tryParse(message); if (!validCommand) validCommand = room.tryParse(message); if (!validCommand) validCommand = rotater.tryParse(message); if (!validCommand) validCommand = tipmenu.special.tryParse(message); if (!validCommand) validCommand = stats.tryParse(message); if (!validCommand) validCommand = teams.tryParse(message); if (!validCommand) validCommand = timers.tryParse(message); if (!validCommand) validCommand = tipmenu.tryParse(message); if (message['X-Spam'] || validCommand) return message; if (tippers.lookup(message.user) !== null) { message.m = "[" + tippers.lookup(message.user).tipped + "] " + message.m; } return message; }); cb.onTip(function (tip) { tippers.add(tip); hightip.compare(tip); var match = tipmenu.match(tip); if (match != null) { notice.send(emblems.tipmenu + tip.from_user + " has tipped for " + match.name); match.handle(tip); } }); var room; (function (room) { function help(message) { notice.help(message); permissions.help(message); rotater.help(message); tipmenu.special.help(message); stats.help(message); timers.help(message); tipmenu.help(message); } function tryParse(message) { var m = message.m.split(" "); if (m.length === 0) return false; var command = m.shift().toLowerCase(); switch (command) { case "/room": if (m.length === 0) return false; command = m.shift().toLowerCase(); switch (command) { case "help": break; default: return false; } case "/roomhelp": help(message); return true; } return false; } room.tryParse = tryParse; })(room || (room = {})); var cb; (function (cb) { cb.settings_choices = [ { name: "rotater0", label: "Rotating Notice", type: "str", required: false, }, { name: "rotater1", label: "Rotating Notice", type: "str", required: false, }, { name: "rotater2", label: "Rotating Notice", type: "str", required: false, }, { name: "rotater3", label: "Rotating Notice", type: "str", required: false, }, { name: "rotater4", label: "Rotating Notice", type: "str", required: false, }, { name: "rotater5", label: "Rotating Notice", type: "str", required: false, }, { name: "rotater6", label: "Rotating Notice", type: "str", required: false, }, { name: "rotater7", label: "Rotating Notice", type: "str", required: false, }, ]; })(cb || (cb = {})); var stats; (function (stats) { "use strict"; function help(message) { if (permissions.isAtLeastTrusted(message)) { notice.add("/stats,statistics --Get all calculated stats"); notice.post(message.user); } } stats.help = help; function print(message) { stats.showDuration(message.user); stats.tokensTotal(message.user); stats.tippersTotal(message.user); stats.tokensPerHour(message.user); stats.tokensPerTipper(message.user); stats.meanHalves(message.user); stats.medianTip(message.user); } function tryParse(message) { if (permissions.isAtLeastTrusted(message)) { var m = message.m.split(" "); if (m.length === 0) return false; var command = m.shift().toLowerCase(); switch (command) { case "/stat": case "/stats": case "/statistic": case "/statistics": print(message); return true; default: return false; } } return false; } stats.tryParse = tryParse; })(stats || (stats = {})); var tipmenu; (function (tipmenu) { var menu = new menusection("Menu", new menuitem("Karma", 1), new menuitem("Fap Tax", 5), new menuitem("Titty Flash", 20), new menuitem("Pussy Flash", 25), new menuitem("Song Request", 45), new menuitem("10 Spanks", 50), new menuitem("Vibrator", 75), new menuitem("Dildo", 80), new menuitem("Blowjob", 100), new menuitem("Pussy Play", 130), new menuitem("Butt Plug Tail", 250), new menuitem("Cum Deny", 555), new menuitem("Cum Save", 666), new menuitem("Instant Cum", 1000), new menuitem("Honey Club", 1111)); function help(message) { notice.add("/tipmenu --Get the entire tipmenu"); notice.add(emblems.blank + "<Section>+ --Get only the specified sections"); notice.add(emblems.blank + "limit <Cost> --Get all items lesser or equal to the specified cost"); notice.post(message.user); } tipmenu.help = help; function match(tip) { var price; for (var _i = 0, _a = tipmenu.specials.list(); _i < _a.length; _i++) { var item = _a[_i]; price = item.cost; if (tip.amount === price) return item; } for (var _b = 0, _c = menu.list(); _b < _c.length; _b++) { var item = _c[_b]; price = discount.apply(item, tip); if (tip.amount === price) return item; } return null; } tipmenu.match = match; function print(message) { tipmenu.specials.print(message, null); menu.print(message, null); } tipmenu.print = print; function tryParse(message) { var m = message.m.split(" "); if (m.length === 0) return false; var command = m.shift().toLowerCase(); switch (command) { case "/menu": case "/tipmenu": print(message); return true; } return false; } tipmenu.tryParse = tryParse; })(tipmenu || (tipmenu = {})); { notice.color = "#FF709B"; teams.addTeam(new team("Honey Club", "", 0.75)); permissions.entrust(); timers.start(); if (cb.settings.rotater0 !== "") rotater.add(cb.settings.rotater0); if (cb.settings.rotater1 !== "") rotater.add(cb.settings.rotater1); if (cb.settings.rotater2 !== "") rotater.add(cb.settings.rotater2); if (cb.settings.rotater3 !== "") rotater.add(cb.settings.rotater3); if (cb.settings.rotater4 !== "") rotater.add(cb.settings.rotater4); if (cb.settings.rotater5 !== "") rotater.add(cb.settings.rotater5); if (cb.settings.rotater6 !== "") rotater.add(cb.settings.rotater6); if (cb.settings.rotater7 !== "") rotater.add(cb.settings.rotater7); rotater.start(); leaderboard.rotate(3); }
© Copyright Chaturbate 2011- 2024. All Rights Reserved.