-
-
Save flash007k/f2306823c6e8cc1fad05f87c7a4aaf3c to your computer and use it in GitHub Desktop.
gluon urban dictionary
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
Asena.addCommand({pattern: 'ud', fromMe: true} | |
(function() { | |
// descriptor | |
return {name:"urbandictionary"} | |
}) | |
function go(msg) { | |
if (msg.method == "irc.privmsg") { | |
var cmd_match = /^!urbandictionary(\s+(\w+))?/.exec(msg.params.message) | |
if(cmd_match) { | |
var url = 'http://api.urbandictionary.com/v0/define?term='+encodeURIComponent(cmd_match[2]) | |
bot.say(bot.admin_channel, url) | |
var entry = JSON.parse(http.get(url)).list[0] | |
var short_match = /(.+)/.exec(entry.definition) | |
bot.say(msg.params.channel, cmd_match[2]+' '+short_match[1]) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment