Created
February 2, 2013 08:22
-
-
Save navarr/4696602 to your computer and use it in GitHub Desktop.
DarnBot
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 = $('#chatform .chat-input'); | |
var t = e.val(); | |
e.val(msg); | |
$('#chatform input[type=submit]').click(); | |
e.val(t); | |
// Clear Variables? | |
e = t = null; | |
}; | |
$('div.chat-entry[data-read!=1]').attr('data-read',1); | |
document.testInt = setInterval(function() { | |
var e = $('div.chat-entry[data-read!=1]'); | |
e.attr('data-read',1); | |
e.each(function() { document.parseCommands($(this)); }); | |
e = null; | |
},1000); | |
document.darnAway = false; | |
document.parseCommands = function(e) { | |
var user = e.find('.user a').clone(); | |
var type = user.find('span').text().trim().toLowerCase().substr(1); | |
type = type.substr(0,type.length-1); | |
user.find('span').remove() | |
user = user.text().trim(); | |
var lUser = user.toLowerCase(); | |
var msg = e.find('.message').text().trim(); | |
var toks = msg.split(" "); | |
switch(toks[0].toLowerCase()) { | |
case "darn": | |
var lMsg = msg.toLowerCase(); | |
if(lMsg == "darn" || lMsg == "mr_darn") { | |
if(document.darnAway) { | |
document.sendMessage('[color=red]Auto-Response:[/color] Sorry, Mr_Darn is currently set to "AFK." Please ask your question, and one of the members will advise.'); | |
} else { | |
document.sendMessage('[color=red]Auto-Response:[/color] ' + user + ', Please do not say my name alone. Please ask your question, too, as one of the members may be able to help you in my absence.'); | |
} | |
} | |
break; | |
case "!away": | |
if(lUser == "mr_darn") { | |
document.darnAway = true; | |
alert('You are now set as away.'); | |
} | |
break; | |
case "!back": | |
if(lUser == "mr_darn") { | |
document.darnAway = false; | |
alert('You are no longer set as away.'); | |
} | |
break; | |
default: | |
break; | |
}; | |
toks = msg = lUser = user = type = null; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment