This commit is contained in:
def 2022-09-09 10:22:27 +02:00
parent 2a98ebc7d1
commit 6ebbf6b907
4 changed files with 58 additions and 0 deletions

5
config.yaml Normal file
View file

@ -0,0 +1,5 @@
settings:
apscheduler_config = :
type: sqlalchemy
url: sqlite:///cron_jobs.db

39
loader.py Normal file
View file

@ -0,0 +1,39 @@
from aiogram import Bot
from aiogram.contrib.fsm_storage.memory import MemoryStorage
from aiogram.dispatcher import Dispatcher
from middlewares.database import DbMiddleware
import asyncio
import asyncpg
from apscheduler.schedulers.asyncio import AsyncIOScheduler
import os
from dotenv import load_dotenv
import pretty_errors
async def create_pool(database, user, password: None):
return await asyncpg.create_pool(database=database,
user=user)
loop = asyncio.get_event_loop()
load_dotenv()
TOKEN = os.getenv("TOKEN")
DB_NAME = os.getenv("DB_NAME")
DB_USER = os.getenv("DB_USER")
DB_PASS = os.getenv("DB_PASS")
pool = loop.run_until_complete(create_pool(DB_NAME, DB_USER, DB_PASS))
bot = Bot(token=TOKEN)
dp = Dispatcher(bot, storage=MemoryStorage())
dp.middleware.setup(DbMiddleware(pool))
apscheduler_config = {
'apscheduler.jobstores.default': {
'type': 'sqlalchemy',
'url': 'sqlite:///cron_jobs.db'
}
}
scheduler = AsyncIOScheduler(apscheduler_config)

10
main.py Normal file
View file

@ -0,0 +1,10 @@
#!/usr/bin/python
from aiogram import executor
from loader import dp
import handlers
if __name__ == '__main__':
handlers.register_handlers(dp)
executor.start_polling(dp, skip_updates=True)

4
requirements.txt Normal file
View file

@ -0,0 +1,4 @@
loguru
pretty_errors
pyyaml
aiogram