Awesome IRC bot
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
1.0 KiB

#!/usr/bin/env python
.. module:: Urban
:synopsis: Lookup from urban dictionary
.. moduleauthor:: Dave Pedu <>
from pyircbot.modulebase import ModuleBase, command
import requests
from pyircbot.modules.ModInfo import info
class Urban(ModuleBase):
@info("urban <term> lookup an urban dictionary definition", cmds=["urban", "u"])
@command("urban", "u")
def urban(self, msg, cmd):
definitions = requests.get("",
params={"term": cmd.args_str}).json()["list"]
if len(definitions) == 0:[0], "Urban definition: no results!")
defstr = definitions[0]['definition'].replace('\n', ' ').replace('\r', '')
if len(defstr) > 360:
defstr = defstr[0:360] + "..."[0], "Urban definition: %s -" %
(defstr, definitions[0]['defid']))