@ -7,10 +7,8 @@ import tempfile
|
|||||||
|
|
||||||
from aiogram import Bot, Dispatcher, types
|
from aiogram import Bot, Dispatcher, types
|
||||||
import shutil
|
import shutil
|
||||||
import os
|
from autotex import settings
|
||||||
import dotenv
|
|
||||||
|
|
||||||
dotenv.load_dotenv()
|
|
||||||
|
|
||||||
pdftex_bin = shutil.which("pdflatex")
|
pdftex_bin = shutil.which("pdflatex")
|
||||||
magick_bin = shutil.which("magick")
|
magick_bin = shutil.which("magick")
|
||||||
@ -21,7 +19,7 @@ if magick_bin is None:
|
|||||||
raise ValueError("ImageMagick is not installed")
|
raise ValueError("ImageMagick is not installed")
|
||||||
|
|
||||||
dp = Dispatcher()
|
dp = Dispatcher()
|
||||||
bot = Bot(token=os.environ["BOT_TOKEN"])
|
bot = Bot(token=settings.BOT_TOKEN)
|
||||||
|
|
||||||
|
|
||||||
PREAMBULA = """\
|
PREAMBULA = """\
|
||||||
@ -78,10 +76,10 @@ async def send_latex(message: types.Message) -> None:
|
|||||||
magick_bin, # type: ignore
|
magick_bin, # type: ignore
|
||||||
"convert",
|
"convert",
|
||||||
"-density",
|
"-density",
|
||||||
"300",
|
str(settings.IMAGE_DPI),
|
||||||
f"{name}.pdf",
|
f"{name}.pdf",
|
||||||
"-quality",
|
"-quality",
|
||||||
"100",
|
str(settings.IMAGE_QUALITY),
|
||||||
f"{name}.jpg",
|
f"{name}.jpg",
|
||||||
cwd=cwd,
|
cwd=cwd,
|
||||||
stdout=asyncio.subprocess.PIPE,
|
stdout=asyncio.subprocess.PIPE,
|
||||||
|
8
autotex/settings.py
Normal file
8
autotex/settings.py
Normal file
@ -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))
|
Reference in New Issue
Block a user