24 lines
768 B
Python
24 lines
768 B
Python
![]() |
from discord import Client
|
||
|
from re import match
|
||
|
from lib.parse_data import update_data, get_covid_data, covid_db
|
||
|
|
||
|
|
||
|
class covidBot(Client):
|
||
|
async def on_ready(self):
|
||
|
print('Logged on as', self.user)
|
||
|
|
||
|
async def on_message(self, message):
|
||
|
# don't respond to ourselves
|
||
|
if(message.author == self.user):
|
||
|
return
|
||
|
|
||
|
if(message.content == '!ping'):
|
||
|
await message.channel.send('pong')
|
||
|
|
||
|
report_match = match(r'(!report )([a-zA-Z\-\_\. ]+)', message.content)
|
||
|
if(report_match):
|
||
|
if(report_match.group(2).upper() == 'KEYS'):
|
||
|
await message.channel.send(covid_db.keys())
|
||
|
else:
|
||
|
await message.channel.send(get_covid_data(report_match.group(2).upper()))
|