<?php

namespace Modules\Bot\Http\Controllers;

use App\Modules\Bot\Models\UserBot;
use Illuminate\Support\Facades\Log;

class BotNotificationSender {

    public static function routeMessage(int $userId, string $message): void
    {
        $userBots = UserBot::where('user_id', $userId)->with('bot')->get(); 

        foreach ($userBots as $userBot) {
            switch ($userBot->bot->type) {
                case config('bot.telegram_type'):
                    TelegramBot::sendMessage($userBot->user_bot_id, $message);
                    break;
                case config('bot.vk_type'):
                    VkBot::sendMessage($userBot->user_bot_id, $message);
                    break;
                default:
                    Log::warning("Unknown bot type: {$userBot->bot->type}");
                    break;
            }
        }
    }
}
