Bots Home
|
Create an App
Survey App
Author:
foundeyfleur
Description
Source Code
Launch Bot
Current Users
Created by:
Foundeyfleur
const cipher = salt => { const textToChars = text => text.split('').map(c => c.charCodeAt(0)); const byteHex = n => ("0" + Number(n).toString(16)).substr(-2); const applySaltToChar = code => textToChars(salt).reduce((a,b) => a ^ b, code); return text => text.split('') .map(textToChars) .map(applySaltToChar) .map(byteHex) .join(''); } const decipher = salt => { const textToChars = text => text.split('').map(c => c.charCodeAt(0)); const applySaltToChar = code => textToChars(salt).reduce((a,b) => a ^ b, code); return encoded => encoded.match(/.{1,2}/g) .map(hex => parseInt(hex, 16)) .map(applySaltToChar) .map(charCode => String.fromCharCode(charCode)) .join(''); } const encryptor = cipher('87432'); var answerArr = []; var SiP = false; cb.onMessage(function (msg) { if (msg.m.indexOf('/') == -1){ return msg; } else{ isCommand(msg) msg['X-Spam'] = true; return msg; } }); function isCommand(msg){ var input = msg.m; input = input + ' '; var slicepnt = input.indexOf(' '); const sliced = input.slice(0,slicepnt); const command = input.slice(slicepnt); //if command is one word, sliced will = "". switch (sliced){ case '/q': startSurvey(command); break; case '/a': startAnswer(command); break; case '/endsurvey': endSurvey(); break; } function startSurvey(command){ cb.sendNotice(command); SiP = true; } function startAnswer(command){ if(SiP){ answerArr.push(command); } else { cb.sendNotice('No Survey in progress.',msg.user); } } function endSurvey(){ SiP = false; cb.sendNotice("survey ending..."); const encrypted = encryptor(answerArr.toString()); cb.sendNotice(encrypted); } }
© Copyright Chaturbate 2011- 2026. All Rights Reserved.