added timeout error, reformatted some error message in .isup

This commit is contained in:
iou1name 2018-06-02 13:42:19 -04:00
parent 76ad41ec48
commit ce55e2eed3
2 changed files with 11 additions and 6 deletions

View File

@ -27,18 +27,23 @@ def isup(bot, trigger):
return bot.msg("Missing or invalid schema. Check the URL.") return bot.msg("Missing or invalid schema. Check the URL.")
except requests.exceptions.ConnectionError: except requests.exceptions.ConnectionError:
return bot.msg("Connection error. Are you sure this is a real website?") return bot.msg("\x0304Connection error\x03. Are you sure this is " + \
"a real website?")
except requests.exceptions.InvalidURL: except requests.exceptions.InvalidURL:
return bot.msg("Invalid URL.") return bot.msg("Invalid URL.")
except requests.exceptions.ReadTimeout:
return bot.msg("\x0307" + url + "\x03 looks \x0304down\x03 from " + \
"here (\x0304Timed out [10s]\x03)")
except Exception as e: except Exception as e:
print(e) print(e)
return bot.msg("Listen buddy. I don't know what you're doing, but \ return bot.msg("Listen buddy. I don't know what you're doing, but " + \
you're not doing it right.") "you're not doing it right.")
try: try:
res.raise_for_status() res.raise_for_status()
return bot.msg(url + " appears to be working from here.") return bot.msg("\x0307" + url + "\x03 looks \x0303up\x03 from here.")
except requests.exceptions.HTTPError: except requests.exceptions.HTTPError:
return bot.msg(url + " looks down from here.") return bot.msg("\x0307" + url + "\x03 looks \x0304down\x03 from here.")

View File

@ -106,7 +106,7 @@ def watch(bot, trigger):
bot.memory["watcher"][url] = t bot.memory["watcher"][url] = t
bot.db.execute("INSERT INTO watcher(api_url, name, last_post, time_since)" bot.db.execute("INSERT INTO watcher(api_url, name, last_post, time_since)"
" VALUES(?,?,?,?,?)", (api_url, name, last_post, time_since)) " VALUES(?,?,?,?)", (api_url, name, last_post, time_since))
bot.msg("[\x0304Watcher\x03] Watching thread: \x0307" + url) bot.msg("[\x0304Watcher\x03] Watching thread: \x0307" + url)