chore: added new updates and moved the database instance to another file

This commit is contained in:
Danil 2025-05-15 14:54:39 +03:00
parent b5d8edcc38
commit b671981bb3
2 changed files with 5 additions and 4 deletions

3
bot.py
View file

@ -3,6 +3,9 @@ from aiogram.client.default import DefaultBotProperties
from aiogram.enums import ParseMode from aiogram.enums import ParseMode
import yaml import yaml
from database.server import Database
db = Database('/data/shirino.db')
config = yaml.safe_load(open('../config.yaml', 'r', encoding='utf-8')) config = yaml.safe_load(open('../config.yaml', 'r', encoding='utf-8'))
bot = Bot( bot = Bot(
token=config['telegram_token'], token=config['telegram_token'],

View file

@ -6,11 +6,9 @@ from aiogram import Dispatcher
from aiogram.webhook.aiohttp_server import SimpleRequestHandler, setup_application from aiogram.webhook.aiohttp_server import SimpleRequestHandler, setup_application
from commands import currency, start, settings from commands import currency, start, settings
from database.server import Database from bot import bot, db
from bot import bot
config = yaml.safe_load(open('../config.yaml', 'r', encoding='utf-8')) config = yaml.safe_load(open('../config.yaml', 'r', encoding='utf-8'))
db = Database('shirino.db')
async def on_startup(bot: bot) -> None: async def on_startup(bot: bot) -> None:
await db.connect() await db.connect()
@ -18,7 +16,7 @@ async def on_startup(bot: bot) -> None:
await bot.set_webhook( await bot.set_webhook(
f"{config['webhook']['base_url']}{config['webhook']['path']}", f"{config['webhook']['base_url']}{config['webhook']['path']}",
secret_token=config['webhook']['secret_token'], secret_token=config['webhook']['secret_token'],
allowed_updates=['inline_query', 'message'] allowed_updates=['inline_query', 'message', 'callback_query']
) )