Bots Home
|
Create an App
arthur
Author:
pollllux
Description
Source Code
Launch Bot
Current Users
Created by:
Pollllux
/* * ------ burgon by Pollllux ------ * * (Based on Blapp by Prnsvh) * * (Based on hodor by Glenn205 ) * */ // burgon var alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; var burgon_command = 'burgon'; var unburgon_command = 'unburgon'; var burgon_detail_command = 'detail'; var change_refresh_time_command = 'refresh'; var burgoned = []; function log(msg) { cb.log(msg); } function burgon(username, time, originator) { if(username == originator) { cb.chatNotice('You cannot burgon yourself ' + originator + "!", originator); } else { log(username + ' is being burgoned by ' + originator); if(username in burgoned) { cb.chatNotice(username + ' already burgoned!', originator); } else { if(username == cb.room_slug) { cb.chatNotice(originator + ' tried to burgon you!', cb.room_slug); cb.chatNotice('You cannot burgon the broadcaster!', originator); } else { var burgontime = new Date(); var timeint = parseInt(time, 10); burgoned[username] = {'time': burgontime, 'duration': timeint}; cb.chatNotice(username + ' has been burgoned by ' + originator + (timeint === 0 ? '' : ' for ' + timeint + ' seconds') + '!'); log(username + ' is now burgoned ' + (timeint === 0 ? 'indefinitely' : 'for ' + timeint + ' seconds')); } } } updateburgonerPanel(); } function unburgon(username, originator) { if(username == originator) { cb.chatNotice('You cannot unburgon yourself ' + originator + "!", originator); } else { log(username + ' is being unburgoned by ' + originator); if(username in burgoned) { delete burgoned[username]; cb.chatNotice(username + ' has been forgiven by ' + originator + ' and is no longer burgoned...'); log(username + ' is now unburgoned'); } else { cb.chatNotice(username + ' was not burgoned!', originator); } } updateburgonerPanel(); } function is_burgoned(username) { if(username in burgoned) { var burgondata = burgoned[username]; if(burgondata.duration === 0) { log('(info) ' + username + ' burgoned indefinitely'); return true; } var remaining = burgonifiedfor(username); if(remaining == 0) { log('(info) ' + username + ' released'); unburgon(username, 'the powers of justice; a.k.a. "he served his time"'); return false; } log('(info) ' + username + ' burgoned for another ' + remaining + ' seconds'); return true; } else { log('(info) ' + username + ' is not burgoned'); return false; } } function burgonifiedfor(username) { if(username in burgoned) { var burgondata = burgoned[username]; if(burgondata.duration === 0) { return -1; } var now = new Date(); var released = new Date(burgondata.time.getTime()); released.setSeconds(released.getSeconds() + burgondata.duration); return Math.max(0, Math.ceil((released.getTime() - now.getTime()) / 1000)); } return 0; } function burgonify(msg) { log('burgonify: ' + msg); var replacement = 'Couillereeee !!'; if(cb.settings.char_seq == 'random letters') { replacement = ''; for(var i = 0; i < 20; i++) { replacement += alphabet.charAt(Math.floor(Math.random() * alphabet.length)); } } var replacementl = replacement.length; var retv = ''; var modindex = 0; for(var j = 0, len = msg.length; j < len; j++) { if (msg[j] == ' ') { retv += ' '; modindex = 0; } else { if(/[.,?!;:]/.test(msg[j])) { retv += msg[j]; } else { retv += replacement[modindex%replacementl]; } modindex++; } } return retv; } function countburgoned() { var cnt = 0; for(var prop in burgoned) { if(is_burgoned(prop)) { cnt++; } } return cnt; } function burgonDetails(user) { log('sending details to ' + user); cb.chatNotice('== burgon! ' + countburgoned() + ' users burgoned ==', user); for(var prop in burgoned) { if (burgoned.hasOwnProperty(prop)) { var remaining = burgonifiedfor(prop); cb.chatNotice(prop + ' is burgoned ' + (remaining > 0 ? 'for another ' + remaining + ' seconds' : 'indefinatily'), user) } } } function updateburgonerPanel() { cb.drawPanel(); } // hooks cb.settings_choices = [ {name:'allow_burgon', label:'Allowed to burgon', type:'choice', choice1:'allow broadcaster to burgon', choice2:'allow broadcaster and mods to burgon'}, {name:'char_seq', label:'burgon-type', type:'choice', choice1:'burgon', choice2:'random letters'}, //{name:'allow_tip_for_freedom', label:'Tip for freedom', type:'choice', choice1:'yes', choice2:'no'}, {name:'refresh_time', label:'Refresh', type:'choice', choice1:'very fast (every second - might cause lagging in busy rooms)', choice2:'fast (every 5 seconds)', choice3:'medium (every 10 seconds)', choice4:'slow (every 30 seconds)', choice5:'very slow (every 60 seconds - almost no overhead)', choice6:'off'} ]; cb.onDrawPanel(function (user) { if(user == cb.room_slug) // broadcaster panel --> TODO: modcheck (currently not supported) { return { 'template':'3_rows_of_labels', 'row1_label':'Users burgoned:', 'row1_value':countburgoned(), 'row2_label':'To burgon:', 'row2_value':'/burgon username [time]', 'row3_label':'To unburgon:', 'row3_value':'/unburgon username' }; } else if(is_burgoned(user)) // burgoned panel { var remaining = burgonifiedfor(user); return { 'template':'3_rows_11_21_31', 'row1_value':'', 'row2_value':'You are burgoned' + (remaining > 0 ? ' for another ' + remaining + ' seconds!' : '!'), 'row3_value':'' }; } else // regular panel { return { 'template':'3_rows_11_21_31', 'row1_value':'burgon mode:', 'row2_value':(cb.settings.allow_burgon == 'allow broadcaster and mods to burgon') ? 'Broadcaster and mods can burgon.' : 'Only broadcaster can burgon.', 'row3_value':'' }; } }); cb.onMessage(function (msg) { // vars for ease of use var m = msg['m']; var u = msg['user']; // check for action if(m[0] == '/') { // don't print commands msg['X-Spam'] = true; // check if user can perform actions var broadcasteronly = (cb.settings.allow_burgon == 'allow broadcaster to burgon'); if(broadcasteronly && u != cb.room_slug) { cb.chatNotice('Only the broadcaster can burgon!', u); } else if(!broadcasteronly && !msg['is_mod'] && u != cb.room_slug) { cb.chatNotice('Only the broadcaster and moderators can burgon!', u); } else { var command = m.substr(1); var commandparts = command.split(' '); if(commandparts[0] == burgon_command && commandparts.length > 1) // burgon { var timeout = 0; if(commandparts.length > 2 && !isNaN(commandparts[2])) { timeout = commandparts[2]; } burgon(commandparts[1], timeout, u); } else if(commandparts[0] == unburgon_command && commandparts.length > 1) // UNburgon { unburgon(commandparts[1], u); } else if(commandparts[0] == burgon_detail_command) // DETAIL { burgonDetails(u); } else if(commandparts[0] == change_refresh_time_command && commandparts.length > 1 && !isNaN(commandparts[1])) // REFRESH { updateRefreshTime(commandparts[1]); } } } else if(is_burgoned(u)) { m = burgonify(m); var remaining = burgonifiedfor(u); if(remaining > 0) { cb.chatNotice('You are burgoned for another ' + remaining + ' seconds!', u); } } msg['m'] = m; return msg; }); // auto update panel every X seconds var updatetime = 0; function initAutoUpdate() { if(cb.settings.refresh_time == 'very fast (every second - might cause lagging in busy rooms)') { updatetime = 1000; } else if(cb.settings.refresh_time == 'fast (every 5 seconds)') { updatetime = 5000; } else if(cb.settings.refresh_time == 'medium (every 10 seconds)') { updatetime = 10000; } else if(cb.settings.refresh_time == 'slow (every 30 seconds)') { updatetime = 30000; } else if(cb.settings.refresh_time == 'very slow (every 60 seconds - almost no overhead)') { updatetime = 60000; } if(updatetime > 0) { setTimeout(autoUpdateburgonerPanel, updatetime); } } function updateRefreshTime(seconds) { var restart = (updatetime == 0); seconds = Math.max(0, parseInt(seconds)); updatetime = seconds * 1000; if(updatetime > 0) { cb.chatNotice('burgonscreen will update every ' + seconds + ' seconds.'); if(restart) { autoUpdateburgonerPanel(); } } else { cb.chatNotice('burgonscreen will not update automatically, updates will happen if actions are performed.'); } } function autoUpdateburgonerPanel() { updateburgonerPanel(); if(updatetime > 0) { setTimeout(autoUpdateburgonerPanel, updatetime); } } initAutoUpdate();
© Copyright Chaturbate 2011- 2026. All Rights Reserved.