From 3150695f9ace4a2282ec2e0077c9503268563e00 Mon Sep 17 00:00:00 2001 From: Luke Robles Date: Thu, 26 Mar 2020 17:15:15 -0700 Subject: [PATCH] Fixing corona to work with country names now too --- app/corona.py | 16 +++++++++------- app/dragon-bot.py | 19 ++++++++----------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/app/corona.py b/app/corona.py index b9f9ceea..2d4a8db8 100644 --- a/app/corona.py +++ b/app/corona.py @@ -20,20 +20,22 @@ def get_csv(): return local_csv -def sum_numbers(state): +def sum_numbers(location): series = read_csv(get_csv(), header=0, parse_dates=[0], index_col=0, squeeze=True) last_updated = series['Last_Update'].iloc[0] - state_query = series.loc[series['Province_State'] == state] - if state_query.empty: - embed = discord.Embed(description="No results found for %s.\n\nPlease enter a valid US state" % state, color=0x428bca, type="rich") - embed.set_author(name="CSSE at Johns Hopkins University", icon_url='https://avatars2.githubusercontent.com/u/60674295') - return embed + location_query = series.loc[series['Province_location'] == location] + if location_query.empty: + location_query = series.loc[series['Country_Region'] == location] + if location_query.empty: + embed = discord.Embed(description="No results found for %s.\n\nPlease enter a valid Country name or US state" % location, color=0x428bca, type="rich") + embed.set_author(name="CSSE at Johns Hopkins University", icon_url='https://avatars2.githubusercontent.com/u/60674295') + return embed sums = state_query.sum() confirmed = sums['Confirmed'] deaths = sums['Deaths'] recovered = sums['Recovered'] - embed = discord.Embed(description="Most recent Corona stats for %s\nUpdated once a day\n(Last update was %s)" % (state, last_updated), color=0x428bca, type="rich") + embed = discord.Embed(description="Most recent Corona stats for %s\nUpdated once a day\n(Last update was %s)" % (location, last_updated), color=0x428bca, type="rich") embed.set_author(name="CSSE at Johns Hopkins University", icon_url='https://avatars2.githubusercontent.com/u/60674295') embed.add_field(name='Confirmed Cases', value=confirmed) embed.add_field(name='Recovered Cases', value=recovered) diff --git a/app/dragon-bot.py b/app/dragon-bot.py index 4bb53d5a..ddefe9d3 100644 --- a/app/dragon-bot.py +++ b/app/dragon-bot.py @@ -42,10 +42,6 @@ dragon_environment = os.getenv('DRAGON_ENV') debug = dragon_environment == 'test' @client.event -async def on_member_join(member): - message = "Whats up epic gamer.\n\nI'm dragon-bot, this server's top meme bot.\nType !help in general to see everything I'm capable of" - await client.send_message(member, message) - async def on_ready(): # Update the bot's status await client.change_presence( @@ -252,13 +248,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) + # await client.send_message(message.author, server.name) + # 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