20 lines
585 B
Python
20 lines
585 B
Python
import aiohttp
|
|
import json
|
|
from urllib.parse import urlencode
|
|
from bot.config import BOT_TOKEN
|
|
import logging
|
|
|
|
# Create a logger instance
|
|
logger = logging.getLogger(__name__)
|
|
logging.basicConfig(level=logging.INFO)
|
|
|
|
apiBase = f"https://api.telegram.org/bot{BOT_TOKEN}/"
|
|
|
|
|
|
async def telegram_api(endpoint: str, **kwargs):
|
|
async with aiohttp.ClientSession() as session:
|
|
async with session.get(apiBase + f"{endpoint}?{urlencode(kwargs)}") as response:
|
|
data = await response.json()
|
|
logger.info("Telegram API response: %s", data)
|
|
return data
|