IrcMiRCARTBot.py:_dispatchPrivmsg(): print message from website if upload fails.

IrcMiRCARTBot.py:_uploadToImgur(): additionally return responseHttp.text on failure.
This commit is contained in:
Lucio Andrés Illanes Albornoz 2018-06-21 09:04:22 +02:00
parent 5f99672c08
commit e7b6324866

View File

@ -163,7 +163,9 @@ class IrcMiRCARTBot(IrcClient.IrcClient):
self.clientLastMessage = int(time.time()) self.clientLastMessage = int(time.time())
else: else:
self._log("Upload failed with HTTP status code {}".format(imgurResponse[0])) self._log("Upload failed with HTTP status code {}".format(imgurResponse[0]))
self._log("Message from website: {}".format(imgurResponse[1]))
self.queue("PRIVMSG", message[2], "4/!\\ Upload failed with HTTP status code {}!".format(imgurResponse[0])) self.queue("PRIVMSG", message[2], "4/!\\ Upload failed with HTTP status code {}!".format(imgurResponse[0]))
self.queue("PRIVMSG", message[2], "4/!\\ Message from website: {}".format(imgurResponse[1]))
if os.path.isfile(asciiTmpFilePath): if os.path.isfile(asciiTmpFilePath):
os.remove(asciiTmpFilePath) os.remove(asciiTmpFilePath)
if os.path.isfile(imgTmpFilePath): if os.path.isfile(imgTmpFilePath):
@ -197,7 +199,7 @@ class IrcMiRCARTBot(IrcClient.IrcClient):
if responseHttp.status_code == 200: if responseHttp.status_code == 200:
return [200, responseDict.get("data").get("link")] return [200, responseDict.get("data").get("link")]
else: else:
return [responseHttp.status_code] return [responseHttp.status_code, responseHttp.text]
# }}} # }}}
# {{{ _urlretrieveReportHook(count, blockSize, totalSize): Limit downloads to 1 MB # {{{ _urlretrieveReportHook(count, blockSize, totalSize): Limit downloads to 1 MB
def _urlretrieveReportHook(count, blockSize, totalSize): def _urlretrieveReportHook(count, blockSize, totalSize):