Add the config file for DotsBotApi.
This commit is contained in:
@@ -0,0 +1,9 @@
|
|||||||
|
class DotsBotApiConfig():
|
||||||
|
_base_url = "https://domain"
|
||||||
|
|
||||||
|
def __str__(self) -> str:
|
||||||
|
return f"{self._base_url=}"
|
||||||
|
|
||||||
|
def get_base_url(self) -> str:
|
||||||
|
return self._base_url
|
||||||
|
|
||||||
@@ -2,15 +2,18 @@ import simplematrixbotlib as botlib
|
|||||||
import aiohttp
|
import aiohttp
|
||||||
import asyncio
|
import asyncio
|
||||||
import ujson
|
import ujson
|
||||||
|
from src.config.dots_bot_api_config import DotsBotApiConfig
|
||||||
|
|
||||||
from src.api.v2.city_api import CityAPI
|
from src.api.v2.city_api import CityAPI
|
||||||
from src.fetcher.v2.api_fetcher import ApiFetcher
|
from src.fetcher.v2.api_fetcher import ApiFetcher
|
||||||
from src.fmt.city_formatter import CityFormatter
|
from src.fmt.city_formatter import CityFormatter
|
||||||
|
|
||||||
|
dots_bot_api_config = DotsBotApiConfig()
|
||||||
|
|
||||||
async def list_cities_handler(room_id: str, bot: botlib.Bot, sender: str, admin_id: str):
|
async def list_cities_handler(room_id: str, bot: botlib.Bot, sender: str, admin_id: str):
|
||||||
|
|
||||||
session = aiohttp.ClientSession(json_serialize=ujson.dumps)
|
session = aiohttp.ClientSession(json_serialize=ujson.dumps)
|
||||||
apiFetcher = ApiFetcher("https://domain", session)
|
apiFetcher = ApiFetcher(dots_bot_api_config.get_base_url(), session)
|
||||||
formatter = CityFormatter()
|
formatter = CityFormatter()
|
||||||
cityAPI = CityAPI(apiFetcher, formatter)
|
cityAPI = CityAPI(apiFetcher, formatter)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user