Bots Home
|
Create an App
tiptest
Author:
staringatstars
Description
Source Code
Launch Bot
Current Users
Created by:
Staringatstars
cb.settings_choices = [ {name: 'tipOn', type: 'choice', choice1: 'on', choice2: 'off', defaultValue: 'off', label: "Tip menu on"}, {name: 'tipMessageTime', label: 'Enter the frequency with you would like the msg displayed in mins', type: 'int', minValue: 1, maxValue: 1000000, defaultValue: 5}, {name:'tipTextcolour', type:'str', label:'Notice color (html code default red #FF0000)', defaultValue: '#494949'}, {name:'tipNoticecolour', type:'str', required: false, label:'Notice color (html code)'}, {name:'tipSeparator', type:'str', defaultValue: '/', label:"The separator for the tip menu"}, {name:'mainTip', type:'str', required: false, label:"Tip items to be displayed in rotating tip menu. Should be entered as - text,tip,green tip each group should be seperated by : example :- boobs,30,20:booty,50,35 ",}, {name:'otherTip', type:'str', required: false, label:"Other tip items. Should be entered as - text,tip,green tip,gif (the gif and green tip are optional) each group should be seperated by / example:- boobs,30,20/booty,50,35,:booty ",} ]; var mainTipList = []; var tipMOn = 'on'; var tipTime = 1000; var fulTipList = []; var otherTipList = []; function isGreen(msg) { return (msg['is_mod']); } // checks if name in a 2d list function in2DList (name) { for(var i = 0; i < tippersList.length; i++) { if (tippersList[i][0] == name) { return i; } } return -1; } function errorMsg (msg) { cb.sendNotice(msg); } function addtipListItemMain (name,mPrice,gPrice,gif) { mainTipList.push([name,mPrice,gPrice,gif]); } function addtipListItemOther (name,mPrice,gPrice,gif) { otherTipList.push([name,mPrice,gPrice,gif]); } function menuBuild(arr,x) { arr.sort(function(a, b) { var z = a[x]; var y = b[x]; return z - y; }); var newArr = []; for (var i = 0; i < arr.length; i++) { var a = '' + arr[i][0] + ' for ' + arr[i][x] + 'tks '; newArr.push(a); } return newArr; } function tipNotifier() { if (cb.settings['tipOn'] == 'on') { var arr = menuBuild(mainTipList,1); a = ' ' + arr[0]; for(var i = 1; i < arr.length; i++) { a = a + cb.settings['tipSeparator'] + arr[i]; } cb.chatNotice('Tip Menu: ' + a + ' Or, Type #menu to see the full menu.','',cb.settings['tipNoticecolour'],cb.settings['tipTextcolour'],'bold'); } } function msgParse(msg) { var msgArray = msg['m'].split(' '); //turn the message into an array var name = msg['user']; var modelName = cb.room_slug; var isModel = (name == cb.room_slug); var green = isGreen(msg); if (msgArray[0].charAt(0) == '#') { switch (msgArray[0]) { case '#menu': msg['X-Spam'] = true; if (green) { fullListNotice(2,name); } else { fullListNotice(1,name); } break; } } } function msgBuild(arr) { var m = arr[0]; for (i=1; i<arr.length;i++) { m = m + ' \n ' + arr[i]; } return m; } function fullListNotice(x,user) { var arr = menuBuild(fulTipList,x); cb.chatNotice(msgBuild(arr),user,cb.settings['tipNoticecolour'],cb.settings['tipTextcolour'],'bold'); } function amountInTipList(tipAmount,position) { for (var i = 0; i < fulTipList.length; i++) { if (fulTipList[i][position] == parseInt(tipAmount)) { return i; } } return -1; } function callme() { if (tipMOn == 'on') { tipNotifier(); cb.setTimeout(callme,tipTime); } } function mergeLists() { var a = []; for (var i =0; i < otherTipList.length; i++) { a.push(otherTipList[i]); } for (var i =0; i < mainTipList.length; i++) { a.push(mainTipList[i]); } a.sort(function(a, b) { var x = a[1]; var y = b[1]; return x - y; }); fulTipList = a; } //populates tip list if (cb.settings.mainTip) { var tempList = cb.settings.mainTip.split('/'); for (var i = 0; i < tempList.length; i++) { tempList2 = tempList[i].split(',') if (tempList2.length < 3) { errorMsg(("list too short " + String(tempList2.length) + ' ' + tempList2)); break; } if (tempList2.length > 4) { errorMsg(("list too long " + String(i) + String(tempList2.length) + ' ' + tempList2)); break; } var a = tempList2[0]; var b = tempList2[1]; var c = tempList2[2]; var d = ''; if (tempList2.length == 4) { d = tempList2[3]; } addtipListItemMain(a,b,c,d); } mainTipList.sort(function(a, b) { var x = a[1]; var y = b[1]; return x - y; }); } if (cb.settings.otherTip) { var tempList = cb.settings.otherTip.split('/'); for (var i = 0; i < tempList.length; i++) { tempList2 = tempList[i].split(',') if (tempList2.length < 3) { errorMsg(("list too short " + String(tempList2.length) + ' ' + tempList2)); break; } if (tempList2.length > 4) { errorMsg(("list too long " + String(i) + String(tempList2.length) + ' ' + tempList2)); break; } var a = tempList2[0]; var b = tempList2[1]; var c = tempList2[2]; var d = ''; if (tempList2.length == 4) { d = tempList2[3]; } addtipListItemOther(a,b,c,d); } otherTipList.sort(function(a, b) { var x = a[1]; var y = b[1]; return x - y; }); } if (cb.settings.tipOn) { tipMOn = cb.settings['tipOn']; } if (cb.settings.tipMessageTime) { tipTime = ((cb.settings['tipMessageTime']) * 60000); } mergeLists(); cb.setTimeout(callme(),tipTime); cb.onTip(function (tip) { var s = 1; if (tip['from_user_is_mod']) { s = 2; } var a = amountInTipList(tip['amount'],s); if (a != -1) { var msg = tip['from_user'] + ' tipped for ' + fulTipList[a][0]; cb.chatNotice(msg,'',cb.settings['tipNoticecolour'],cb.settings['tipTextcolour'],'bold'); } }); cb.onMessage(function (msg) { msgParse(msg); });
© Copyright Chaturbate 2011- 2024. All Rights Reserved.