41 lines
1.2 KiB
Python
41 lines
1.2 KiB
Python
import argparse
|
|
import json
|
|
|
|
from vkbottle.bot import Bot, run_multibot
|
|
|
|
from ai_agent import create_ai_agent
|
|
|
|
import vk.vk_database as database
|
|
|
|
from . import handlers
|
|
from . import tasks
|
|
from .utils import MyAPI
|
|
|
|
|
|
if __name__ == '__main__':
|
|
parser = argparse.ArgumentParser(description='Telegram chat bot')
|
|
parser.add_argument('-c', '--config', type=str, required=True,
|
|
help='Path to the JSON configuration file')
|
|
args = parser.parse_args()
|
|
|
|
with open(args.config, 'r') as file:
|
|
config = json.load(file)
|
|
print('Конфигурация загружена.')
|
|
|
|
database.create_database(config['db_connection_string'])
|
|
|
|
create_ai_agent(config['openrouter_token'],
|
|
config['openrouter_model'],
|
|
config['openrouter_model_temp'],
|
|
database.DB)
|
|
|
|
bot = Bot(labeler=handlers.labeler)
|
|
|
|
apis: list[MyAPI] = []
|
|
for item in database.DB.get_bots():
|
|
api = MyAPI(item['id'], item['api_token'])
|
|
bot.loop_wrapper.on_startup.append(tasks.startup_task(api))
|
|
bot.loop_wrapper.add_task(tasks.daily_maintenance_task(api))
|
|
apis.append(api)
|
|
|
|
run_multibot(bot, apis)
|