From bf2c33c31a6cd7e9e335df844555150ed1711600 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Forr=C3=B3?= Date: Mon, 30 Apr 2018 17:25:28 +0200 Subject: [PATCH] Return complete response instance from API methods --- bot.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bot.py b/bot.py index 5ffd983..bc16bd8 100644 --- a/bot.py +++ b/bot.py @@ -97,26 +97,26 @@ class TwitchBot(irc.bot.SingleServerIRCBot): def get(self, params): r = requests.get('{0}/quotes'.format(self.api_url), params=params) r.raise_for_status() - return r.json() + return r def post(self, data): r = requests.post('{0}/quotes'.format(self.api_url), data=data, headers={'X-Quotes-API-Key': self.api_key}) r.raise_for_status() - return r.json() + return r def delete(self, id): r = requests.delete('{0}/quotes/{1}'.format(self.api_url, id), headers={'X-Quotes-API-Key': self.api_key}) r.raise_for_status() - return r.json() + return r def last_quote(self, connection, tags, **kwargs): try: quotes = self.get(dict( sort_by='id', sort_order='desc', - page_size=1)) + page_size=1)).json() quote = quotes[0] except (requests.exceptions.HTTPError, IndexError): msg = 'Sorry @{0}, no quotes found'.format(tags['display-name']) @@ -134,7 +134,7 @@ class TwitchBot(irc.bot.SingleServerIRCBot): filter=filter, sort_by='id', sort_order='desc', - page_size=1)) + page_size=1)).json() quote = quotes[0] except (requests.exceptions.HTTPError, IndexError): msg = 'Sorry @{0}, no quotes found'.format(tags['display-name']) @@ -152,7 +152,7 @@ class TwitchBot(irc.bot.SingleServerIRCBot): quotes = self.get(dict( sort_by='id', sort_order='desc', - page_size=1)) + page_size=1)).json() quote = quotes[0] except requests.exceptions.HTTPError as e: log.error('Failed to get quotes: %s', str(e))