#!/bin/python import discord from discord.ext import commands from lib.parse_data import update_data, get_covid_data, covid_db from re import match from datetime import datetime from asyncio import sleep class MyClient(discord.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): with open('.keys/report_channel_id') as cid: channel = self.get_channel(int(cid.readline().strip())) if(report_match.group(2).upper() == 'KEYS'): await channel.send(covid_db.keys()) else: await channel.send(get_covid_data(report_match.group(2).upper())) if(__name__ == '__main__'): with open('.keys/bot_api.key') as key: discord_api_key = key.readline().strip() client = MyClient() client.run(discord_api_key)