generated from geekiot/python-template
Add [bot start]: add bot_token to start_bot & configure logger
This commit is contained in:
parent
a8d1104bbd
commit
1de731d7bc
2 changed files with 10 additions and 0 deletions
|
|
@ -1,11 +1,13 @@
|
||||||
__all__ = ["start_bot"]
|
__all__ = ["start_bot"]
|
||||||
|
|
||||||
|
|
||||||
|
from loguru import logger
|
||||||
from redis.asyncio.client import Redis
|
from redis.asyncio.client import Redis
|
||||||
from sqlalchemy.ext.asyncio import AsyncSession
|
from sqlalchemy.ext.asyncio import AsyncSession
|
||||||
|
|
||||||
|
|
||||||
async def start_bot(
|
async def start_bot(
|
||||||
|
bot_token: str,
|
||||||
redis_client: Redis,
|
redis_client: Redis,
|
||||||
database_session: AsyncSession,
|
database_session: AsyncSession,
|
||||||
) -> None: ...
|
) -> None: ...
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,21 @@
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
|
from config import settings, configure_logger
|
||||||
from bot import start_bot
|
from bot import start_bot
|
||||||
from db import session
|
from db import session
|
||||||
from redis_client import client
|
from redis_client import client
|
||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
|
configure_logger(
|
||||||
|
file_log_level=settings.file_log_level,
|
||||||
|
console_log_level=settings.console_log_level,
|
||||||
|
listen_logging=True,
|
||||||
|
)
|
||||||
|
|
||||||
asyncio.run(
|
asyncio.run(
|
||||||
start_bot(
|
start_bot(
|
||||||
|
bot_token=settings.bot_token,
|
||||||
redis_client=client,
|
redis_client=client,
|
||||||
database_session=session,
|
database_session=session,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue