From 90ce92dc39395444862edfc7946ef7a1195f2464 Mon Sep 17 00:00:00 2001 From: dngfx Date: Fri, 31 Aug 2018 10:51:47 +0100 Subject: Revert "Reformat" This reverts commit abed9cf --- modules/urbandictionary.py | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'modules/urbandictionary.py') diff --git a/modules/urbandictionary.py b/modules/urbandictionary.py index 657df127..d2bcc441 100644 --- a/modules/urbandictionary.py +++ b/modules/urbandictionary.py @@ -4,13 +4,12 @@ import Utils URL_URBANDICTIONARY = "http://api.urbandictionary.com/v0/define" REGEX_DEFNUMBER = re.compile("-n(\d+) \S+") - class Module(object): def __init__(self, bot): bot.events.on("received").on("command").on("urbandictionary", "ud" - ).hook(self.ud, min_args=1, - help="Get the definition of a provided term", - usage="") + ).hook(self.ud, min_args=1, + help="Get the definition of a provided term", + usage="") def ud(self, event): term = event["args"] @@ -20,17 +19,14 @@ class Module(object): number = int(match.group(1)) term = term.split(" ", 1)[1] page = Utils.get_url(URL_URBANDICTIONARY, get_params={"term": term}, - json=True) + json=True) if page: if len(page["list"]): - if number > 0 and len(page["list"]) > number - 1: - definition = page["list"][number - 1] + if number > 0 and len(page["list"]) > number-1: + definition = page["list"][number-1] event["stdout"].write("%s: %s" % (definition["word"], - definition[ - "definition"].replace( - "\n", " ").replace( - "\r", "").replace( - " ", " "))) + definition["definition"].replace("\n", " ").replace( + "\r", "").replace(" ", " "))) else: event["stderr"].write("Definition number does not exist") else: -- cgit v1.3.1-10-gc9f91