Last active
April 5, 2016 00:25
-
-
Save diracdeltafunk/17a3cde3f1a2a81a2e443f437f1f8049 to your computer and use it in GitHub Desktop.
Robin Bot
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 l; | |
var s; | |
var k; | |
var i; | |
var faces = [";)", ":)", ":(", "¯\\_(ツ)_/¯", "( ͡° ͜ʖ ͡°)"]; | |
function type(message) { | |
$('input.c-form-control.text-counter-input').val("♫ " + message + " ♫"); | |
setTimeout(function() {$('input.c-form-control.text-counter-input').submit()}, 50); | |
} | |
function respond() { | |
l = $('span.robin-message--message:last').text(); | |
if(l == ":?") { | |
type("Commands are :? :face :roll <number>"); | |
} | |
if(l.indexOf(":face") != -1) { | |
type(faces[Math.floor(Math.random() * faces.length)]); | |
} | |
if(l.indexOf(":roll") != -1) { | |
s = l.split(' '); | |
k = s.indexOf(":roll"); | |
if (k != -1 && k < s.length) { | |
i = parseInt(s[k+1]); | |
if (i > 0) { | |
type("You rolled " + (Math.floor(Math.random() * i) + 1)); | |
} | |
} | |
} | |
} | |
type("{USERNAME} chat bot initialized! Type :? for help"); | |
$('.robin-chat--message-list').bind('DOMNodeInserted', respond); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment