Skip to content

Commit

Permalink
Added cached getMe function to utils.
Browse files Browse the repository at this point in the history
  • Loading branch information
natfarleydev committed Feb 4, 2017
1 parent 01a4bcc commit 58a69ea
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions skybeard/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import logging
import pip
import yaml
import aiohttp

import pyconfig

Expand Down Expand Up @@ -207,3 +208,18 @@ def partition_text(text):
j += 1
except IndexError:
yield text_list[i]


BOT_JSON = None


async def getMe():
global BOT_JSON
if not BOT_JSON:
async with aiohttp.ClientSession() as session:
async with session.get(
"https://api.telegram.org/bot{}/getMe".format(
pyconfig.get('key'))) as resp:
BOT_JSON = (await resp.json())['result']

return BOT_JSON

0 comments on commit 58a69ea

Please sign in to comment.