From 019bf06f71d2b540e6adaa96b04099b837d90948 Mon Sep 17 00:00:00 2001 From: Alex Root Junior Date: Tue, 11 Jul 2017 23:16:08 +0300 Subject: [PATCH] Change API Url getting method. --- aiogram/bot/api.py | 10 +++++++++- aiogram/bot/base.py | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/aiogram/bot/api.py b/aiogram/bot/api.py index 879415f9..12f45622 100644 --- a/aiogram/bot/api.py +++ b/aiogram/bot/api.py @@ -83,7 +83,7 @@ def _compose_data(params, files=None): async def request(session, token, method, data=None, files=None): log.debug(f"Make request: '{method}' with data: {data or {}} and files {files or {}}") data = _compose_data(data, files) - url = API_URL.format(token=token, method=method) + url = Methods.api_url(token=token, method=method) async with session.post(url, data=data) as response: return await _check_result(method, response) @@ -137,3 +137,11 @@ class Methods: SEND_GAME = 'sendGame' SET_GAME_SCORE = 'setGameScore' GET_GAME_HIGH_SCORES = 'getGameHighScores' + + @staticmethod + def api_url(token, method): + return API_URL.format(token=token, method=method) + + @staticmethod + def file_url(token, path): + return FILE_URL.format(token=token, path=path) diff --git a/aiogram/bot/base.py b/aiogram/bot/base.py index f5eaecf1..7b806ec1 100644 --- a/aiogram/bot/base.py +++ b/aiogram/bot/base.py @@ -94,7 +94,7 @@ class BaseBot: destination = io.BytesIO() session = self.create_temp_session() - url = api.FILE_URL.format(token=self.__token, path=file_path) + url = api.Methods.file_url(token=self.__token, path=file_path) dest = destination if isinstance(destination, io.IOBase) else open(destination, 'wb') try: