Add chat monitor

This commit is contained in:
Andrew Tomaka 2015-04-13 20:47:17 -04:00
parent b0e6167b82
commit 6ed690ef74

29
bot.js
View file

@ -109,10 +109,23 @@ function mainLoop() {
botToggle(); botToggle();
function botToggleUI() { function chatMonitor() {
clickSelector('a[name="portal"]'); $('#chatbox, #groupchatbox').bind('DOMSubtreeModified', function() {
clickSelector('button[name="vault_hide"]'); var lastMessage = $(this).find('.chat-message').last();
$('a[name="bossPortal"] > img').toggle(); if(chatIsPM(lastMessage) || chatHasName(lastMessage)) {
var user = lastMessage.find('.username').text().trim();
var content = lastMessage.find('.message').text().trim();
console.log('CHAT (' + user + '): ' + content);
}
});
}
function chatIsPM(message) {
return message.find('.chat-pm').length > 0;
}
function chatHasName(message) {
return /atomaka/.exec(message.find('.message').text()) != null;
} }
function botTimestamp() { function botTimestamp() {
@ -227,10 +240,12 @@ function botToggle() {
if(botPaused) { if(botPaused) {
console.log('Playing bot'); console.log('Playing bot');
botLoop = setInterval(mainLoop, 1000); botLoop = setInterval(mainLoop, 1000);
chatMonitor();
botPaused = false; botPaused = false;
} else { } else {
console.log('Pausing bot'); console.log('Pausing bot');
clearInterval(botLoop); clearInterval(botLoop);
$('#chatbox, #groupchatbox').unbind('DOMSubtreeModified');
botPaused = true; botPaused = true;
} }
} }
@ -255,6 +270,12 @@ function botToggleGlobal() {
} }
} }
function botToggleUI() {
clickSelector('a[name="portal"]');
clickSelector('button[name="vault_hide"]');
$('a[name="bossPortal"] > img').toggle();
}
function botSetTarget(username) { function botSetTarget(username) {
botRaidTarget = username; botRaidTarget = username;
} }