Permalink
Browse files

[refactor] Adjusted permissions to use dynamic rank names.

  • Loading branch information...
1 parent 174b7da commit bc2bdf00a618d2b88bcf85294df3229b6925e098 @AvianFlu AvianFlu committed Oct 25, 2011
Showing with 25 additions and 20 deletions.
  1. +5 −5 lib/plugins/twitter.js
  2. +20 −15 lib/triggers.js
View
@@ -9,7 +9,7 @@
var twitter = exports;
twitter.tweet = function (data, command) {
- if (!data.friend) { return false; }
+ if (!data[this.ranks[2]]) { return false; }
var text = command.slice(1).join(' ');
if (text.length > 140) {
this.emit('sendMsg', {
@@ -21,22 +21,22 @@ twitter.tweet = function (data, command) {
}
twitter.stoptweets = function (data, command) {
- if (!data.employee) {return false; }
+ if (!data[this.ranks[1]]) {return false; }
this.emit('stopTweets', null);
}
twitter.starttweets = function (data, command) {
- if (!data.employee) { return false; }
+ if (!data[this.ranks[1]]) { return false; }
this.emit('startTweets', null);
}
twitter.report = function (data, command) {
- if (!data.employee) { return false; }
+ if (!data[this.ranks[1]]) { return false; }
this.emit('report', {name: command[1], to: data.to});
}
twitter.block = function (data, command) {
- if (!data.employee) { return false; }
+ if (!data[this.ranks[1]]) { return false; }
this.emit('block', {name: command[1], to: data.to});
}
View
@@ -11,12 +11,17 @@ var fs = require('fs');
var triggers = module.exports = {
'version' : function (data, command) {
- if (!data.friend) { return false; }
- this.emit('sendMsg', { dest: data.to, msg: this.config.get('version')});
+ if (!data[this.ranks[2]]) { return false; }
+ this.emit('sendMsg', {
+ dest: data.to,
+ msg: 'Kohai ' + this.config.get('version')
+ + ' running on Node.JS '
+ + process.version
+ });
},
'channel': function (data, command) {
- if (!data.admin) { return false; }
+ if (!data[this.ranks[0]]) { return false; }
if (!this.channels[command[1]]) {
return this.emit('sendMsg', {
dest: data.to,
@@ -33,59 +38,59 @@ var triggers = module.exports = {
},
'join' : function (data, command) {
- if (!data.admin) { return false; }
+ if (!data[this.ranks[0]]) { return false; }
this.emit('join', command[1]);
},
'part' : function (data, command) {
- if (!data.admin) { return false; }
+ if (!data[this.ranks[0]]) { return false; }
var channel = command[1] || data.to;
this.emit('part', channel);
},
'insult' : function (data, command) {
- if (!data.friend) { return false; }
+ if (!data[this.ranks[2]]) { return false; }
var n = Math.floor(Math.random() * this.insults.length),
target = command.slice(1).join(' ').replace(/[^\w\d\s]/g, '');
this.emit('sendMsg', { dest: data.to, msg: this.insults[n].replace('%%', target) })
},
'voice' : function (data, command) {
- if (!data.admin) { return false }
+ if (!data[this.ranks[0]]) { return false }
var dest = command[2] || data.to;
this.emit('sendMsg', { dest: dest, msg: 'I declare you cool, ' + command[1] + '!' });
this.emit('command', 'mode ' + dest + ' +v ' + command[1]);
},
'devoice' : function (data, command) {
- if (!data.admin) { return false }
+ if (!data[this.ranks[0]]) { return false }
var dest = command[2] || data.to;
this.emit('sendMsg', { dest: dest, msg: 'No more voice for you, ' + command[1] + '!' });
this.emit('command', 'mode ' + dest + ' -v ' + command[1]);
},
'op' : function (data, command) {
- if (!data.admin) { return false }
+ if (!data[this.ranks[0]]) { return false }
var dest = command[2] || data.to;
this.emit('command', 'mode ' + dest + ' +o ' + command[1]);
},
'deop' : function (data, command) {
- if (!data.admin) { return false }
+ if (!data[this.ranks[0]]) { return false }
var dest = command[2] || data.to;
this.emit('command', 'mode ' + dest + ' -o ' + command[1]);
},
'kick' : function (data, command) {
- if (!data.employee) { return false; }
+ if (!data[this.ranks[1]]) { return false; }
var dest = command[2] || data.to;
console.log(command[1], ' has been kicked from ', dest);
this.emit('sendMsg', { dest: dest, msg: 'kohai says GTFO!' });
this.emit('command', 'kick ' + dest + ' ' + command[1]);
},
'ban' : function (data, command) {
- if (!data.admin) { return false; }
+ if (!data[this.ranks[0]]) { return false; }
var dest = command[2] || data.to;
console.log(command[1], ' has been banned from ', dest, ' at the request of ', data.nick);
this.emit('sendMsg', { dest: dest, msg: 'BEHOLD THE MIGHT OF THE BANHAMMER!!!' });
@@ -94,15 +99,15 @@ var triggers = module.exports = {
},
'unban' : function (data, command) {
- if (!data.admin) { return false; }
+ if (!data[this.ranks[0]]) { return false; }
var dest = command[2] || data.to;
console.log(command[1], ' has been unbanned from ', dest, ' at the request of ', data.nick);
this.emit('sendMsg', { dest: dest, msg: 'Mercy has been bestowed upon ' + command[1] });
this.emit('command', 'mode ' + dest + ' -b ' + command[1]);
},
'stfu' : function (data, command) {
- if (!data.employee) { return false; }
+ if (!data[this.ranks[1]]) { return false; }
var self = this,
dest = (isNaN(parseInt(command[2]))) ? command[2] : data.to,
timer = (command[3] && !isNaN(parseInt(command[3]))) ? // If command[3] is a number,
@@ -127,7 +132,7 @@ var triggers = module.exports = {
},
'gtfo': function (data, command) {
- if (!data.admin) { return false; }
+ if (!data[this.ranks[0]]) { return false; }
this.emit('hook::exit', null);
}
}

0 comments on commit bc2bdf0

Please sign in to comment.