Permalink
Browse files

[fix] !stfu now works as expected.

  • Loading branch information...
1 parent 3346989 commit 372e5d45da0de764a7c41542af7cc0eb13fdb19a @AvianFlu AvianFlu committed Oct 21, 2011
Showing with 18 additions and 4 deletions.
  1. +18 −4 lib/triggers.js
View
@@ -17,6 +17,12 @@ var triggers = module.exports = {
'channel': function (data, command) {
if (!data.admin) { return false; }
+ if (!this.channels[command[1]]) {
+ return this.emit('sendMsg', {
+ dest: data.to,
+ msg: 'Sorry, cannot alter channel configuration for ' + command[1]
+ });
+ }
var retval = this.channels[command[1]].config(command[2], command[3]);
if (retval) {
this.emit('sendMsg', { dest: data.to, msg: retval });
@@ -98,10 +104,18 @@ var triggers = module.exports = {
'stfu' : function (data, command) {
if (!data.employee) { return false; }
var self = this,
- dest = (typeof command[2] === 'string') ? command[2] : data.to,
- timer = command[3] || (typeof command[2] === 'number') ? command[2] : 60;
- self.emit('sendMsg', { dest: dest, msg: 'Gross Adjusted Noobosity of ' + command[1]
- + ' has exceeded specified telemetry parameters. Irrevocable ' + toString(timer) + ' second mute has been initiated.'});
+ dest = (isNaN(parseInt(command[2]))) ? command[2] : data.to,
+ timer = (command[3] && !isNaN(parseInt(command[3]))) ? // If command[3] is a number,
+ parseInt(command[3]) : // parse it as an int and use it.
+ !isNaN(parseInt(command[2])) ? // Otherwise, if command[2] is a number,
+ parseInt(command[2]) : // try to parse command[2] as an int;
+ 60; // if that fails as well, the default timer is 60 seconds.
+ self.emit('sendMsg', {
+ dest: dest,
+ msg: 'Gross Adjusted Noobosity of ' + command[1]
+ + ' has exceeded specified telemetry parameters. Irrevocable '
+ + timer + ' second mute has been initiated.'
+ });
self.emit('command', 'mode ' + dest + ' +q ' + command[1]);
setTimeout(function () {
self.emit('command', 'mode ' + dest + ' -q ' + command[1]);

0 comments on commit 372e5d4

Please sign in to comment.