33 lines
873 B
Python
33 lines
873 B
Python
import asyncio
|
|
import json
|
|
|
|
from aiogram import Bot, Dispatcher
|
|
|
|
from ai_agent import create_ai_agent
|
|
|
|
import tg.tg_database as database
|
|
|
|
from . import handlers
|
|
from . import tasks
|
|
|
|
|
|
async def main() -> None:
|
|
with open('tg.json', 'r') as file:
|
|
config = json.load(file)
|
|
print('Конфигурация загружена.')
|
|
|
|
bot = Bot(token=config['api_token'])
|
|
database.create_database(config['db_connection_string'])
|
|
create_ai_agent(config['openrouter_token'],
|
|
config['openrouter_model'],
|
|
config['openrouter_model_temp'],
|
|
database.DB)
|
|
|
|
dp = Dispatcher()
|
|
dp.include_router(handlers.router)
|
|
dp.startup.register(tasks.startup_task)
|
|
asyncio.create_task(tasks.daily_maintenance_task(bot))
|
|
await dp.start_polling(bot)
|
|
|
|
if __name__ == '__main__':
|
|
asyncio.run(main())
|