Bots Home
|
Create an App
GTtest
Author:
gtbroadcast
Description
Source Code
Launch Bot
Current Users
Created by:
Gtbroadcast
/* Title: "Gifttoken tipper with tipmenu" bot Author: michal73 version 1.0 (20-12-2018) Contains a fork of : Title: "Tip Menu Single Line Plus" bot Author: badbadbubba version 1.0.2 (09/09/2016) --------------------------------------------------------------- If forking (parts of) this script do not obfuscate the code !! */ var HEART = '\u2665'; // ♥ BDIAMOND = '\u2666'; // ♦ BSTAR = '\u2605'; // ★ var tip_amt = 0; var separator_char = "| "; var msg; var MAXITEMS=20; var tipmenuprice = []; var tipmenuitem= []; var MAXSEP = 9; var GTusers = []; // array of users with gifttokens var GTtokens = []; // gifttokens amount of users var GTmsg=""; // complete message without gt/ and trailing spaces var GTuser=""; // user sending the command var GTname=""; // name out of the message var GTamount=""; // token amount out of the message separators = [ {label:'Hearts',shortcut:':heart2'}, {label:'Glitter',shortcut:':pixelglitter'}, {label:'Flowers',shortcut:':tinyflower2'}, {label:'Bow',shortcut:':bluebow'}, {label:'Hearts2',shortcut:':pixelheart'}, {label:'Smiley',shortcut:':smile'}, {label:'Text Heart',shortcut:HEART}, {label:'Text Diamond',shortcut:BDIAMOND}, {label:'Text Star',shortcut:BSTAR}, ]; cb.settings_choices = [ {name: 'sepchar', type: 'choice', choice1: 'Vertical Bar', choice2: 'Hearts', choice3:'Glitter',choice4:'Flowers',choice5:'Bow',choice6:'Hearts2',choice7:'Smiley',choice8:'Text Heart', choice9:'Text Diamond', choice10:'Text Star', defaultValue: 'Vertical Bar', label: "Separator character"}, {name:'item1', type:'str', label:'Item 1 (eg 10--flash tits)',}, {name:'item2', type:'str', required: false, label:'Item 2',}, {name:'item3', type:'str', required: false, label:'Item 3',}, {name:'item4', type:'str', required: false, label:'Item 4',}, {name:'item5', type:'str', required: false, label:'Item 5',}, {name:'item6', type:'str', required: false, label:'Item 6',}, {name:'item7', type:'str', required: false, label:'Item 7',}, {name:'item8', type:'str', required: false, label:'Item 8',}, {name:'item9', type:'str', required: false, label:'Item 9',}, {name:'item10', type:'str', required: false, label:'Item 10',}, {name:'item11', type:'str', required: false, label:'Item 11',}, {name:'item12', type:'str', required: false, label:'Item 12',}, {name:'item13', type:'str', required: false, label:'Item 13',}, {name:'item14', type:'str', required: false, label:'Item 14',}, {name:'item15', type:'str', required: false, label:'Item 15',}, {name:'item16', type:'str', required: false, label:'Item 16',}, {name:'item17', type:'str', required: false, label:'Item 17',}, {name:'item18', type:'str', required: false, label:'Item 18',}, {name:'item19', type:'str', required: false, label:'Item 19',}, {name:'item20', type:'str', required: false, label:'Item 20',}, {name:'noticecolor', type:'str', label:'Notice color (html code default red #FF0000)', defaultValue: '#FF0000'}, {name: 'chat_ad', type:'int', minValue: 1, maxValue: 999, defaultValue: 1, label: 'Delay in minutes between notice being displayed (minimum 1)'} ]; /* gift tips commands general: gt/ amount tipnote gt/ help (send by user) gt/ help (send by broadcaster) gt/ give amount user gt/ clear user gt/ clear all gt/ list gt/ number */ if (typeof(Storage) == "undefined") { GTsendmsg("no storage","") } cb.onMessage(function (message) { if (message["m"].split("/")[0]=="gt"){ GTmsg=message["m"].split("/")[1].trim(); GTuser=message["user"]; message["X-Spam"]=true; GTdecode(); return message; }else{ return message; } }); cb.onTip(function (tip){ tipped(parseInt(tip['amount']),tip['from_user']); }); cb.onEnter(function(user) { if (GTusers.indexOf(user['user'])!=-1){ GTsendmsg("Welcome "+user['user']+". You have "+GTtokens[GTusers.indexOf(user['user'])]+" Gifttokens.\nType gt/ help for instruction on how to use them. ",user['user']); } }); function GTdecode(){ switch(GTmsg.split(" ")[0]){ case "list": GTlist(); break; case "help": GThelp(); break; case "clear": GTclear(); break; case "give": GTgive(); break; default: GTtip(); } } function GTgive(){ if (GTuser!=cb.room_slug){GTerror0();return;} // invalid command for not broadcaster GTamount=GTmsg.split(" ")[1]; if (+GTamount=="NaN"){GTerror1();return;} // not a number if (parseInt(GTamount)!= +GTamount){GTerror1();return;} // messed up number if (Math.abs(GTamount) != +GTamount){GTerror1();return;} // negative number if (+GTamount === 0){GTerror1();return;} // zero number GTamount=+GTamount; // string to real number if (!GTmsg.split(" ")[2]){GTerror2();return;} // no name given GTname=GTmsg.split(" ")[2]; if (GTusers.indexOf(GTname)==-1){ // new user , make 0 token name GTusers.push(GTname); GTtokens.push(0); } GTtokens[GTusers.indexOf(GTname)]=GTtokens[GTusers.indexOf(GTname)]+GTamount; // add tokens to user GTsucces1(); // send message to user GTsucces2(); // send message to broadcaster } function GTtip(){ GTamount=GTmsg.split(" ")[0]; if (+GTamount=="NaN"){GTerror0();return;} // not a number - invalid command if (parseInt(GTamount)!= +GTamount){GTerror0();return;} // messed up number if (Math.abs(GTamount) != +GTamount){GTerror0();return;} // negative number if (+GTamount === 0){GTerror0();return;} // zero number GTamount=+GTamount; // string to real number if (GTusers.indexOf(GTuser)==-1){GTerror3();return;} // you have no tokens , not in array if (GTamount>GTtokens[GTusers.indexOf(GTuser)]){GTerror4();return;} // not enough gifttokens GTtokens[GTusers.indexOf(GTuser)]=GTtokens[GTusers.indexOf(GTuser)]-GTamount; // substract the tokens GTsucces3(); // tip message in chat GTsucces4(); // tokens left to user GTsucces5(); // tipnote and tokens left to broadcaster if (GTtokens[GTusers.indexOf(GTuser)]===0){ // remove user out array if at 0 gifttokens GTtokens.splice(GTusers.indexOf(GTuser),1); GTusers.splice(GTusers.indexOf(GTuser),1); } tipped (GTamount,GTuser); // send tip to tipmenu } function GTclear(){ if (GTuser!=cb.room_slug){GTerror0();return;} // invalid command if (GTusers.length===0){GTerror6();return;} // no gift users , empty array if (!GTmsg.split(" ")[1]){GTerror2();return;} // no 2nd command , username GTname=GTmsg.split(" ")[1]; if (GTname!="all"){ if (GTusers.indexOf(GTname)==-1){GTerror5();return;} // not in userlist GTrevoke(); }else{ while (GTusers.length != 0){ GTname=GTusers[0]; GTrevoke(); } } } function GTrevoke(){ // needs GTname ! GTtokens.splice(GTusers.indexOf(GTname),1); GTusers.splice(GTusers.indexOf(GTname),1); GTsucces6(); // to user GTsucces7(); // to broadcaster } function GTlist(){ if (GTuser!=cb.room_slug){GTerror0();return;} // invalid command if (GTusers.length===0){GTerror6();return;} // no gift users var n=0; for (n=0; n<GTusers.length; n++){ GTsendmsg(GTusers[n]+" - "+GTtokens[n]+" Gifttokens",cb.room_slug); } } var GThelp1="GiftTokens help for the broadcaster.\n" +"gt/ help - this help menu.\n" +"gt/ give amount user - e.g. 'gt/ give 200 michal73' will give 200 Gifttokens to michal73.\n" +"The Gifttokens will add up with the amount he/she already got.\n" +"gt/ clear user - will clear all Gifttokens of that user.\n" +"gt/ clear all - will clear all Gifttokens of all users.\n" +"gt/ list - will give a list of all users with Gifttokens and the amount they got.\n" +"Users can tip using : 'gt/ amount tipnote' (tipnote is optional).\n" +"The tipmenu will respond the same way as if real tokens are given.\n" +"Please note that lovence toys will not respond on Gifttokens and there will be no tipsound."; var GThelp2="GiftTokens help.\n" +"If the broadcaster has given you GiftTokens you can use them by typing 'gt/ amount tipnote'\n" +"For example: 'gt/ 100 i love you' will send 100 Gifttokens with the tipnote 'i love you'.(tipnote is optional)\n" +"The tipmenu will respond the same way as if real tokens are given.\n" +"Please note that lovence toys will not respond on Gifttokens and there will be no tipsound."; function GThelp(){ if (GTuser==cb.room_slug){ GTsendmsg(GThelp1,cb.room_slug); }else{ GTsendmsg(GThelp2,GTuser); } } function GTerror0(){ GTsendmsg("Not a valid GiftTokens command, type gt/ help for help.",GTuser); } function GTerror1(){ GTsendmsg("No valid GiftTokens amount.",cb.room_slug); } function GTerror2(){ GTsendmsg("No user name given.",cb.room_slug); } function GTerror3(){ GTsendmsg("You have no Gifttokens !",GTuser); } function GTerror4(){ GTsendmsg("No valid GiftTokens amount, type gt/ help for help.",GTuser); } function GTerror4(){ GTsendmsg("You only have "+GTtokens[GTusers.indexOf(GTuser)]+" Gifttokens. You can not tip "+GTamount+" Gifttokens.",GTuser); } function GTerror5(){ GTsendmsg(GTmsg.split(" ")[1]+" does not have Gifttokens.",cb.room_slug); } function GTerror6(){ GTsendmsg("There are no Gifttokens users.",cb.room_slug); } function GTsucces1(){ GTsendmsg(cb.room_slug+" gave you Gifttokens, you now have "+ GTtokens[GTusers.indexOf(GTname)]+" Gifttokens.\n Use 'gt/ amount tipnote' to spend them or type 'gt/ help' for help.",GTname); } function GTsucces2(){ GTsendmsg("You gave "+GTamount+" Gifttokens to "+GTname+". He now got "+ GTtokens[GTusers.indexOf(GTname)]+" Gifttokens.",cb.room_slug); } function GTsucces3(){ cb.sendNotice(GTuser+ " Tipped "+GTmsg.split(" ")[0]+" Gifttokens","","#ffff33","#000000","bold",""); } function GTsucces4(){ GTsendmsg("Thank you for tipping, you have "+GTtokens[GTusers.indexOf(GTuser)]+" Gifttokens left.",GTuser); } function GTsucces5(){ GTsendmsg(GTuser+" tipped you: "+GTmsg+ " ("+GTtokens[GTusers.indexOf(GTuser)]+" Gifttokens left).",cb.room_slug); } function GTsucces6(){ GTsendmsg(cb.room_slug+" revoked your Gifttokens , you have no more Gifttokens.",GTname); } function GTsucces7(){ GTsendmsg("You revoked "+GTname+"'s Gifttokens.",cb.room_slug); } function GTsendmsg(GTstring,GTsendto){ // send message with small delay so message will not appear before command setTimeout(function(){ cb.sendNotice(GTstring,GTsendto,"","","bold",""); }, 800); } // end gifttoken tipper , start tipmenu function tipped(tip_amt,tip_user){ for (var i = 1; i <= MAXITEMS; i++) { if (tip_amt == tipmenuprice[i]) { cb.sendNotice(tip_user + ' tipped for ' + tipmenuitem[i],'','',cb.settings['noticecolor'],'bold'); } } } function chatAd() { if (msg!='Tip Menu: ') { cb.sendNotice(msg,'','',cb.settings['noticecolor'],'bold'); } cb.setTimeout(chatAd, (cb.settings.chat_ad * 60000)); } cb.setTimeout(chatAd, (cb.settings.chat_ad * 60000)); function init() { for (i=0;i<=MAXSEP-1;i++) { if (cb.settings['sepchar'] == separators[i].label) { separator_char = separators[i].shortcut + ' '; } } msg = 'Tip Menu: '; for (i=1;i<=MAXITEMS;i++) { var tmp; tmp=cb.settings['item' + i]; if (tmp) { var arr= tmp.split('--'); if (arr[1]===undefined) { cb.sendNotice('Error-You need two dashes to separate the tip amount and menu item for item no '+ i,'','',cb.settings['noticecolor'],'bold'); } else { var amt=parseInt(arr[0]); if (amt>0) { tipmenuprice[i]=amt; tipmenuitem[i]=arr[1]; if (i>=2) { msg += separator_char; } msg += arr[1] + '(' + amt + ') '; } } } } if (msg!= 'Tip Menu: ') { cb.sendNotice(msg,'','',cb.settings['noticecolor'],'bold'); } else { cb.sendNotice('Error-No menu items found','','',cb.settings['noticecolor'],'bold'); } } init();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.