Skip to content

Commit

Permalink
Fix one edge case
Browse files Browse the repository at this point in the history
Signed-off-by: starry69 <starry369126@outlook.com>
  • Loading branch information
starry-shivam committed May 5, 2020
1 parent f79734e commit bc9f75f
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions starrybot.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,16 +385,22 @@ def api_status(update, context):
else:
status = f'Error! {r.status_code}'

ratelimit = r.headers['X-RateLimit-Limit']
remaining = r.headers['X-RateLimit-Remaining']
try:
ratelimit = r.headers['X-RateLimit-Limit']
remaining = r.headers['X-RateLimit-Remaining']

text = f"API status: <code>{status}</code>\n"
text += f"Requests limit: <code>{ratelimit}</code>\n"
text += f"Requests remaining: <code>{remaining}</code>"
text = f"API status: <code>{status}</code>\n"
text += f"Requests limit: <code>{ratelimit}</code>\n"
text += f"Requests remaining: <code>{remaining}</code>"

msg.reply_text(text,
msg.reply_text(text,
parse_mode=ParseMode.HTML)

except:
msg.reply_text(f"API status: {status}")



# HANDLERS
start_handler = CommandHandler('start', start)
help_handler = CommandHandler('help', helper)
Expand Down

0 comments on commit bc9f75f

Please sign in to comment.