Bots Home
|
Create an App
asshat
Author:
iloveumore
Description
Source Code
Launch Bot
Current Users
Created by:
Iloveumore
/* * ------ Asshat by ILoveUMore ------ * */ // asshat var phrases = "I have a tiny dick, My ass hurts, I can fuck fish, 2+2=peanut butter, I lost my virginity to a mule, I live in mommys basement, Im a asshat, Im a moron"; var asshat_command = 'asshat'; var unasshat_command = 'unasshat'; var asshat_detail_command = 'detail'; var change_refresh_time_command = 'refresh'; var asshatted = []; function log(msg) { cb.log(msg); } function asshat(username, time, originator) { if(username == originator) { cb.chatNotice('You cannot asshat yourself ' + originator + "!", originator); } else { log(username + ' is being asshatted by ' + originator); if(username in asshatted) { cb.chatNotice(username + ' already asshatted!', originator); } else { if(username == cb.room_slug) { cb.chatNotice(originator + ' tried to asshat you!', cb.room_slug); cb.chatNotice('You cannot asshat the broadcaster!', originator); } else { var asshattime = new Date(); var timeint = parseInt(time, 10); asshatted[username] = {'time': asshattime, 'duration': timeint}; cb.chatNotice(username + ' has been asshated by ' + originator + (timeint === 0 ? '' : ' for ' + timeint + ' seconds') + '!'); log(username + ' is now asshatted ' + (timeint === 0 ? 'indefinitely' : 'for ' + timeint + ' seconds')); } } } updateAsshatterPanel(); } function unasshat(username, originator) { if(username == originator) { cb.chatNotice('You cannot unasshat yourself ' + originator + "!", originator); } else { log(username + ' is being unasshatted by ' + originator); if(username in asshatted) { delete asshatted[username]; cb.chatNotice(username + ' has been forgiven by ' + originator + ' and is no longer asshatted...'); log(username + ' is now unasshatted'); } else { cb.chatNotice(username + ' was not asshatted!', originator); } } updateAsshatterPanel(); } function is_asshatted(username) { if(username in asshatted) { var asshatdata = asshatted[username]; if(asshatdata.duration === 0) { log('(info) ' + username + ' asshatted indefinitely'); return true; } var remaining = asshatifiedfor(username); if(remaining == 0) { log('(info) ' + username + ' released'); unasshat(username, 'the force of the Jedi; a.k.a. "he learned his lesson"'); return false; } log('(info) ' + username + ' asshatted for another ' + remaining + ' seconds'); return true; } else { log('(info) ' + username + ' is not asshatted'); return false; } } function asshatifiedfor(username) { if(username in asshatted) { var asshatdata = asshatted[username]; if(asshatdata.duration === 0) { return -1; } var now = new Date(); var released = new Date(asshatdata.time.getTime()); released.setSeconds(released.getSeconds() + asshatdata.duration); return Math.max(0, Math.ceil((released.getTime() - now.getTime()) / 1000)); } return 0; } function asshatify(msg) { log('asshatify: ' + msg); var replacement = 'asshat'; if(cb.settings.char_seq == 'random phrases') { replacement = ''; for(var i = 0; i < 20; i++) { replacement += phraes.charAt(Math.floor(Math.random() * phrase.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 countAsshatted() { var cnt = 0; for(var prop in asshatted) { if(is_asshatted(prop)) { cnt++; } } return cnt; } function asshatDetails(user) { log('sending details to ' + user); cb.chatNotice('== Asshat! ' + countAsshatted() + ' users asshatted ==', user); for(var prop in asshatted) { if (asshatted.hasOwnProperty(prop)) { var remaining = asshatifiedfor(prop); cb.chatNotice(prop + ' is asshatted ' + (remaining > 0 ? 'for another ' + remaining + ' seconds' : 'indefinatily'), user) } } } function updateAsshatterPanel() { cb.drawPanel(); } // hooks cb.settings_choices = [ {name:'allow_asshat', label:'Allowed to asshat', type:'choice', choice1:'allow broadcaster to asshat', choice2:'allow broadcaster and mods to asshat'}, {name:'char_seq', label:'Asshat-type', type:'choice', choice1:'I have a tiny dick', choice2:'My ass hurts'}, //{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 asshatted:', 'row1_value':countAsshatted(), 'row2_label':'To asshat:', 'row2_value':'/asshat username [time]', 'row3_label':'To unasshat:', 'row3_value':'/unasshat username' }; } else if(is_asshatted(user)) // asshatted panel { var remaining = asshatifiedfor(user); return { 'template':'3_rows_11_21_31', 'row1_value':'', 'row2_value':'You are asshatted' + (remaining > 0 ? ' for another ' + remaining + ' seconds!' : '!'), 'row3_value':'' }; } else // regular panel { return { 'template':'3_rows_11_21_31', 'row1_value':'Asshat mode:', 'row2_value':(cb.settings.allow_asshat == 'allow broadcaster and mods to asshat') ? 'Broadcaster and mods can asshat.' : 'Only broadcaster can asshat.', '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_asshat == 'allow broadcaster to asshat'); if(broadcasteronly && u != cb.room_slug) { cb.chatNotice('Only the broadcaster can asshat!', u); } else if(!broadcasteronly && !msg['is_mod'] && u != cb.room_slug) { cb.chatNotice('Only the broadcaster and moderators can asshat!', u); } else { var command = m.substr(1); var commandparts = command.split(' '); if(commandparts[0] == blapp_command && commandparts.length > 1) // ASSHAT { var timeout = 0; if(commandparts.length > 2 && !isNaN(commandparts[2])) { timeout = commandparts[2]; } asshat(commandparts[1], timeout, u); } else if(commandparts[0] == unasshat_command && commandparts.length > 1) // UNASSHAT { unasshat(commandparts[1], u); } else if(commandparts[0] == asshat_detail_command) // DETAIL { asshatDetails(u); } else if(commandparts[0] == change_refresh_time_command && commandparts.length > 1 && !isNaN(commandparts[1])) // REFRESH { updateRefreshTime(commandparts[1]); } } } else if(is_asshatted(u)) { m = asshatify(m); var remaining = asshatifiedfor(u); if(remaining > 0) { cb.chatNotice('You are asshatted 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(autoUpdateAsshatterPanel, updatetime); } } function updateRefreshTime(seconds) { var restart = (updatetime == 0); seconds = Math.max(0, parseInt(seconds)); updatetime = seconds * 1000; if(updatetime > 0) { cb.chatNotice('Asshatscreen will update every ' + seconds + ' seconds.'); if(restart) { autoUpdateAsshatterPanel(); } } else { cb.chatNotice('Asshatscreen will not update automatically, updates will happen if actions are performed.'); } } function autoUpdateAsshatterPanel() { updateAsshatterPanel(); if(updatetime > 0) { setTimeout(autoUpdateAsshatterPanel, updatetime); } } initAutoUpdate();
© Copyright Chaturbate 2011- 2026. All Rights Reserved.