Fixing corona to work with country names now too

This commit is contained in:
Luke Robles 2020-03-26 17:15:15 -07:00
parent c1176d804c
commit 3150695f9a
2 changed files with 17 additions and 18 deletions

View File

@ -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)

View File

@ -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