caching bot id (web request is done only once)
Signed-off-by: klux2 <k.lux.gm@gmail.com>
This commit is contained in:
parent
01248e449e
commit
4946837240
1 changed files with 9 additions and 5 deletions
|
@ -46,6 +46,8 @@ essen = []
|
|||
var = True
|
||||
datum = None
|
||||
|
||||
botID = -1
|
||||
|
||||
|
||||
class HSMensaW(telepot.aio.helper.ChatHandler):
|
||||
@staticmethod
|
||||
|
@ -233,11 +235,13 @@ async def get_essen(only_today: bool) -> None:
|
|||
|
||||
|
||||
def get_bot_id() -> int:
|
||||
global botID
|
||||
if botID == -1:
|
||||
api_url = "https://api.telegram.org/bot" + telegram_bot_token + "/getMe"
|
||||
with urllib.request.urlopen(api_url) as response:
|
||||
data = json.load(response)
|
||||
bot_id = data["result"]["id"]
|
||||
return bot_id
|
||||
botID = data["result"]["id"]
|
||||
return botID
|
||||
|
||||
|
||||
def get_chat_name(msg: dict) -> str:
|
||||
|
|
Loading…
Reference in a new issue