lk.zachem.info/app/Modules/Bot/Http/Controllers/BotNotificationSender.php
2025-05-23 19:37:45 +08:00

29 lines
858 B
PHP

<?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;
}
}
}
}