Bots Home
|
Create an App
Silence or Hide Cam
Author:
grendel7
Description
Source Code
Launch Bot
Current Users
Created by:
Grendel7
/** * Bot: Silence or Hide Cam * Version: 1.0 * Author: grendel7 * Date: 25.11.16 */ var silenced = []; var hidden = []; var count_silenced = -1; var count_hidden = -1; var checked_silenced = false; var checked_hidden = false; var message; var silence_message = 'You are silenced!'; var hide_message = 'The cam is hidden for you!'; cb.settings_choices = [ {name:'mod_allowed', type:'choice', label:'Allow mods use commands', choice1:'yes', choice2:'no', defaultValue:'no', required:false}, {name:'greys_allowed_cam', type:'choice', label:'Allow users without tokens to watch your cam', choice1:'yes', choice2:'no', defaultValue:'no', required:false}, {name:'greys_allowed_chat', type:'choice', label:'Allow users without tokens to write in your chat', choice1:'yes', choice2:'no', defaultValue:'no', required:false}, {name: 'silence_penalty', type:'int', label:'Penalty tip to get unsilenced (0 = no penalty possible)', minValue:0, maxValue:1000, defaultValue:0}, {name: 'hide_penalty', type:'int', label:'Penalty tip to get unhidden (0 = no penalty possible)', minValue:0, maxValue:1000, defaultValue:0}, ]; cb.onEnter(function(user) { if (user['has_tokens'] || cb.greys_allowed_cam == 'yes') { cb.limitCam_addUsers([user['user']]); } }); cb.onLeave(function(user) { if (cb.limitCam_userHasAccess([user['user']])) { cb.limitCam_removeUsers([user['user']]); } }); cb.onTip(function (tip) { if (cb.settings.silence_penalty > 0 && tip['amount'] >= cb.settings.silence_penalty) { for (var i=0; i<=count_silenced; i++) { if (silenced[i] == tip['from_user']) { silenced.splice(i,1); count_silenced--; cb.sendNotice(tip['from_user'] + ' tipped a penalty of at least ' + cb.settings.silence_penalty + ' to get unsilenced!', '', '', '', ''); cb.sendNotice('You are unsilenced now!', message[1], '', '', 'bold'); } } } if (cb.settings.hide_penalty > 0 && tip['amount'] >= cb.settings.hide_penalty) { for (var i=0; i<=count_hidden; i++) { if (hidden[i] == tip['from_user']) { hidden.splice(i,1); count_hidden--; cb.limitCam_addUsers([tip['from_user']]); cb.sendNotice(tip['from_user'] + ' tipped a penalty of at least ' + cb.settings.hide_penalty + ' to get unhidden!', '', '', '', ''); cb.sendNotice('You are unhiddem now!', message[1], '', '', 'bold'); } } } }); cb.onMessage(function (msg) { if (msg['m'].indexOf("!") == 0 && (msg['user'] == cb.room_slug || (msg['is_mod'] && cb.mod_allowed == 'yes'))) { var message = msg['m'].split(' '); if (msg['m'] == '!cmd') { msg['X-Spam'] = true; cb.sendNotice('!slc name = silence \n !uslc name = unsilence \n !hdc name = hide cam \n !uhdc name = unhide cam \n !prt silenced/hidden = print name lists', msg['user'], '', '', ''); } if (message[0] == '!slc') { msg['X-Spam'] = true; check_silenced(message); if (checked_silenced == false) { count_silenced++; silenced[count_silenced] = new Object (); silenced[count_silenced] = message [1]; silenced.sort(); cb.sendNotice(message[1] + ' was silenced by ' + msg['user'] + '!', '', '', '', ''); cb.sendNotice('You are silenced now!', message[1], '', '', 'bold'); } else { checked_silenced = false; } } if (message[0] == '!uslc') { msg['X-Spam'] = true; for (var i=0; i<=count_silenced; i++) { if (silenced[i] == message[1]) { silenced.splice(i,1); count_silenced--; cb.sendNotice(message[1] + ' was unsilenced by ' + msg['user'] + '!', '', '', '', ''); cb.sendNotice('You are unsilenced now!', message[1], '', '', 'bold'); } } silenced.sort(); } if (message[0] == '!hdc') { msg['X-Spam'] = true; check_silenced(message); if (checked_silenced == false) { count_silenced++; silenced[count_silenced] = new Object (); silenced[count_silenced] = message [1]; silenced.sort(); } else { checked_silenced = false; } check_hidden(message); if (checked_hidden == false) { count_hidden++; hidden[count_hidden] = new Object (); hidden[count_hidden] = message [1]; hidden.sort(); cb.limitCam_removeUsers([message [1]]); cb.sendNotice(message[1] + ' was hidden and silenced by ' + msg['user'] + '!', '', '', '', ''); cb.sendNotice('You are hidden and silenced now!', message[1], '', '', 'bold'); } else { checked_hidden = false; } } if (message[0] == '!uhdc') { msg['X-Spam'] = true; for (var i=0; i<=count_silenced; i++) { if (silenced[i] == message[1]) { silenced.splice(i,1); count_silenced--; } } silenced.sort(); for (var i=0; i<=count_hidden; i++) { if (hidden[i] == message[1]) { hidden.splice(i,1); count_hidden--; cb.limitCam_addUsers([message[1]]); cb.sendNotice(message[1] + ' was unhidden and unsilenced by ' + msg['user'] + '!', '', '', '', ''); cb.sendNotice('You are unhidden and unsilenced now!', message[1], '', '', 'bold'); } } silenced.sort(); } if (message[0] == '!prt') { msg['X-Spam'] = true; if (message[1] == 'silenced') { for (var i=0; i<=count_silenced; i++) { cb.sendNotice(silenced[i], msg['user'], '', '', ''); } } if (message[1] == 'hidden') { for (var i=0; i<=count_hidden; i++) { cb.sendNotice(hidden[i], msg['user'], '', '', ''); } } } } if (msg['has_tokens'] || cb.greys_allowed_chat == 'yes') { for (var i=0; i<=count_silenced; i++) { if (silenced[i] == msg['user']) { msg['X-Spam'] = true; msg['m'] = silence_message; return msg; } } } else { msg['X-Spam'] = true; msg['m'] = silence_message; return msg; } }); function check_silenced(message) { for (var i=0; i<=count_silenced; i++) { if (silenced[i] == message[1]) { checked_silenced = true; } } } function check_hidden(message) { for (var i=0; i<=count_hidden; i++) { if (hidden[i] == message[1]) { checked_hidden = true; } } } function init() { if (cb.settings.silence_penalty > 0) { silence_message += ' You can unsilence yourself by tipping a penalty of at least ' + cb.settings.silence_penalty + ' tokens!' } if (cb.settings.hide_penalty > 0) { hide_message += ' You can unhide the cam by tipping a penalty of at least ' + cb.settings.hide_penalty + ' tokens!' } cb.limitCam_start(hide_message); cb.sendNotice(cb.room_slug + ' started «Silence or Hide Cam» bot by grendel7! \n If the cam ist hidden now for you, please re-enter this chatroom!', '', '', '', 'bold'); } init();
© Copyright Chaturbate 2011- 2024. All Rights Reserved.