Apps Home
|
Create an App
Studio 1900 Colors
Author:
anelise_fox
Description
Source Code
Launch App
Current Users
Created by:
Anelise_Fox
var _0xd8b0=['sender','text','snuff','unsnuff','_msg','X-Spam','preventDefault','words','setPrefix','STOP_SIGN','setFont','Arial\x20Narrow','setColor','rgb(199,\x2086,\x200)','rgb(255,\x20218,\x20217)','notice','prependers','push','isOwner','isMod','is_mod','delim','onMessage','finish','log','Error:\x20','message','isArray','map','callback','calledWithNoArgs','onlyMods','onlyOwner','_detailedHelp','help','helpStyle','#5416c3','#1d8a04','important','bold','normal','callFn','hasArgs','function','Could\x20not\x20call\x20command:\x20\x22','get','Command\x20\x22','set','Command\x20not\x20found:\x20\x22','/help\x20-\x20displays\x20available\x20commands','arg','reject','Command\x20not\x20found:\x20','_help','trim','callCommand','Command\x20failed:\x20\x22','assign','onTip','\x27s\x20room.','changeRoomSubject','floor','random','pow','%u26A0%uFE0F','%u2755','%u27F6','%u27F9','%uD83D%uDD25','%uD83C%uDF46','keys','length','users','tippers','room_slug','queryUser','query\x20is\x20too\x20short:\x20\x27','forEach','match','No\x20matching\x20user\x20found:\x20\x27','Multiple\x20users\x20found\x20matching\x20query:\x20','join','user','origin'];(function(_0x5102c3,_0xe49201){var _0x1877cc=function(_0x22699a){while(--_0x22699a){_0x5102c3['push'](_0x5102c3['shift']());}};_0x1877cc(++_0xe49201);}(_0xd8b0,0xe5));var _0x4a1c=function(_0x3b041b,_0x3c47c0){_0x3b041b=_0x3b041b-0x0;var _0x1497b0=_0xd8b0[_0x3b041b];return _0x1497b0;};const SESSION_SEED=Math[_0x4a1c('0x0')](Math[_0x4a1c('0x1')]()*Math[_0x4a1c('0x2')](0x2,0x14));const emoji={'EXCLAMATION':unescape(_0x4a1c('0x3')),'WHITE_EXCLAMATION':unescape(_0x4a1c('0x4')),'STOP_SIGN':unescape('%uD83D%uDED1'),'RIGHT_ARROW':unescape(_0x4a1c('0x5')),'RIGHT_DOUBLE_ARROW':unescape(_0x4a1c('0x6')),'RAINDROP':unescape('%uD83D%uDCA7'),'FLAME':unescape(_0x4a1c('0x7')),'EGGPLANT':unescape(_0x4a1c('0x8'))};const utils={'ObjectEntries':_0x52a3bc=>{const _0x5849ad=Object[_0x4a1c('0x9')](_0x52a3bc);let _0x20c76a=_0x5849ad[_0x4a1c('0xa')];const _0x5d8e5a=new Array(_0x20c76a);while(_0x20c76a--)_0x5d8e5a[_0x20c76a]=[_0x5849ad[_0x20c76a],_0x52a3bc[_0x5849ad[_0x20c76a]]];return _0x5d8e5a;},'hashStringToInt':function(_0x31646d){var _0xe6d826=0x1,_0x508342=0x0,_0x70c2de,_0x3998f7;if(_0x31646d){_0xe6d826=0x0;for(_0x70c2de=_0x31646d[_0x4a1c('0xa')]-0x1;_0x70c2de>=0x0;_0x70c2de--){_0x3998f7=_0x31646d['charCodeAt'](_0x70c2de);_0xe6d826=(_0xe6d826<<0x6&0xfffffff)+_0x3998f7+(_0x3998f7<<0xe);_0x508342=_0xe6d826&0xfe00000;_0xe6d826=_0x508342!==0x0?_0xe6d826^_0x508342>>0x15:_0xe6d826;}}return String(_0xe6d826);},'isStringOfInt':function(_0x59d84a){return''+parseInt(_0x59d84a)===_0x59d84a;},'noop':function(){}};const chat={'notice':(_0x2a35be,_0x576044)=>{if(typeof _0x576044!=='object'){_0x576044={'to':_0x576044};}let {to,color,background,fontWeight,group}=_0x576044;cb['sendNotice'](_0x2a35be,to,background,color,fontWeight,group);},'sessionSeed'(){return SESSION_SEED;},'utils':utils,'constants':{'emoji':emoji}};{chat[_0x4a1c('0xb')]={};chat[_0x4a1c('0xc')]={};chat[_0x4a1c('0xb')][cb[_0x4a1c('0xd')]]=!![];chat[_0x4a1c('0xe')]=_0x247e77=>{if(!_0x247e77){throw new Error('bad\x20user\x20query');}else if(_0x247e77[_0x4a1c('0xa')]<0x3){throw new Error(_0x4a1c('0xf')+_0x247e77+'\x27');}const _0x25934f=new RegExp('^'+_0x247e77,'i');const _0x31e10d=[];Object[_0x4a1c('0x9')](chat[_0x4a1c('0xb')])[_0x4a1c('0x10')](_0x2d09d8=>{if(_0x2d09d8[_0x4a1c('0x11')](_0x25934f)){_0x31e10d['push'](_0x2d09d8);}});if(_0x31e10d[_0x4a1c('0xa')]===0x0){throw new Error(_0x4a1c('0x12')+_0x247e77+'\x27');}else if(_0x31e10d[_0x4a1c('0xa')]>0x1){throw new Error(_0x4a1c('0x13')+_0x31e10d[_0x4a1c('0x14')]('\x20'));}return _0x31e10d[0x0];};}{class MsgContext{constructor(_0x5426e5){this['_msg']=_0x5426e5;this['sender']=_0x5426e5[_0x4a1c('0x15')];this[_0x4a1c('0x16')]=this[_0x4a1c('0x17')];this['prependers']=[];this[_0x4a1c('0x18')]=_0x5426e5['m']||'';}[_0x4a1c('0x19')](){return this['preventDefault']();}[_0x4a1c('0x1a')](){this[_0x4a1c('0x1b')][_0x4a1c('0x1c')]=![];return this;}[_0x4a1c('0x1d')](){this[_0x4a1c('0x1b')]['X-Spam']=!![];return this;}[_0x4a1c('0x1e')](){return this['text']['split'](/\s+/g);}['reject'](_0x19ae88){this['preventDefault']();if(_0x19ae88){this[_0x4a1c('0x1f')](emoji[_0x4a1c('0x20')]+'\x20');this[_0x4a1c('0x21')](_0x4a1c('0x22'));this[_0x4a1c('0x23')](_0x4a1c('0x24'),_0x4a1c('0x25'));chat[_0x4a1c('0x26')](emoji[_0x4a1c('0x20')]+'\x20'+_0x19ae88,this[_0x4a1c('0x16')]);}return this;}[_0x4a1c('0x1f')](_0x57f271){this[_0x4a1c('0x27')][_0x4a1c('0x28')](_0x57f271);}[_0x4a1c('0x29')](){return this[_0x4a1c('0x16')]===cb['room_slug'];}[_0x4a1c('0x21')](_0x22f6b6){this[_0x4a1c('0x1b')]['f']=_0x22f6b6;}[_0x4a1c('0x23')](_0x45ee8d,_0x3c3cb5){if(_0x45ee8d){this['_msg']['c']=_0x45ee8d;}if(_0x3c3cb5){this[_0x4a1c('0x1b')]['background']=_0x3c3cb5;}return this;}[_0x4a1c('0x2a')](){return this[_0x4a1c('0x29')]()||this[_0x4a1c('0x1b')][_0x4a1c('0x2b')];}['finish'](){let _0x3d28fb='';if(this[_0x4a1c('0x27')][_0x4a1c('0xa')]>0x0){_0x3d28fb=this[_0x4a1c('0x27')][_0x4a1c('0x14')]('');this[_0x4a1c('0x1b')]['m']=''+_0x3d28fb+(this[_0x4a1c('0x2c')]||'')+this[_0x4a1c('0x18')];}else{this[_0x4a1c('0x1b')]['m']=this[_0x4a1c('0x18')];}}}const onMessageCallbacks=[];cb[_0x4a1c('0x2d')](_0x4eb7c4=>{if(!chat['users'][_0x4eb7c4[_0x4a1c('0x15')]]){chat[_0x4a1c('0xb')][_0x4eb7c4['user']]=!![];}try{var _0x30fadd=new MsgContext(_0x4eb7c4);for(var _0x2f0110=0x0;_0x2f0110<onMessageCallbacks[_0x4a1c('0xa')];_0x2f0110++){onMessageCallbacks[_0x2f0110](_0x30fadd);}return _0x30fadd[_0x4a1c('0x2e')]();}catch(_0x30d4f8){cb[_0x4a1c('0x2f')](_0x4a1c('0x30')+_0x30d4f8[_0x4a1c('0x31')]);}});chat[_0x4a1c('0x2d')]=_0x53590c=>{onMessageCallbacks['push'](_0x53590c);};}{const commands=new Map();function pushHelpString(_0x4b23d3,_0x3fd75f=''){if(Array[_0x4a1c('0x32')](_0x4b23d3)){if(_0x3fd75f){return _0x4b23d3[_0x4a1c('0x33')](_0x5802e4=>{return''+_0x3fd75f+_0x5802e4;})[_0x4a1c('0x14')]('\x0a');}}return _0x3fd75f+_0x4b23d3;}class Command{constructor(_0x547930,_0x119220){this['id']=_0x547930;this['opts']=_0x119220;this[_0x4a1c('0x34')]=_0x119220[_0x4a1c('0x34')];this[_0x4a1c('0x35')]=_0x119220['calledWithNoArgs'];this[_0x4a1c('0x36')]=_0x119220[_0x4a1c('0x36')];this['onlyOwner']=_0x119220[_0x4a1c('0x37')];this[_0x4a1c('0x38')]=[pushHelpString(_0x119220['detailedHelp'],emoji['RIGHT_ARROW']+'\x20')][_0x4a1c('0x14')]('\x0a');if(_0x119220['help']&&Array[_0x4a1c('0x32')](_0x119220[_0x4a1c('0x39')])){_0x119220['help']=_0x119220['help']['join']('\x0a');}this['_help']=_0x119220[_0x4a1c('0x39')]||'';this[_0x4a1c('0x3a')]=[_0x119220[_0x4a1c('0x36')]?_0x4a1c('0x3b'):_0x119220[_0x4a1c('0x37')]?'#c31616':_0x4a1c('0x3c'),_0x119220[_0x4a1c('0x3d')]?_0x4a1c('0x3e'):_0x4a1c('0x3f')];}[_0x4a1c('0x40')](_0x23cef5,_0x554620){_0x554620[_0x4a1c('0x41')]=!(_0x23cef5===undefined||_0x23cef5==='');if(_0x554620['hasArgs']){_0x554620['arg']=_0x23cef5;}if(typeof this[_0x4a1c('0x34')]===_0x4a1c('0x42')){this['callback'](_0x554620);}else{throw new Error(_0x4a1c('0x43')+this['id']+'\x22');}}}const onCommand=(_0x508bd3,_0x5f25f7)=>{if(typeof _0x5f25f7===_0x4a1c('0x42')){_0x5f25f7={'callback':_0x5f25f7};}if(_0x5f25f7[_0x4a1c('0x34')]&&_0x4a1c('0x42')===typeof _0x5f25f7['callback']){if(commands[_0x4a1c('0x44')](_0x508bd3)){throw new Error(_0x4a1c('0x45')+_0x508bd3+'\x22\x20is\x20already\x20defined');}commands[_0x4a1c('0x46')](_0x508bd3,[new Command(_0x508bd3,_0x5f25f7)]);}};const callCommand=(_0x514661,_0x39886a,_0x43a42d)=>{let _0x5be43f=commands[_0x4a1c('0x44')](_0x514661);if(!_0x5be43f){throw new Error(_0x4a1c('0x47')+_0x514661+'\x22');}for(let _0x5d834d=0x0,_0x40c352=_0x5be43f[_0x4a1c('0xa')];_0x5d834d<_0x40c352;_0x5d834d++){_0x5be43f[_0x5d834d][_0x4a1c('0x40')](_0x39886a,_0x43a42d);}};onCommand('help',{'help':[_0x4a1c('0x48'),'/help\x20[command]\x20-\x20displays\x20more\x20info.\x20example:\x20[/help\x20link]'],'callback':function(_0x2f9717){_0x2f9717[_0x4a1c('0x19')]();let _0x451269=commands;let _0x51d663=![];if(_0x2f9717[_0x4a1c('0x49')]&&!commands[_0x4a1c('0x44')](_0x2f9717['arg'])){return _0x2f9717[_0x4a1c('0x4a')](_0x4a1c('0x4b')+_0x2f9717['arg']);}else if(_0x2f9717[_0x4a1c('0x49')]){_0x451269=[commands[_0x4a1c('0x44')](_0x2f9717['arg'])];_0x51d663=!![];}const _0x46f839=_0x2f9717[_0x4a1c('0x2a')]();const _0x219a68=_0x2f9717[_0x4a1c('0x29')]();let _0x143989=[];_0x451269['forEach'](([_0x2157d6])=>{if(_0x2157d6[_0x4a1c('0x4c')]===''){return;}let _0x194a79=[_0x2157d6['_help']];if(_0x51d663){_0x194a79[_0x4a1c('0x28')](_0x2157d6[_0x4a1c('0x38')]||'No\x20more\x20details\x20available\x20for\x20this\x20command');}const _0x5be06=[_0x194a79[_0x4a1c('0x14')]('\x0a'),_0x2157d6[_0x4a1c('0x3a')][0x0],_0x2157d6[_0x4a1c('0x3a')][0x1]];if(_0x219a68){_0x143989[_0x4a1c('0x28')](_0x5be06);}else if(_0x46f839){if(!_0x2157d6[_0x4a1c('0x37')]){_0x143989[_0x4a1c('0x28')](_0x5be06);}}else{if(!_0x2157d6[_0x4a1c('0x36')]&&!_0x2157d6[_0x4a1c('0x37')]){_0x143989[_0x4a1c('0x28')](_0x5be06);}}});_0x143989['forEach'](([_0x13e1d4,_0x46e27d,_0x216de8])=>{chat['notice'](_0x13e1d4,{'to':_0x2f9717[_0x4a1c('0x17')],'color':_0x46e27d,'fontWeight':_0x216de8});});}});chat[_0x4a1c('0x2d')](function(_0x4f5ecd){var _0x21b760=_0x4f5ecd['text'][_0x4a1c('0x11')](/^\/(\w+)(\s+.*)?$/);if(_0x21b760){const [_0x228df4,_0x181802,_0x3f9313]=_0x21b760;let _0x2ecf79;if(_0x3f9313&&_0x3f9313['trim']){_0x2ecf79=_0x3f9313[_0x4a1c('0x4d')]();}try{chat[_0x4a1c('0x4e')](_0x181802,_0x2ecf79,_0x4f5ecd);}catch(_0x4b85cc){_0x4f5ecd[_0x4a1c('0x4a')](_0x4a1c('0x4f')+_0x4b85cc[_0x4a1c('0x31')]+'\x22');}}});Object[_0x4a1c('0x50')](chat,{'onCommand':onCommand,'callCommand':callCommand});}{const onTipCallbacks=[];chat['onTip']=_0x4def35=>{onTipCallbacks[_0x4a1c('0x28')](_0x4def35);};cb[_0x4a1c('0x51')](({amount,from_user,message})=>{if(!chat[_0x4a1c('0xb')][from_user]){chat[_0x4a1c('0xb')][from_user]=!![];}if(!chat[_0x4a1c('0xc')][from_user]){chat[_0x4a1c('0xc')][from_user]=0x0;}chat['tippers'][from_user]+=amount;onTipCallbacks[_0x4a1c('0x10')](_0x54f776=>{_0x54f776({'sender':from_user,'amount':amount,'message':message,'totalTipped':chat[_0x4a1c('0xc')][from_user]});});});}{let topic=cb[_0x4a1c('0xd')]+_0x4a1c('0x52');const getTopic=()=>{return topic;};const setTopic=_0x1e1c5b=>{if(_0x1e1c5b){topic=_0x1e1c5b;cb[_0x4a1c('0x53')](topic);}else{return![];}};Object[_0x4a1c('0x50')](chat,{'getTopic':getTopic,'setTopic':setTopic});} let oldTopic = false; chat.onCommand('away', { help: [ `/away [optional message] (sets an away message)`, `/back (resets the room subject after being 'away')`, ], onlyMods: true, callback: (ctx) => { const str = ctx.arg; const awayMessage = !!str ? `away: ${str}` : 'away'; if (ctx.isMod()) { if (!oldTopic) { oldTopic = chat.getTopic(); } chat.notice(awayMessage); chat.setTopic(awayMessage); } else { chat.notice(`${ctx.origin} is ${awayMessage}`); } ctx.preventDefault(); }, }); chat.onCommand('back', (ctx) => { const str = ctx.arg; if (ctx.isMod()) { chat.notice('back'); if (oldTopic) { chat.setTopic(oldTopic); oldTopic = false; } } else { chat.notice(`${ctx.origin} is back`); } ctx.preventDefault(); }); const userCards = {}; const SUITS = ['Diamonds', 'Clubs', 'Hearts', 'Spades']; const RANKS = [2, 3, 4, 5, 6, 7, 8, 9, 10, 'Jack', 'Queen', 'King', 'Ace']; const RANKS_ABBR = [2, 3, 4, 5, 6, 7, 8, 9, 10, 'J', 'Q', 'K', 'A']; const ICONS = {}; const expandSuitChar = (n) => unescape(`%u${(n + 2660)}`); [['Spades', 4, 0], ['Hearts', 1, 5], ['Diamonds', 2, 6], ['Clubs', 7, 3]].forEach(([key, outline, solid]) => { ICONS[key] = { outline: expandSuitChar(outline), solid: expandSuitChar(solid), }; }); const UNICODE_CARDS = (() => { const cards = []; // corresponding to offset in utf-8 mapping of cards [3, 2, 0, 1].forEach((suitIndex, utfOffset) => { const utfIndex = 3530 + utfOffset; [-1, 12, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, 10, 11].forEach((cardRank, utfSecondaryIndex)=> { if (cardRank > -1) { let index = suitIndex + cardRank * 4; cards[index] = { suitIndex, index, cardRank, card: unescape(`%ud83c%u${(16 * utfIndex + utfSecondaryIndex).toString(16)}`), suit: SUITS[suitIndex], suitIcon: ICONS[SUITS[suitIndex]], rank: RANKS[cardRank], rankAbbr: RANKS_ABBR[cardRank], isRed: suitIndex % 2 === 0, }; } }); }); return cards; })(); const calcCard = (username) => { if (!userCards[username]) { userCards[username] = (chat.sessionSeed() + chat.utils.hashStringToInt(username)) % 52; } return userCards[username]; }; const viewCard = (username) => { return UNICODE_CARDS[calcCard(username)]; }; let cardsActive = false; chat.onCommand('cards', { usage: '/cards', description: `deal a card to each member in the room. they can access their cards by tipping or typing '/card'`, onlyMods: true, callback: (ctx) => { if (!ctx.isMod()) { return ctx.reject('Only mods can start this app'); } if (!cardsActive) { cardsActive = true; chat.notice(`"Highest card" game has been started. This is a simple game, where everyone draws a card to see who gets the highest. Try it with: /card`); } else { cardsActive = false; ctx.snuff(); chat.notice(`"Highest card" game hidden.`); } } }); let rankingNum = 0; let sortedCards = []; let topCards = []; const SHOW_TOP = 3; function getRanks () { sortedCards = chat.utils.ObjectEntries(userCards).sort((a, b) => a[1] < b[1]); topCards = sortedCards.slice(0, SHOW_TOP); rankingNum = topCards[topCards.length-1][1]; } function listCardRanks () { let topCardInfo = topCards.map(([username, cardNumber], place)=>{ const card = UNICODE_CARDS[cardNumber]; return `${chat.constants.emoji.RIGHT_ARROW} #${place+1} with a [ ${card.rankAbbr} ${card.suitIcon.solid} ], ${username}`; }).join('\n'); chat.notice(`Cards drawn- ${topCardInfo} ${chat.constants.emoji.RIGHT_DOUBLE_ARROW} Check your card by typing '/card'`); } const showingCard = {}; chat.onCommand('card', { usage: '/card', description: `view your card`, onlyMods: false, callback: (ctx) => { const { sender, arg } = ctx; if (!cardsActive) { return ctx.reject(`the 'cards' app is not active. ask a mod or the owner to start it with the command '/cards'.`); } let player = sender; let selfPlayed = true; if (arg) { let user = chat.queryUser(arg); player = user; if (player !== sender) { selfPlayed = false; } } if (!userCards[player]) { const card = viewCard(player); showingCard[player] = true; ctx.text = ''; if (selfPlayed) { chat.notice(`${player} pulled a ${card.rank} of ${card.suit.toLowerCase()} from the deck`); } else { chat.notice(`${sender} pulled a ${card.rank} of ${card.suit.toLowerCase()} from the deck for ${player}`); } getRanks(); let curCardIndex = calcCard(player); if (curCardIndex >= rankingNum) { listCardRanks(); } } else if (showingCard[player]) { ctx.snuff(); const card = viewCard(ctx.origin); chat.notice(`Hiding your card (${card.rank} of ${card.suit})`, { to: player, }); showingCard[player] = false; } else { const card = viewCard(ctx.origin); chat.notice(`Showing your card (${card.rank} of ${card.suit})`, { to: player, }); showingCard[player] = true; } } }); chat.onMessage((ctx) => { const { sender, prependers } = ctx; if (cardsActive && userCards[sender] !== undefined && showingCard[sender]) { const card = viewCard(sender); ctx.delim = ' - '; prependers.push(`${card.rankAbbr} ${card.suitIcon.solid} `); } }); // http://paletton.com/#uid=13L0u0kllllaFw0g0qFqFg0w0aF const colors = [ ['#78020b', '#ffc1c5'], ['#af0814', '#e7c8ca'], ['#551a00', '#ffdac9'], ['#7d3717', '#e8c9bc'], ['#230339', '#e5c1fe'], ['#1f793c', '#e2cdf0'], ['#0f073b', '#c8bffb'], ['#221858', '#dfd9fb'], ['#0034b1', '#afc1ec'], ['#053196', '#d0d7e9'], ]; const colorLength = colors.length; let userColorsActive = true; const userColors = {}; chat.onCommand('usercolors', { help: '/usercolors (sets every users color)', onlyMods: true, detailedHelp: [ 'These colors are determined by the username ', 'and will persist from one session to the next.' ], callback: (ctx) => { userColorsActive = !userColorsActive; chat.notice(userColorsActive ? `"Usercolors" activated. Each member has the same color from one day to the next. There are ${colorLength} different sets of colors.` : '"Usercolors" OFF'); } }); chat.onMessage((ctx) => { if (userColorsActive) { if (!userColors[ctx.sender]) { userColors[ctx.sender] = colors[chat.utils.hashStringToInt(ctx.sender) % colorLength]; } ctx.setColor(userColors[ctx.sender][0], userColors[ctx.sender][1]); } }); // an 'eval' command for debugging { chat.onCommand('eval', function(ctx){ let resp; let str = ctx.arg || ''; const evalCopy = eval; if (!ctx.isMod()) { return ctx.reject('You must be a moderator to run this command'); } if(str.match(/^(\'|\")(.*)(\'|\")$/)) { str = str.match(/^(\'|\")(.*)(\'|\")$/)[2]; } try { resp = evalCopy(str); } catch (e) { resp = `Error: ${e.message}`; } chat.notice(`Evaluated response: ${resp}`, ctx.origin); }); } chat.onCommand("link", { help: '/link [url]', detailedHelp: 'A way to post URLs that might be filtered from the general chat', callback ({ sender, arg }) { chat.notice(`${sender}'s /link (copy-paste into new tab) ${arg}`); } }); // "/me [message]" // users must talk in the third person. or this looks dumb chat.onCommand('me', { help: `/me [message to broadcast] (displays a message to the room)`, detailedHelp: `Note: must be written in the third person or it won't make sense!!`, callback: function (ctx) { const status = ctx.arg; if (status !== undefined) { chat.notice(`* ${ctx.origin} ${status}`); } ctx.preventDefault(); } }); var latestMessageSenders = {}; chat.onCommand('msg', { help: '/msg [username] [message]', detailedHelp: 'A new way to direct message', callback: (ctx) => { const userAndMsg = ctx.arg || ''; const [_, usernameGuess, message] = userAndMsg.match(/^(\w+)\s+(.*)$/); if (!message) { return ctx.reject(`Sending message failed. Message not recognized`); } // var username = blocks[0], message = blocks.splice(1).join(" "); let username = chat.queryUser(usernameGuess); if (username && message) { chat.notice(`Direct message from ${ctx.origin} to ${username} [ ${username} ]`, username); chat.notice(`Direct message from ${ctx.origin} to ${username} [ ${message} ]`, ctx.origin); latestMessageSenders[username] = ctx.origin; } ctx.text = `(${ctx.text})`; ctx.snuff(); } }); chat.onCommand('r', { callback: (ctx) => { const message = ctx.arg || ''; var username = latestMessageSenders[ctx.origin]; if (username) { chat.notice(`Direct message from ${ctx.origin} to ${username} [ ${username} ]`, username); chat.notice(`Direct message from ${ctx.origin} to ${username} [ ${message} ]`, ctx.origin); latestMessageSenders[username] = ctx.origin; } ctx.text = `(${ctx.text})`; ctx.snuff(); } }); /* Chat area: i wrote a command that works similar to "cb.sendNotice" The main difference is that the order of the arguments doesn't matter. This is the syntax: chat.notice("message", { color: 'black', //optional. hex only background: 'white', //optional. hex only to: 'username', //optional }); */ // to get the 'escaped' value, open up a chrome inspector and run this command: // escape('💧') --shows--> "%uD83D%uDCA7" Object.assign(chat.constants.emoji, { // escape('💧') RAINDROP: unescape('%uD83D%uDCA7'), // escape('🏖') BEACH: unescape('%uD83C%uDFD6'), // escape('🛡') SHIELD: unescape('%uD83D%uDEE1'), // escape('🌊') WAVE: unescape('%uD83C%uDF0A'), // escape('🌙') CRESCENT_MOON: unescape('%uD83C%uDF19'), // escape('🍉') WATERMELON: unescape('%uD83C%uDF49'), // escape('🕺') DANCING_MAN: unescape('%uD83D%uDD7A'), // escape('💃') DANCING_LADY: unescape('%uD83D%uDC83'), // escape('💩') POOP: unescape('%uD83D%uDCA9'), // escape('🍈') MELON: unescape('%uD83C%uDF48'), // escape('☙') FLORAL: unescape('%u2619'), }); // on enter, show the user a welcome message var welcomeMessage = `Psst! Wanna pick your color? type /theme`; cb.onEnter(() => { chat.notice(`:helpicon ${welcomeMessage}`, { color: '#fff', background: '#0084ff', to: 'username', weight: 'bold', }); }); const PRICE_OF_SIMPLE = 20; const PRICE_OF_GRADIENT = 40; //check out the `color-picker` atom package. //i have it and pigment //nice //advanced color themes [text color, background color] const customThemes = { midnight: { plainVersion:["rgba(255,196,37,1)","rgba(55,56,84,1)"], gradientVersion:["rgba(255,196,37,1)","linear-gradient(to right, rgba(55,56,84,1), #a908d2)"], textFlair: chat.constants.emoji.CRESCENT_MOON, }, retro: { plainVersion:["rgba(251,46,1,1)","rgba(111,203,159,1)"], // i tried it out with a hex color and it worked fine: // plainVersion:["rgba(251,46,1,1)","#990000"], gradientVersion:["rgba(251,46,1,1)","linear-gradient(to right, rgba(111,203,159,1), rgba(255,226,138,1))"], textFlair: chat.constants.emoji.DANCING_MAN, }, // melon: { // plainVersion: ["rgba(250,125,128,1)", "rgba(16,105,93,1)"], // gradientVersion: ["rgba(250,125,128,1)", "linear-gradient(to right, rgba(16,105,93,1), rgba(255,226,138,1))"], // textFlair: chat.constants.emoji.MELON, // }, fire: { plainVersion: ["rgba(242,125,12,1)", "rgba(128,9,9,1)"], gradientVersion: ["rgba(242,125,12,1)", "linear-gradient(to right, rgba(128,9,9,1), rgba(0,0,0,1))"], textFlair: chat.constants.emoji.FLAME, }, gryffindor: { plainVersion: ["rgba(211,166,37,1)", "rgba(116,0,1,1)"], gradientVersion: ["rgba(211,166,37,1)", "linear-gradient(to right, rgba(116,0,1,1), rgba(174,0,1,1))"], textFlair: chat.constants.emoji.SHIELD, }, beach: { plainVersion: ["rgba(255,204,92,1)", "rgba(255,111,105,1)"], gradientVersion: ["rgba(255,204,92,1)", "linear-gradient(to right, rgba(255,111,105,1), rgba(150,206,180,1))"], textFlair: chat.constants.emoji.BEACH, }, seafoam: { plainVersion: ["rgba(49,120,115,1)", "rgba(160,214,180,1)"], gradientVersion: ["rgba(49,120,115,1)", "linear-gradient(to right, rgba(160,214,180,1), rgba(95,158,160,1))"], textFlair: chat.constants.emoji.WAVE, }, rain: { plainVersion: ["rgba(100,151,177,1)", "rgba(1,31,75,1)"], gradientVersion: ["rgba(100,151,177,1)", "linear-gradient(to right, rgba(1,31,75,1), rgba(0,91,150,1))"], textFlair: chat.constants.emoji.RAINDROP }, plum: { plainVersion: ["rgba(211,196,207,1)", "rgba(110,60,96,1)"], gradientVersion: ["rgba(211,196,207,1)", "linear-gradient(to right, rgba(110,60,96,1), rgba(178,48,92,1))"], textFlair: chat.constants.emoji.EGGPLANT }, }; /* /theme (list themes) /theme snow (activate snow theme) */ const savedFlair = {}; const savedColors = {}; const userSelectedTheme = {}; const themeCommand = (ctx, gradient)=> { // temporarily showing ctx.snuff(); const { arg, sender } = ctx; // const username = ctx.origin; let tipAmount = chat.tippers[sender] || 0; let canSetTheme = ctx.isMod() || tipAmount >= PRICE_OF_SIMPLE; let canSetGradient = ctx.isMod() || tipAmount >= PRICE_OF_GRADIENT; if (!arg) { // let themes = '| ' + Object.keys(customThemes).map((themeId, n)=> { // let space = n % 3 === 2 ? ' |\n | ' : ' | '; // return `${customThemes[themeId].textFlair}${themeId}${space}`; // }).join(''); chat.notice(` Tip ${PRICE_OF_SIMPLE}+ tokens so you can set a theme. ${PRICE_OF_GRADIENT}+ to set a theme with a gradient! /theme midnight (set your theme to midnight)`, { to: sender, fontWeight: 'bold', }); setTimeout((()=>{ Object.keys(customThemes).forEach((themeId) => { chat.notice(`[ ${customThemes[themeId].textFlair} /theme ${themeId} ${customThemes[themeId].textFlair} ]`, { to: sender, color: customThemes[themeId].plainVersion[0], background: customThemes[themeId].plainVersion[1], }); }); }), 1000); return; } if (canSetGradient) { gradient = true; } let [themeId, ...rest] = arg.split(' '); if (themeId[0] === '-') { themeId = themeId.substr(1); gradient = false; } if (themeId === 'reset') { savedFlair[sender] = false; savedColors[sender] = []; } else if (!canSetTheme) { chat.notice(`You must tip at least 20 tokens to set a theme`, { to: sender, color: '#9900000', weight: 'bold', }); } else if (customThemes[themeId]) { const { plainVersion, gradientVersion, textFlair, } = customThemes[themeId]; const flairValue = unescape(textFlair); savedFlair[sender] = flairValue; if (rest.length > 0) { ctx.text = `${themeId} - ${rest.join(' ')}`; ctx.unsnuff(); } else { ctx.text = `${themeId}`; } userSelectedTheme[sender] = themeId; savedColors[sender] = gradient ? gradientVersion : plainVersion; } else { ctx.reject(`Theme not found: '${themeId}'`); } }; chat.onCommand('theme', (ctx)=>{ themeCommand(ctx, false); }); chat.onMessage((context) => { const username = context.origin; if (savedFlair[username]) { context.setPrefix(savedFlair[username]); } if (savedColors[context.origin]) { context.setColor(savedColors[context.origin][0], savedColors[context.origin][1]); } }); const notifiedOfThemes = {}; const notifiedOfGradientThemes = {}; chat.onTip(({ sender, amount, message, totalTipped, })=>{ if (totalTipped >= PRICE_OF_GRADIENT && !notifiedOfGradientThemes[sender]) { chat.notice(`You have tipped more than ${PRICE_OF_GRADIENT} tokens. You can now set a theme with a gradient! You can see the available themes with the command '/theme'`, { to: sender, fontWeight: 'bold', }); if (userSelectedTheme[sender]) { let themeId = userSelectedTheme[sender]; chat.notice(`Upgrading your theme to ${userSelectedTheme[sender]} with a gradient.`, { to: sender, }); savedColors[sender] = customThemes[themeId].gradientVersion; } notifiedOfThemes[sender] = true; notifiedOfGradientThemes[sender] = true; } if (totalTipped >= PRICE_OF_SIMPLE && !notifiedOfThemes[sender]) { chat.notice(`You have tipped more than ${PRICE_OF_SIMPLE} tokens. You can set a theme. You can see the available themes with the command '/theme'`, { to: sender, }); notifiedOfThemes[sender] = true; } }); let activeFont; // list of fonts pulled from here: // http://www.lalit.org/lab/javascript-css-font-detect/ const FONTS = [ 'Arial Black', 'Arial Narrow', 'Arial Rounded MT Bold', 'Arial', 'Comic Sans MS', 'Courier', 'Courier New', 'cursive', 'fantasy', 'Georgia', 'Impact', 'Papyrus', 'Trebuchet MS', 'Verdana', ]; chat.onCommand('roomfont', { help: [ '/roomfont (lists the fonts available)', '/roomfont [font-name] (sets the font for all messages in the room)', ], onlyMods: true, callback: (ctx) => { const { origin, reject, arg } = ctx; if (!ctx.isMod()) { reject('You are not allowed to use this function'); } ctx.snuff(); if (arg === 'reset') { activeFont = false; return reject('Reset room font'); } if (['list', '', undefined].includes(arg)) { let fontStrings = FONTS.map((fontName)=>{ return '\n' + (fontName === activeFont ? '* ' : '- ') + fontName; }).join(''); chat.notice(`Available fonts: ${fontStrings}`, origin); return; } let font; if (FONTS.includes(arg)) { font = arg; } else if (chat.utils.isargingOfInt(arg)) { font = FONTS[parseInt(arg)]; } if (font) { activeFont = font; chat.notice(`Setting font to '${font}'`, origin); } else { reject(`Font not found: ${arg}`); } } }); chat.onMessage((ctx)=>{ if (activeFont) { ctx.setFont(activeFont); } }); const savedColors$1 = {}; // i'm doing this so we can test out raw colors. we can remove this before we publish the app chat.onCommand('rawcolor', { help: [ `/rawcolor [textcolor] [backgroundcolor] (sets color options for your own messages)`, `/rawcolor reset (resets color)` ], onlyMods: true, callback: (ctx) => { // ctx.snuff() // don't show the "/rawcolor" message to the whole chat room if (!ctx.isMod()) { ctx.reject('Only administrators can change this value'); } const [cmd, ...params] = ctx.words(); const sender = ctx.origin; if (params.length === 0) { chat.notice(`These are the commands to set your colors: /rawcolor (display this help message) /rawcolor blue pink (will set your textColor to blue and backgroundColor to pink) /rawcolor reset (will reset your colors to the default)`, sender); } else if (params.length === 1 && params[0] === 'reset') { savedColors$1[sender] = []; } else { const [textColor, ...backgroundColorArr] = params; const backgroundColor = backgroundColorArr.join(' ') || chat.utils.noop(ctx) || 'inherit'; chat.notice(`${sender} is changing their text color with the command /rawcolor`); chat.notice(`Changing textColor to ${textColor}`, sender); chat.notice(`Changing backgroundColor to ${backgroundColor}`, sender); savedColors$1[sender] = [textColor, backgroundColor]; } } }); chat.onMessage((context) => { const { sender } = context; if (savedColors$1[sender]) { context.setColor(savedColors$1[sender][0], savedColors$1[sender][1]); } }); chat.onCommand('topic', { help: `/topic [new room topic] (sets the room subject)`, onlyMods: true, callback: (ctx) => { const nextTopic = ctx.arg; if (ctx.isMod()) { chat.setTopic(nextTopic); ctx.reject(); } } }); // list users and tippers chat.onCommand('users', { help: '/users (list all users who have messaged or tipped)', callback (ctx) { ctx.snuff(); let out = `Talked or tipped:\n ${chat.constants.emoji.RIGHT_ARROW} `; out += Object.keys(chat.users).join(' '); chat.notice(out, ctx.sender); } }); chat.onCommand('checkuser', { callback (ctx) { ctx.snuff(); try { let username = chat.queryUser(ctx.arg); chat.notice(`user found: ${username}`, { to: ctx.sender, }); } catch (e) { ctx.reject(e.message); } } }); chat.onCommand('tippers', { help: '/tippers (list all users who have tipped)', callback (ctx) { ctx.snuff(); let tippersList = chat.utils.ObjectEntries(chat.tippers); if (tippersList.length === 0) { chat.notice('No tippers'); } else { let out = [`Tippers:`]; let userList = tippersList.sort((a,b)=>a[1] < b[1]).forEach(([user, tiptotal])=>{ out.push(` - ${user} (${tiptotal})`); }); chat.notice(out.join('\n'), ctx.sender); } } });
© Copyright Chaturbate 2011- 2026. All Rights Reserved.