Skip to content

Instantly share code, notes, and snippets.

@flash007k
Forked from donpdonp/urbandictionary.js
Last active April 6, 2021 13:28
Show Gist options
  • Save flash007k/f2306823c6e8cc1fad05f87c7a4aaf3c to your computer and use it in GitHub Desktop.
Save flash007k/f2306823c6e8cc1fad05f87c7a4aaf3c to your computer and use it in GitHub Desktop.
gluon urban dictionary
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