added logging to file + fonts + .env file
This commit is contained in:
parent
d9ae6527a1
commit
41d7dd066b
1
.env.template
Normal file
1
.env.template
Normal file
@ -0,0 +1 @@
|
|||||||
|
TELEGRAM_TOKEN=
|
@ -14,13 +14,26 @@ from bs4 import BeautifulSoup
|
|||||||
from telegram import Update
|
from telegram import Update
|
||||||
from telegram.ext import ApplicationBuilder, CommandHandler, ContextTypes
|
from telegram.ext import ApplicationBuilder, CommandHandler, ContextTypes
|
||||||
|
|
||||||
|
log_dir = os.getenv("BEEBOT_LOGS")
|
||||||
|
if not log_dir:
|
||||||
|
log_dir = "/mnt/logs"
|
||||||
|
if not os.path.exists(log_dir):
|
||||||
|
os.mkdir(log_dir)
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
format="[%(asctime)s] %(name)s/%(levelname)s - %(message)s",
|
format="[%(asctime)s] %(name)s/%(levelname)s - %(message)s",
|
||||||
level=logging.INFO
|
level=logging.INFO,
|
||||||
|
handlers=[
|
||||||
|
logging.FileHandler(
|
||||||
|
os.path.join(
|
||||||
|
log_dir,
|
||||||
|
datetime.datetime.today().strftime("%Y%m%d-%H%M%S.log")
|
||||||
|
)
|
||||||
|
),
|
||||||
|
logging.StreamHandler()
|
||||||
|
]
|
||||||
)
|
)
|
||||||
logging.getLogger("httpx").setLevel(logging.WARNING)
|
logging.getLogger("httpx").setLevel(logging.WARNING)
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
logger.setLevel(logging.DEBUG)
|
|
||||||
|
|
||||||
class BeeBot:
|
class BeeBot:
|
||||||
MENU_URL = "https://www.epfl.ch/campus/restaurants-shops-hotels/fr/industrie21-epfl-valais-wallis/?date={date}"
|
MENU_URL = "https://www.epfl.ch/campus/restaurants-shops-hotels/fr/industrie21-epfl-valais-wallis/?date={date}"
|
||||||
@ -142,7 +155,7 @@ class BeeBot:
|
|||||||
|
|
||||||
def save_cache(self):
|
def save_cache(self):
|
||||||
with open(self.CACHE_PATH, "w") as f:
|
with open(self.CACHE_PATH, "w") as f:
|
||||||
json.dump(self.cache, f)
|
json.dump(self.cache, f, indent=4)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_img_id(today_only: bool, categories: set[str]) -> str:
|
def get_img_id(today_only: bool, categories: set[str]) -> str:
|
||||||
|
BIN
src/fonts/LiberationSans-Bold.ttf
Normal file
BIN
src/fonts/LiberationSans-Bold.ttf
Normal file
Binary file not shown.
BIN
src/fonts/LiberationSans-BoldItalic.ttf
Normal file
BIN
src/fonts/LiberationSans-BoldItalic.ttf
Normal file
Binary file not shown.
BIN
src/fonts/LiberationSans-Italic.ttf
Normal file
BIN
src/fonts/LiberationSans-Italic.ttf
Normal file
Binary file not shown.
BIN
src/fonts/LiberationSans-Regular.ttf
Normal file
BIN
src/fonts/LiberationSans-Regular.ttf
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user