Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created August 18, 2020 16:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amankharwal/7fee3ecf2a0049ab0834db89e5df2dfb to your computer and use it in GitHub Desktop.
Save amankharwal/7fee3ecf2a0049ab0834db89e5df2dfb to your computer and use it in GitHub Desktop.
import requests
import json
def summary(update, context):
response = requests.get('https://api.covid19api.com/summary')
if(response.status_code==200): #Everything went okay, we have the data
data = response.json()
print(data['Global'])
context.bot.send_message(chat_id=update.effective_chat.id, text=data['Global'])
else: #something went wrong
context.bot.send_message(chat_id=update.effective_chat.id, text="Error, something went wrong.")
corona_summary_handler = CommandHandler('summary', summary)
dispatcher.add_handler(corona_summary_handler)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment