Commit 85490f78 authored by Danny SMc's avatar Danny SMc

Added support for the define command

parent 57b2b75a
......@@ -14,7 +14,7 @@ var irc = require('irc'),
pre = "!";
console.log("Connecting to IRC Channel: #shinexusuk");
var bot = new irc.Client('irc.esper.net', 'ShinexusUK', {
var bot = new irc.Client('irc.esper.net', 'DaveBot_Shinexus', {
channels: ['#shinexusuk'],
realName: 'ShinexusUK Server Bot',
autoRejoin: true
......@@ -114,8 +114,37 @@ function parsemessage(msg, to) {
} else if (msgs[0] == pre+"motd") {
// Should return the message of the day.
} else if (msgs[0] == pre+"define") {
// Defines a word using urban dictionary.
term = msgs[1];
unirest.get("https://mashape-community-urban-dictionary.p.mashape.com/define?term="+term)
.header("X-Mashape-Key", "rTnUnhzFqrmshxY4iMM3Xq5xtERXp12EAa6jsnBd7OnwLQL0Ag")
.header("Accept", "text/plain")
.end(function (result) {
a = result.body['list'];
if(a.length >= 1){
q = result.body['list'][0];
def = q['definition'].replace("\n","");
if(def.length >= 300){
def = def.substring(0, 300)+"...";
}
bot.say(to, "Definition of "+term+": "+def+" (http://urbandictionary.com/"+term+")");
}else{
bot.say(to, "Can't find a definiton for "+term);
}
});
} else if (msgs[0] == pre+"ip") {
bot.say(to, "ShinexusUK IP Address: shinexusuk.nitrous.it");
} else if (msgs[0] == pre+"rules") {
......
......@@ -9,4 +9,9 @@ This IRC bot has access to all the servers allowing you to get information about
!help | Will request a list of all available commands.
!help :command: | Will list information for each command.
!status | Will display the status for each server. Whether online or offline.
!players | Will display the total player count, and then the count for each server.
\ No newline at end of file
!players | Will display the total player count, and then the count for each server.
!define | Will grab a definition for a key work on Urban Dictionary.
-----
### Warning:
The bot comes with very sacrastic humour, so do not let him offend you, the bot can be named to your desire. Currently we call him Dave.
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment