diff --git a/autotex/__main__.py b/autotex/__main__.py index a064e87f67e4d3b043fb94670d79d1c90089126c..825dc08183491e01404fe9397f08b73e849786fc 100644 --- a/autotex/__main__.py +++ b/autotex/__main__.py @@ -7,10 +7,8 @@ import tempfile from aiogram import Bot, Dispatcher, types import shutil -import os -import dotenv +from autotex import settings -dotenv.load_dotenv() pdftex_bin = shutil.which("pdflatex") magick_bin = shutil.which("magick") @@ -21,7 +19,7 @@ if magick_bin is None: raise ValueError("ImageMagick is not installed") dp = Dispatcher() -bot = Bot(token=os.environ["BOT_TOKEN"]) +bot = Bot(token=settings.BOT_TOKEN) PREAMBULA = """\ @@ -78,10 +76,10 @@ async def send_latex(message: types.Message) -> None: magick_bin, # type: ignore "convert", "-density", - "300", + str(settings.IMAGE_DPI), f"{name}.pdf", "-quality", - "100", + str(settings.IMAGE_QUALITY), f"{name}.jpg", cwd=cwd, stdout=asyncio.subprocess.PIPE, diff --git a/autotex/settings.py b/autotex/settings.py new file mode 100644 index 0000000000000000000000000000000000000000..0d937f6d357d74b6ddf24e5885d3429854993fb3 --- /dev/null +++ b/autotex/settings.py @@ -0,0 +1,8 @@ +import os +import dotenv + +dotenv.load_dotenv() + +BOT_TOKEN = os.environ["BOT_TOKEN"] +IMAGE_DPI = int(os.environ.get("IMAGE_DPI", 300)) +IMAGE_QUALITY = int(os.environ.get("IMAGE_QUALITY", 100))