mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-11 09:55:21 +00:00
Change API Url getting method.
This commit is contained in:
parent
14527ef2bf
commit
019bf06f71
2 changed files with 10 additions and 2 deletions
|
|
@ -83,7 +83,7 @@ def _compose_data(params, files=None):
|
||||||
async def request(session, token, method, data=None, 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 {}}")
|
log.debug(f"Make request: '{method}' with data: {data or {}} and files {files or {}}")
|
||||||
data = _compose_data(data, files)
|
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:
|
async with session.post(url, data=data) as response:
|
||||||
return await _check_result(method, response)
|
return await _check_result(method, response)
|
||||||
|
|
||||||
|
|
@ -137,3 +137,11 @@ class Methods:
|
||||||
SEND_GAME = 'sendGame'
|
SEND_GAME = 'sendGame'
|
||||||
SET_GAME_SCORE = 'setGameScore'
|
SET_GAME_SCORE = 'setGameScore'
|
||||||
GET_GAME_HIGH_SCORES = 'getGameHighScores'
|
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)
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ class BaseBot:
|
||||||
destination = io.BytesIO()
|
destination = io.BytesIO()
|
||||||
|
|
||||||
session = self.create_temp_session()
|
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')
|
dest = destination if isinstance(destination, io.IOBase) else open(destination, 'wb')
|
||||||
try:
|
try:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue