Skip to content

Instantly share code, notes, and snippets.

@navarr
Last active December 19, 2015 23:08
Show Gist options
  • Save navarr/6032142 to your computer and use it in GitHub Desktop.
Save navarr/6032142 to your computer and use it in GitHub Desktop.
Ping Bot
// Audio To Play when one of the strings is mentioned
window.pingAudio = new Audio('http://www.soundjay.com/button/sounds/beep-7.mp3');
// Array of strings to notify you on, i.e. ['Navarr','Highlife','Darn'];
window.notifyMeOn = ['ju1cy','mr_darn','admin','help'];
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;
};
taigaBox = $('#taigachat_box');
taigaBox.find('li[data-read!=1]').attr('data-read', 1);
document.pingTestInt = setInterval(function () {
var e = taigaBox.find('li[data-read!=1]');
e.attr('data-read', 1);
e.each(function () {
document.pingParseText($(this));
});
e = null;
}, 1000);
document.pingParseText = 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 lMsg = msg.toLowerCase();
for (var i in window.notifyMeOn) {
if (lMsg.indexOf(window.notifyMeOn[i].toLowerCase()) > -1) {
window.pingAudio.play();
e.find('.taigachat_messagetext').css('color','#DD0000');
break;
}
}
// Clear Variables
nToks = toks = u = d = msg = lUser = user = type = null;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment