Skip to content
Snippets Groups Projects
Commit fea64e3d authored by Ferdinand Schober's avatar Ferdinand Schober :speech_balloon:
Browse files

fix some log messages

parent 867f4327
No related tags found
No related merge requests found
......@@ -4,7 +4,7 @@ import json
import time
from pprint import pprint
from contextlib import ExitStack
from log import print_info, print_error, color, BOLD, ITALIC, WHITE, CLEAR
from log import print_info, print_error, print_warn, color, BOLD, ITALIC, WHITE, CLEAR
webhook_url = None
......@@ -96,20 +96,24 @@ def validate_webhook_url(webhook_url):
try:
r = requests.get(webhook_url)
r.raise_for_status()
except Exception as e:
print_warn('Invalid webhook: ' + str(e))
return False
try:
json = r.json()
except Exception as e:
print_error('Invalid webhook:')
print(e)
print_warn('Invalid webhook: Expected a json response')
return False
name = json.get('name')
if not name:
print_error(
"Invalid webhook! Could not find a name associated with the bot.")
"Invalid webhook! Expected to find a name")
exit(1)
s = input(
f'use webhook "{color(ITALIC, WHITE)}{json.get("name")}{CLEAR}"? [Y,n] ')
f'found webhook "{color(ITALIC, WHITE)}{json.get("name")}{CLEAR}", '
'is this correct? [Y,n] ')
if s == 'y' or s == 'Y' or not s:
return True
return False
......
......@@ -10,7 +10,7 @@ import sys
import campus
import discord_hook
from log import print_info
from log import print_info, print_warn
close_requested = False
......@@ -27,7 +27,6 @@ def main():
with campus.Connection(args.u) as connection:
with discord_hook.Connection() as discord_connection:
print_info('online')
global online
online = True
discord_connection.send('[status] online')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment