import Foundation import Vapor @preconcurrency import SwiftTelegramSdk public func configure(_ app: Application) async throws { guard let tgApi: String = Environment.get("TG_BOT_API") else { throw Errors.notVariable("Telegram key is not defined") } app.logger.logLevel = .debug let bot: TGBot = try await .init(connectionType: .longpolling(limit: nil, timeout: nil, allowedUpdates: nil), dispatcher: nil, tgClient: VaporTGClient(client: app.client), tgURI: TGBot.standardTGURL, botId: tgApi, log: app.logger) await botActor.setBot(bot) await DefaultBotHandlers.addHandlers(bot) try await botActor.bot.start() // try routes(app) }