Created
March 8, 2014 14:45
-
-
Save whiskers75/9431550 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var later = {}; | |
var Command = require('../command.js'); | |
later.desc = 'Do stuff later' | |
later.modify = function(g) { | |
g.later = {}; | |
g.later.pending = false; | |
g.later.user = '' | |
g.bot.on('+mode', function(channel, by, mode, argument, raw) { | |
if (mode == 'b' || mode == 'q') { | |
global.hasPermission(raw.user + '@' + raw.host, 'op', channel, function (perm) { | |
if (perm) { | |
g.bot.say(by, 'Would you like to undo [+' + mode + ' ' + raw.args[2] + '] later?'); | |
g.bot.say(by, 'Reply with ' + g.config.prefix + ' la <time in seconds>'); | |
g.later.pending = function(seconds) { | |
setTimeout(function() { | |
g.bot.send('MODE', channel, '-' + mode, raw.args[2]); | |
}, seconds * 1000); | |
} | |
g.later.user = by; | |
} | |
}); | |
} | |
}); | |
} | |
later.commands = {}; | |
later.commands.lmode = new Command({perm: 'op', desc: 'Set a mode after some time', usage: '<time in seconds> <mode> <target>', args: 3}, function(g, m, u, t) { | |
g.bot.say(t, u + ': ' + Number(m[0]) + 's until MODE ' + t + ' ' + m[1] + ' ' + m[2]); | |
setTimeout(function() { | |
g.bot.send('MODE', t, m[1], m[2]); | |
}, Number(m[0]) * 1000); | |
}); | |
later.commands.kban = new Command({perm: 'op', desc: 'Ban a user for <seconds> seconds', usage: '<user> <seconds>', args: 2}, function(g, m, u, t) { | |
g.bot.send('MODE', t, '+b', m[0]); | |
g.bot.send('REMOVE', t, m[0], 'You have been banned for ' + m[1] + ' seconds!') | |
setTimeout(function() { | |
g.bot.send('MODE', t, '-b', m[0]); | |
g.bot.send('INVITE', m[0], t); | |
}, Number(m[1]) * 1000); | |
}); | |
later.commands.kmode = new Command({perm: 'op', desc: 'Set a mode for <seconds> seconds', usage: '<mode> <target> <seconds>', args: 3}, function(g, m, u, t) { | |
g.bot.send('MODE', t, m[0], m[1]); | |
setTimeout(function() { | |
g.bot.send('MODE', t, m[0].replace('+', '-'), m[1]); | |
}, Number(m[2]) * 1000); | |
}); | |
later.commands.la = new Command({args: 1}, function(g, m, u, t) { | |
if (g.later.pending && g.later.user == u) { | |
g.later.pending(m[0]); | |
g.bot.say(u, 'Done.') | |
} | |
else { | |
g.bot.notice(u, 'There is nothing pending.'); | |
} | |
}); | |
module.exports = later; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment