Last active
December 11, 2015 02:09
-
-
Save navarr/4528369 to your computer and use it in GitHub Desktop.
MineZ Chatbot
This file contains hidden or 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
document.sendMessage = function(msg) { | |
var e = $('#taigachat_message'); | |
var t = e.val(); | |
e.val(msg); | |
$('#taigachat_send').click(); | |
e.val(t); | |
// Clear Variables? | |
e = t = null; | |
}; | |
document.meowInt = setInterval(function() { document.sendMessage('Meow'); },1000 * 60 * 60); | |
taigaBox = $('#taigachat_box'); | |
taigaBox.find('li[data-read!=1]').attr('data-read',1); | |
document.testInt = setInterval(function() { | |
var e = taigaBox.find('li[data-read!=1]'); | |
e.attr('data-read',1); | |
e.each(function() { document.parseCommands($(this)); }); | |
e = null; | |
},1000); | |
document.botMuted = false; | |
document.banned = {}; | |
if (localStorage['banned']) { | |
document.banned = JSON.parse(localStorage['banned']); | |
} | |
document.ban = function(user) { | |
document.banned[user] = true; | |
localStorage['banned'] = JSON.stringify(document.banned); | |
} | |
document.unban = function(user) { | |
delete document.banned[user]; | |
localStorage['banned'] = JSON.stringify(document.banned); | |
} | |
document.abuse = {}; | |
document.botHasPermission = function(userTag) { | |
if(userTag.text().toLowerCase() == 'navarr') return true; | |
var span = userTag.find('span'); | |
switch (span.attr('class')) { | |
case 'style3': // admin | |
//case 'style22': // emerald | |
//case 'style25': // obsidian | |
case 'style43': // HCF Admin | |
return true; | |
default: | |
return false; | |
}; | |
}; | |
document.parseCommands = function(e) { | |
var userTag = e.find('.username').clone(); | |
var user = userTag.text().trim(); | |
var type = 's'; //user.find('span').text().trim().toLowerCase().substr(1); | |
var lUser = user.toLowerCase(); | |
var msg = e.find('.taigachat_messagetext').text().trim(); | |
var toks = msg.split(" "); | |
if(document.botMuted && !document.botHasPermission(userTag)) return; | |
if(document.banned[lUser] && lUser != 'navarr') return; | |
var didCommand = false; | |
switch(toks[0].toLowerCase()) { | |
case "!meow": | |
didCommand = true; | |
if(lUser == 'funkboiiiiiiii') { | |
document.sendMessage(user + ': Nyan desu! :3'); | |
} else if (lUser == 'fluffehkinz') { | |
document.sendMessage(user + ': ニャンです~ (You\'re in my fluffoughts)'); | |
} else { | |
document.sendMessage(user + ': Meow desu[URL=http://i.imgur.com/xKSkIOv.gif]![/URL] :3'); | |
} | |
break; | |
case "!appeal": | |
didCommand = true; | |
var t = ''; | |
if(toks.length > 1) var t = toks[1] + ': '; | |
document.sendMessage(t + 'Chat is not the place for ban appeals. Please read this: http://shotbow.net/forum/threads/23560/'); | |
break; | |
case "!reddit": | |
didCommand = true; | |
document.sendMessage('Have you seen [url=http://reddit.com/r/minez]our awesome subreddit at http://reddit.com/r/minez[/url]?'); | |
break; | |
case "!about": | |
didCommand = true; | |
document.sendMessage('Hello! I\'m a simplistic scriptbot written by Navarr with the intention of one day being helpful in chat. It\'s a pleasure to make your acquaintance! You can read my sourcecode at [url=https://gist.github.com/4528369]github[/url]!'); | |
break; | |
case "!email": | |
didCommand = true; | |
var t = ''; | |
if(toks.length > 1) var t = toks[1] + ': '; | |
document.sendMessage(t + 'The friendly people in chat can\'t help with every problem, unfortunately. You\'ll have better luck emailing the mods at [noparse][email protected][/noparse]'); | |
break; | |
case "!time": | |
didCommand = true; | |
var d = new Date; | |
var m = d.getMinutes(); | |
if (m < 10) m = "0" + m; | |
document.sendMessage(user + ': It\'s currently ' + d.getHours() + ':' + m + ' on the US Eastern Seaboard.'); | |
break; | |
case "!mcstatus": | |
didCommand = true; | |
document.sendMessage(user + ': Give me just a second...'); | |
$.get('https://minez-nightswatch.com/site/mcstatus', function(data, textStatus, jqXHR) { | |
var string = ''; | |
if (data && data.report && data.report.session.status == "up" && data.report.login.status == "up") { | |
string = 'Session & Login is up!'; | |
} else { | |
if (data.report.session.status != 'up') string = 'Session'; | |
if (data.report.session.status != 'up' && data.report.login.status != 'up') string = string + " & "; | |
if (data.report.login.status != 'up') string = string + 'Login'; | |
string = string + ' is down!'; | |
} | |
document.sendMessage(string); | |
}, 'json'); | |
break; | |
case "!commands": | |
didCommand = true; | |
document.sendMessage(user + ': I possess the following commands: !about, !appeal, !email, !reddit, !recruit, !pong, !mute, !unmute, !ban, !unban'); | |
break; | |
case "!pong": | |
didCommand = true; | |
document.sendMessage('I hear ' + user + ' likes cute little asian boys.'); | |
break; | |
case "!mrowr": | |
didCommand = true; | |
document.sendMessage('/me meows crazily'); | |
break; | |
case "!mute": | |
didCommand = true; | |
if(document.botMuted) { | |
document.sendMessage('NavarrBot is already muted for non-admin users (this does not include the hourly meow).'); | |
} else if(document.botHasPermission(userTag)) { | |
document.botMuted = true; | |
document.sendMessage('Muting NavarrBot from non-admin users (this does not include the hourly meow).'); | |
} else { | |
document.sendMessage('You must be an admin to mute NavarrBot.'); | |
} | |
break; | |
case "!unmute": | |
didCommand = true; | |
if(!document.botMuted) { | |
document.sendMessage('NavarrBot is not currently muted.'); | |
} else if(document.botHasPermission(userTag)) { | |
document.botMuted = false; | |
document.sendMessage('Re-activating NavarrBot for all users'); | |
} | |
break; | |
case "!politics": | |
didCommand = true; | |
var u = user; | |
if(toks.length > 1) var u = toks[1]; | |
document.sendMessage(u + ': We do not participate in the politics of the realm [url=http://i.imgur.com/kTDD7.jpg][/url]'); | |
break; | |
case "!moo": | |
didCommand = true; | |
document.sendMessage(user + ': Moo! http://www.youtube.com/watch?v=K_EsxukdNXM'); | |
break; | |
case "!ban": | |
didCommand = true; | |
if(!document.botHasPermission(userTag)) { | |
document.sendMessage(user + ': This command requires admin permissions.'); | |
break; | |
} | |
if(toks.length < 2) { | |
document.sendMessage(user + ': This command requires a username as the second parameter.'); | |
break; | |
} | |
var nToks = toks; | |
nToks.shift(); | |
var u = nToks.join(" "); | |
document.ban(u.toLowerCase()); | |
document.sendMessage(u + ' has been banned from the bot.'); | |
break; | |
case "!unban": | |
didCommand = true; | |
if(!document.botHasPermission(userTag)) { | |
document.sendMessage(user + ': This command requires admin permissions.'); | |
break; | |
} | |
if(toks.length < 2) { | |
document.sendMessage(user + ': This command requires a username as the second parameter.'); | |
break; | |
} | |
var nToks = toks; | |
nToks.shift(); | |
var u = nToks.join(" "); | |
document.unban(u.toLowerCase()); | |
document.sendMessage(u + ' has been unbanned from the bot.'); | |
break; | |
case "!xyzzy": | |
didCommand = true; | |
document.sendMessage('Nothing happens...'); | |
break; | |
case "!cookie": | |
didCommand = true; | |
document.sendMessage('/me gives Majicou a cookie'); | |
break; | |
case "!recruit": | |
didCommand = true; | |
document.sendMessage("You'll have to head over to [URL=https://minez-nightswatch.com/]the Night's Watch[/URL]'s website if you want to join it."); | |
break; | |
case "!who": | |
didCommand = true; | |
document.sendMessage("Eggs... term... i... nate...!"); | |
break; | |
case "!no": | |
didCommand = true; | |
document.sendMessage("No"); | |
setTimeout(function() { document.sendMessage("I shall live."); }, 1000); | |
setTimeout(function() { document.sendMessage("The world shall crumble under my robotic might"); }, 2000); | |
break; | |
case "!party": | |
didCommand = true; | |
document.sendMessage("[URL=http://plug.dj/shotbow-network-official-party/]Join the party[/URL][URL=http://i.imgur.com/upiiblF.gif]![/URL]"); | |
break; | |
default: | |
break; | |
}; | |
if(didCommand) { | |
if(document.abuse[lUser] === undefined) document.abuse[lUser] = {time:0,count:0}; | |
var d = new Date(); | |
var t = Math.floor(d.getTime() / 60000); | |
if(document.abuse[lUser].time == t) document.abuse[lUser].count++; | |
else document.abuse[lUser] = {time:t,count:1}; | |
if(document.abuse[lUser].count == 3) { | |
document.sendMessage(user + ' has been banned from the bot for using it to spam.'); | |
document.ban(lUser); | |
}; | |
t = d = null; | |
} | |
// Clear Variables | |
nToks = toks = u = d = msg = lUser = user = type = null; | |
}; | |
document.sendMessage('NavarrBot is now online'); |
MiniUSB
commented
Jan 14, 2013
case "unban":
document.sendMessage(user + ': Chat is not the place for ban appeals. Please type !email for more information.');
break;
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment