Bots Home
|
Create an App
Debug advanced tip menu
Author:
gregory_handsome
Description
Source Code
Launch Bot
Current Users
Created by:
Gregory_Handsome
var total_tips = 0; var ht_username = null; var ht_amount = 0; var menu = {}; var userList = {}; //stats by /getlist command var whiteList = []; //white list for grey users (filled with those who sent 1 message already) let blackList = ['hornyboy', 'cumboys', 'c2cboys', 'c2cplay', 'slaveboys', 'daddyboys', 'daddysboys']; //keywords for blocking messages // Settings cb.settings_choices = [{ name: 'highlight_tippers', type: 'choice', label: 'Highlight tippers messages in chat', choice1: 'Yes', choice2: 'No', defaultValue: 'No' }, { name: 'antispam', type: 'choice', label: 'Antispam protection (more details in description)', choice1: 'Yes', choice2: 'No', defaultValue: 'No' }, { name: 'blacklist', type: 'str', minLength: 1, maxLength: 250, label: "Blacklist (sitenames here), see description" }, { name: 'chat_ad', type: 'int', minValue: 0, maxValue: 999, defaultValue: 10, label: 'Advertise Menu in Chat Every _____ Mins (Set 0 to Disable)' }, { name: 'type_of_ad', type: 'choice', label: 'Choose "menu" if you want bot to send whole menu as advertising or leave just invite message', choice1: 'Simple message', choice2: 'Whole menu', defaultValue: 'Simple message' }, { name: 'item1', type: 'str', minLength: 1, maxLength: 30, label: "Menu Item 1 (required)" }, { name: 'price1', type: 'int', minValue: 0, defaultValue: 10, label: "Item 1 Price (required)" }, { name: 'item2', type: 'str', minLength: 1, maxLength: 50, label: "Menu Item 2 (required)" }, { name: 'price2', type: 'int', minValue: 0, defaultValue: 20, label: "Item 2 Price (required)" }, { name: 'item3', type: 'str', minLength: 1, maxLength: 50, label: "Menu Item 3", required: false }, { name: 'price3', type: 'int', minValue: 0, label: "Item 3 Price", required: false }, { name: 'item4', type: 'str', minLength: 1, maxLength: 50, label: "Menu Item 4", required: false }, { name: 'price4', type: 'int', minValue: 0, label: "Item 4 Price", required: false }, { name: 'item5', type: 'str', minLength: 1, maxLength: 50, label: "Menu Item 5", required: false }, { name: 'price5', type: 'int', minValue: 0, label: "Item 5 Price", required: false }, { name: 'item6', type: 'str', minLength: 1, maxLength: 50, label: "Menu Item 6", required: false }, { name: 'price6', type: 'int', minValue: 0, label: "Item 6 Price", required: false }, { name: 'item7', type: 'str', minLength: 1, maxLength: 50, label: "Menu Item 7", required: false }, { name: 'price7', type: 'int', minValue: 0, label: "Item 7 Price", required: false }, { name: 'item8', type: 'str', minLength: 1, maxLength: 50, label: "Menu Item 8", required: false }, { name: 'price8', type: 'int', minValue: 0, label: "Item 8 Price", required: false }, { name: 'item9', type: 'str', minLength: 1, maxLength: 50, label: "Menu Item 9", required: false }, { name: 'price9', type: 'int', minValue: 0, label: "Item 9 Price", required: false }, { name: 'item10', type: 'str', minLength: 1, maxLength: 50, label: "Menu Item 10", required: false }, { name: 'price10', type: 'int', minValue: 0, label: "Item 10 Price", required: false }, { name: 'item11', type: 'str', minLength: 1, maxLength: 50, label: "Menu Item 11", required: false }, { name: 'price11', type: 'int', minValue: 0, label: "Item 11 Price", required: false }, { name: 'item12', type: 'str', minLength: 1, maxLength: 50, label: "Menu Item 12", required: false }, { name: 'price12', type: 'int', minValue: 0, label: "Item 12 Price", required: false }, { name: 'item13', type: 'str', minLength: 1, maxLength: 50, label: "Menu Item 13", required: false }, { name: 'price13', type: 'int', minValue: 0, label: "Item 13 Price", required: false }, { name: 'item14', type: 'str', minLength: 1, maxLength: 50, label: "Menu Item 14", required: false }, { name: 'price14', type: 'int', minValue: 0, label: "Item 14 Price", required: false }, { name: 'item15', type: 'str', minLength: 1, maxLength: 50, label: "Menu Item 15", required: false }, { name: 'price15', type: 'int', minValue: 0, label: "Item 15 Price", required: false }, { name: 'item16', type: 'str', minLength: 1, maxLength: 50, label: "Menu Item 16", required: false }, { name: 'price16', type: 'int', minValue: 0, label: "Item 16 Price", required: false }, { name: 'item17', type: 'str', minLength: 1, maxLength: 50, label: "Menu Item 17", required: false }, { name: 'price17', type: 'int', minValue: 0, label: "Item 17 Price", required: false }, { name: 'item18', type: 'str', minLength: 1, maxLength: 50, label: "Menu Item 18", required: false }, { name: 'price18', type: 'int', minValue: 0, label: "Item 18 Price", required: false }, { name: 'item19', type: 'str', minLength: 1, maxLength: 50, label: "Menu Item 19", required: false }, { name: 'price19', type: 'int', minValue: 0, label: "Item 19 Price", required: false }, { name: 'item20', type: 'str', minLength: 1, maxLength: 50, label: "Menu Item 20", required: false }, { name: 'price20', type: 'int', minValue: 0, label: "Item 20 Price", required: false } ]; // Handlers cb.onEnter(function (user) { let username = user['user']; sendMenuToUser(username, true); if ((cb.settings.antispam == 'Yes') && !user['has_tokens'] && !whiteList.includes(username)) { sendWelcomeAntiSpamMessage(username); } }); cb.onTip(function(tip) { let amount = tip['amount']; let username = tip['from_user']; if (userList[username] != undefined && userList[username] != null) { userList[username] += amount } else { userList[username] = amount; } total_tips += amount; if(menu[amount] != undefined) { sendToAll(menu[amount]); } if (amount > ht_amount) { ht_amount = amount; ht_username = username; } cb.drawPanel(); }); cb.onMessage(function(msg) { if (antiSpamCheck(msg)) { msg['X-Spam'] = true; return msg; } if (cb.settings.highlight_tippers == 'Yes' && msg['user'] == ht_username) { msg['background'] = '#CCFF99'; } if (msg['m'].match(/\/menu/i)) { sendMenuToUser(msg['user'], false); msg['X-Spam'] = true; } if (msg['m'].match(/\/showmenu/i) && (msg['user'] == cb.room_slug || msg['is_mod'] == true)) { sendMenuToChat(); msg['X-Spam'] = true; } if (msg['m'].match(/\/getlist/i) && (msg['user'] == cb.room_slug || msg['is_mod'] == true)) { sendListMessage(msg['user']); msg['X-Spam'] = true; } if (msg['m'].match(/\/getalphabet/i) && (msg['user'] == cb.room_slug || msg['is_mod'] == true)) { sendAlphabet(); msg['X-Spam'] = true; } return msg; }); // ANTI SPAM const spamEncodedAlphabet = '{"97":[[55349,56606,55349],945,65345,7424,592,97,7491,9424,479,261,229,8371,940,65313,8704,65,9398,196,570,197,[55349,56372,55349],[55349,56398,55349],[55349,56424,55349],[55349,56450,55349],[]],"98":[[55349,56607,55349],65346,665,98,7495,9425,3666,4262,622,4330,66,1074,223,3647,20035,1165,946,65314,9399,7470,8492,[55349,56373,55349],[55349,56399,55349],[55349,56425,55349],[55349,56451,55349],[]],"99":[[55349,56608,55349],7580,65347,99,9426,962,162,8373,40,91,231,268,60,8451,262,9400,8493,8450,65315,67,199,[55349,56374,55349],[55349,56400,55349],[55349,56426,55349],[55349,56452,55349],[]],"100":[[55349,56609,55349],65348,7429,100,7496,9427,1283,68,8706,208,272,1386,270,65316,273,9401,7472,8517,8518,[55349,56375,55349],[55349,56401,55349],[55349,56427,55349],[55349,56453,55349],[]],"101":[[55349,56610,55349],65349,7431,477,101,600,8337,7497,1108,1213,603,275,931,234,69,949,65317,8364,9402,7864,7473,200,400,941,8455,8494,8495,8496,8512,8519,[55349,56376,55349],[55349,56402,55349],[55349,56428,55349],[55349,56454,55349],[]],"102":[[55349,56611,55349],65318,65350,42800,102,7584,9429,358,989,70,402,8355,1171,401,9403,8457,8497,[55349,56377,55349],[55349,56403,55349],[55349,56429,55349],[55349,56455,55349],[]],"103":[[55349,56612,55349],103,65351,610,7501,9430,608,71,8370,1409,484,286,65319,7475,9404,403,8458,[55349,56378,55349],[55349,56404,55349],[55349,56430,55349],[55349,56456,55349],[]],"104":[[55349,56613,55349],65352,668,104,688,9431,1106,1291,905,1085,11367,12435,8461,292,65320,9405,72,7476,502,8459,8460,8462,8463,[55349,56379,55349],[55349,56431,55349],[55349,56457,55349],[]],"105":[[55349,56614,55349],65353,618,305,105,8305,9432,953,616,73,322,20008,7588,407,8225,65321,9406,7477,204,303,943,8489,8520,[55349,56380,55349],[55349,56406,55349],[55349,56432,55349],[55349,56458,55349],[]],"106":[[55349,56615,55349],65322,65354,7434,106,690,9433,669,74,1112,308,4273,9407,8464,8465,8521,[55349,56381,55349],[55349,56407,55349],[55349,56433,55349],[55349,56459,55349],[]],"107":[1082,65355,7435,670,107,7503,9434,409,1220,75,8365,1180,1183,9408,65323,311,1036,7479,[55349,56382,55349],[55349,56408,55349],[55349,56434,55349],[55349,56460,55349],[]],"108":[[55349,56617,55349],65356,621,645,406,8467,11360,12581,65434,65324,321,741,76,8515,7480,9409,42824,315,8452,8466,8522,[55349,56383,55349],[55349,56409,55349],[55349,56435,55349],[55349,56461,55349],[]],"109":[[55349,56618,55349],9410,65357,7437,109,7504,9436,3667,625,653,5047,77,1084,8357,1019,7481,11374,8499,[55349,56384,55349],[55349,56410,55349],[55349,56436,55349],[55349,56462,55349],[]],"110":[[55349,56619,55349],9411,65358,628,110,8345,8319,9437,627,1404,331,3734,951,241,1394,327,65326,7600,8469,78,886,8470,[55349,56385,55349],[55349,56411,55349],[55349,56437,55349],[55349,56463,55349],[]],"111":[[55349,56620,55349],7894,65359,7439,111,8338,7506,963,1413,417,3792,1256,79,65327,186,7484,214,12444,972,9702,937,8500,[55349,56386,55349],[55349,56412,55349],[55349,56438,55349],[55349,56464,55349],[]],"112":[[55349,56621,55349],420,65360,7448,112,7510,9439,1511,961,1412,8472,80,8369,9413,65328,8473,7486,8471,[55349,56387,55349],[55349,56413,55349],[55349,56439,55349],[55349,56465,55349],[]],"113":[[55349,56622,55349],65361,81,113,9440,1382,586,490,8474,65329,7884,[55349,56388,55349],[55349,56414,55349],[55349,56440,55349],[55349,56466,55349],[]],"114":[[55349,56623,55349],344,65362,640,114,691,9441,1075,638,1071,1103,11364,65330,8477,8476,7450,82,9415,341,8475,8479,[55349,56389,55349],[55349,56415,55349],[55349,56441,55349],[55349,56467,55349],[]],"115":[[55349,56624,55349],350,65363,42801,115,738,9442,642,1414,423,1109,83,65331,351,348,[55349,56390,55349],[55349,56416,55349],[55349,56442,55349],[55349,56468,55349],[]],"116":[[55349,56625,55349],19973,65364,7451,7511,9443,566,428,1090,8224,8366,12562,1383,84,356,355,65332,7488,9417,882,[55349,56391,55349],[55349,56417,55349],[55349,56443,55349],[55349,56469,55349],[]],"117":[[55349,56626,55349],65365,7452,117,7512,9444,965,650,371,1062,181,1396,9418,249,471,65333,85,[824,7918,824],[55349,56392,55349],[55349,56418,55349],[55349,56444,55349],[55349,56470,55349],[]],"118":[[55349,56627,55349],65366,7456,118,7515,9445,1783,86,957,8730,1141,65334,1142,9419,8483,[55349,56393,55349],[55349,56419,55349],[55349,56445,55349],[55349,56471,55349],[]],"119":[[55349,56628,55349],969,65367,7457,119,695,9446,623,1377,8179,1065,87,65335,974,372,824,7490,9420,[55349,56394,55349],[55349,56420,55349],[55349,56446,55349],[55349,56472,55349],[]],"120":[[55349,56629,55349],120,8339,739,9447,1276,1203,88,967,1278,215,9421,65336,4335,8501,[55349,56395,55349],[55349,56421,55349],[55349,56447,55349],[55349,56473,55349],[]],"121":[1199,65369,655,654,121,696,9448,4327,5033,89,1091,165,590,12570,1406,9422,1038,65337,1227,435,8509,[55349,56396,55349],[55349,56422,55349],[55349,56448,55349],[55349,56474,55349],[]],"122":[382,65370,7458,122,823,656,657,90,11371,381,8484,379,9423,437,65338,576,[55349,56397,55349],[55349,56423,55349],[55349,56449,55349],[55349,56475,55349],[]]}'; let spamAlphabet = {}; function decodeAlphabet() { let encodedAlphabet = JSON.parse(spamEncodedAlphabet); spamAlphabet = {}; for (let letter in encodedAlphabet) { spamAlphabet[String.fromCharCode(letter)] = []; for (let j in encodedAlphabet[letter]) { if (encodedAlphabet[letter][j].length != undefined) { ////WHAT IF 3 CODES????!!!! spamAlphabet[String.fromCharCode(letter)].push(String.fromCharCode(encodedAlphabet[letter][j][0], encodedAlphabet[letter][j][1])); } else { spamAlphabet[String.fromCharCode(letter)].push(String.fromCharCode(encodedAlphabet[letter][j])); } } } } function antiSpamCheck(msg) { let message = msg['m']; let username = msg['user']; if ((cb.settings.antispam == 'No') || msg['has_tokens']) { return false } if (isSpam(message)) { sendBlockNotification(username); sendBlockedMessageToBroadcaster(msg); return true } if (!whiteList.includes(username)) { whiteList.push(username); sendFirstMessageHidden(username); sendBlockedMessageToBroadcaster(msg); return true } return false } function isSpam(message) { for (let i in blackList) { if (messageContains(message, blackList[i])) { return true } } return false; } function messageContains(message, toSearch) { let normalView = transformMessage(message).replace(/\s+/g, '').toLowerCase(); return normalView.match(toSearch + '\.[a-zA-z]{1,10}') != null //check for 'snapchat' or 'snap' } function transformMessage(message) { message = subTransform(message); return message } function subTransform(message) { let transformed = []; let k = 0; while (k < message.length) { if (message[k].charCodeAt(0) != 55349) { transformed.push(message[k]); k++ } else { transformed.push(String.fromCharCode(message[k].charCodeAt(0), message[k + 1].charCodeAt(0))); k+=2 } } let length = transformed.length; for (let i in transformed) { for (let letter in spamAlphabet) { for (let j in spamAlphabet[letter]) { if (transformed[i] == spamAlphabet[letter][j]) { transformed[i] = letter; } } } } let out = ''; for (let i = 0; i < length; i++) { out += transformed[i]; } return out; } //debug function generateShit(source) { let output = ''; for (let i in source) { if (spamAlphabet[source[i]] != undefined) { output += spamAlphabet[source[i]][getRandomInt(spamAlphabet[source[i]].length - 1)]; } else { output += source[i]; } } return output } function testTransform(counts) { let errors = []; for (let i = 0; i < counts; i++) { let source = blackList[getRandomInt(blackList.length - 1)]; let shit = generateShit(source); let output = transformMessage(shit); if (output != source) { errors.push([source, shit, output]); } } console.log(errors); } function getRandomInt(max) { return Math.floor(Math.random() * Math.floor(max)); } // Messages function sendMenuToChat() { sendToAll(getMenuAsString(), '#0a5a83'); } function sendMenuToUser(username, firstTime) { if (firstTime) { sendToUser("Welcome here, " + username + ", take a look on my tip menu\n" + getMenuAsString(), username, '#0a5a83') } else { sendToUser(getMenuAsString(), username, '#0a5a83') } } function getMenuAsString() { let toSend = '-----' + cb.room_slug + 's Tip Menu -----'; for (let price in menu) { toSend += "\n" + menu[price] + ' is for ' + price + ' tokens' } return toSend; } function sendAd() { if (cb.settings.type_of_ad == 'Whole menu') { sendMenuToChat(); } else { sendToAll('Tip Menu Is Active! Tip ' + cb.settings.price1 + 'tokens for "' + cb.settings.item1 + '" Or, Type /menu to see the full menu'); } cb.setTimeout(sendAd, (cb.settings.chat_ad * 60000)); } // Tippers list function sendListMessage(username) { let toSend = ''; let names = Object.keys(userList).sort(function (a, b) { return userList[b] - userList[a] }); for (let i in names) { toSend += "\n" + names[i] + ': ' + userList[names[i]]; } sendToUser(toSend, username); } // Anti spam function sendFirstMessageHidden(username) { let toSend = "YOUR FIRST MESSAGE WAS HIDDEN FOR ENTIRE ROOM DUE TO ANTI SPAM REASONS (just the first one, don't worry) \n You're free to chat now, " + username; sendToUser(toSend, username, '#ff3636') } function sendBlockNotification(username) { let toSend = "YOUR MESSAGE WAS BLOCKED AS SPAM. If you're sure it's not spam - try paraphrase it using other words and send one more time"; sendToUser(toSend, username, '#ff3636') } function sendWelcomeAntiSpamMessage(username) { let toSend = "Hey there, " + username + ". I have anti-spam protection. Your first message will be hidden for chat. The thing is that bots come here and send only one message then they leave. So don't worry, you can chat free right since you send second message. Welcome :P"; sendToUser(toSend, username); } function sendBlockedMessageToBroadcaster(msg) { let toSend = "BLOCKED::" + msg['user'] + ": " + msg['m']; sendToBroadcaster(toSend); } function sendAlphabet() { let toSend = ''; for (let letter in spamAlphabet) { toSend += letter + ': '; for (let i in spamAlphabet[letter]) { toSend += spamAlphabet[letter][i] + ' '; } toSend += '\n' } sendToBroadcaster(toSend); } // Common function sendToBroadcaster(message) { cb.sendNotice(message, cb.room_slug); } function sendToUser(message, username, color) { if (color != undefined) { cb.sendNotice(message, username, '', color, 'bold'); } else { cb.sendNotice(message, username); } } function sendToAll(message, color) { if (color != undefined) { cb.sendNotice(message, '', '', color, 'bold'); } else { cb.sendNotice(message, ''); } } // Init if (cb.settings.chat_ad > 0) { cb.setTimeout(sendAd, (cb.settings.chat_ad * 60000)); } function init() { for (let i = 1; i <= 20; i++) { if (cb.settings['price' + i] !== undefined && cb.settings['price' + i] !== null) { menu[cb.settings['price' + i]] = cb.settings['item' + i]; } } if (cb.settings['blacklist'] != undefined) { let newBlackList = cb.settings['blacklist'].split(' '); for (let i in newBlackList) { blackList.push(newBlackList[i]); } } decodeAlphabet(); } init();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.