initial commit
This commit is contained in:
commit
fb9bff7556
|
|
@ -0,0 +1,21 @@
|
||||||
|
[project]
|
||||||
|
name = "wiki-bot"
|
||||||
|
version = "0.1.0"
|
||||||
|
description = "Bot for wiki-master"
|
||||||
|
authors = [
|
||||||
|
{name = "Pascal Phelipot",email = "pascal@phelipot.me"}
|
||||||
|
]
|
||||||
|
requires-python = ">=3.10,<4.0"
|
||||||
|
dependencies = [
|
||||||
|
"httpx (>=0.28.1,<0.29.0)",
|
||||||
|
"pendulum (>=3.2.0,<4.0.0)",
|
||||||
|
"sqlalchemy (>=2.0.51,<3.0.0)",
|
||||||
|
"loguru (>=0.7.3,<0.8.0)"
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
[build-system]
|
||||||
|
requires = ["poetry-core>=2.0.0,<3.0.0"]
|
||||||
|
build-backend = "poetry.core.masonry.api"
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,4 @@
|
||||||
|
import asyncio
|
||||||
|
from .app import main
|
||||||
|
|
||||||
|
asyncio.run(main())
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
from loguru import logger
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
from .lib.utils import EveryRunRotator
|
||||||
|
|
||||||
|
def setup():
|
||||||
|
logs_folder = Path(__file__).parents[1].joinpath("logs")
|
||||||
|
logs_folder.mkdir(exist_ok=True)
|
||||||
|
logger.debug("log file can be found in: {}", logs_folder.as_posix())
|
||||||
|
logger.info("Starting the bot...")
|
||||||
|
|
||||||
|
logger.add(logs_folder.joinpath("app.log"), retention=4, rotation=EveryRunRotator())
|
||||||
|
logger.add(logs_folder.joinpath("app.log.json"), serialize=True, rotation=EveryRunRotator(), retention=1, compression="gz")
|
||||||
|
|
||||||
|
async def main():
|
||||||
|
setup()
|
||||||
|
logger.info("Starting the bot...")
|
||||||
|
logger.trace("ho yeah")
|
||||||
|
|
@ -0,0 +1,13 @@
|
||||||
|
from io import TextIOWrapper
|
||||||
|
import os
|
||||||
|
|
||||||
|
class EveryRunRotator:
|
||||||
|
def __init__(self):
|
||||||
|
self.rotate = True
|
||||||
|
|
||||||
|
def __call__(self, _log, log_file: TextIOWrapper):
|
||||||
|
# we do not want to rotate if the current file is empty
|
||||||
|
if self.rotate and os.stat(log_file.name).st_size != 0:
|
||||||
|
self.rotate = False
|
||||||
|
return True
|
||||||
|
return False
|
||||||
Loading…
Reference in New Issue