From fb7f89103d163595431c1079998a228e16760acb Mon Sep 17 00:00:00 2001 From: luke Date: Sat, 21 Mar 2020 15:34:59 -0700 Subject: [PATCH] making the river function easier to add to --- app/dragon-bot.py | 9 ++++++++- app/river_stats.py | 14 +++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/app/dragon-bot.py b/app/dragon-bot.py index 27fcedd1..bdb47787 100644 --- a/app/dragon-bot.py +++ b/app/dragon-bot.py @@ -226,6 +226,14 @@ async def on_message(message): ) if message.content.startswith('!invite'): + # for server in client.servers: + # if server.name == 'Alexandria': + # for channel in server.channels: + # if channel.name == 'cyber_bullying': + # invite = await client.create_invite( + # destination=channel, max_uses=1, max_age=3600 + # ) + # await client.send_message(message.channel, invite) # 3600 = 1 hour invite = await client.create_invite( destination=message.channel, max_uses=1, max_age=3600 @@ -362,7 +370,6 @@ async def on_message(message): embed=generate_embed(embed_url=wallpaper.get_wall(message.content)) ) - if message.content.startswith('!minecraft'): # Check permissions if not role_check.docker_permissions(message.author.roles): diff --git a/app/river_stats.py b/app/river_stats.py index adf0572e..434ee83e 100644 --- a/app/river_stats.py +++ b/app/river_stats.py @@ -5,8 +5,8 @@ import threading results = {} -def get_river_stats(river_url): - url = requests.get(river_url) +def get_river_stats(river_id): + url = requests.get("https://waterdata.usgs.gov/usa/nwis/uv?" + river_id) soup = BeautifulSoup(url.content, "lxml") river_name = ' '.join(soup.find('h2').text.split()[2:]) @@ -19,13 +19,13 @@ def get_river_stats(river_url): def get_stats(): - rivers = [ - 'https://waterdata.usgs.gov/usa/nwis/uv?06752260', - 'https://waterdata.usgs.gov/co/nwis/uv/?site_no=07091200&PARAmeter_cd=00065,00060', - 'https://waterdata.usgs.gov/co/nwis/uv/?site_no=06719505&PARAmeter_cd=00065,00060', + river_ids = [ + '06752260', + '07091200', + '06719505', ] threads = [] - for river in rivers: + for river in river_ids: t = threading.Thread(target=get_river_stats, args=(river,)) threads.append(t) t.start()