Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * roboJar: A turntable.fm bot. Chris "inajar" Vickery <chrisinajar@gmail.com>
- *
- * Redistribution and use in source, minified, binary, or any other forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name, roboJar, nor the names of its contributors may be
- * used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * Needs more cat facts.
- *
- */
- var SlotTimer = function (jj) {
- var s = this;
- this.j=jj;
- var j=jj;
- this.slots = [];
- //this.j.putDoc('slottimer', { version: 0 }, function(s, doc) {});
- this.j.getDoc('slottimer', function(s, doc) {
- if (s.j.isset(doc)) {
- s.db = doc;
- s.j.log("yeah, got my shit");
- } else {
- j.log("Oh fuck...");
- return;
- }
- if (!s.j.isset(s.db.version)) {
- s.db = { version: 0 };
- }
- }, this);
- j.on(this, 'rem_dj', function (d, s) {
- var j = s.j;
- s.slots.push((new Date()).getTime());
- }, this);
- j.on(this, 'add_dj', function (d, s) {
- var j = s.j;
- if (s.slots.length < 1)
- return;
- var user = d.user[0];
- var t = (((new Date()).getTime())-s.slots[0]);
- var idle = j.users[user.userid].getIdleTime();
- s.slots.splice(0,1);
- j.log ("Open slots: " +s.slots.length);
- var text = "DJ Slot was open for " + (t>1000 ? (t/1000)+" seconds." : t+" msecs.");
- if (s.slots.length == 0 && t < 1000) {
- if (idle > (1000*60*15)) {
- // check for autodj bullshittery
- text = '@' + user.name + ' pulled a bullshit move and took a seat in ' + t + 'ms while ' + Math.round(idle/1000/60) + ' minutes idle';
- // User specific code goes here.... //
- } else if (t > 500 ) { // 1000-500
- text = user.name + ' gets a nice grab in ' + t + 'msecs';
- } else if (t > 400 ) { // 400-500
- text = user.name + ' spines the seat in ' + t + 'msecs';
- } else if (t > 300 ) { // 300-500
- text = user.name + ' clickhaxx at ' + t + 'msecs';
- } else { // 0-300
- text = user.name + ' poops on the room and steals the seat in: ' + t + 'msecs.';
- }
- }
- j.speak(text);
- if (!j.isset(s.db[user.userid]))
- s.db[user.userid] = [];
- s.db[user.userid].push({time: t, idle: idle});
- }, this);
- };
- SlotTimer.prototype.unload = function(h, d) {
- h(d);
- };
- module.exports = SlotTimer;
Add Comment
Please, Sign In to add comment