Last active
September 30, 2022 10:21
-
-
Save donpdonp/df36c86a223c749b15d83dcca1181008 to your computer and use it in GitHub Desktop.
gluon urban dictionary
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
(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 data = JSON.parse(http.get(url)) | |
var list = data.list.sort(function(a,b){return b.thumbs_up - a.thumbs_up}) | |
var entry = list[0] | |
var short_match = /(.+)/.exec(entry.definition) | |
var say = cmd_match[2]+' '+short_match[1]+' ('+entry.thumbs_up+' thumbs up)' | |
bot.say(msg.params.channel, say) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment