<?php

namespace App\Http\Traits;

use Illuminate\Support\Facades\Http;

trait TelegramTrait
{
    /*
     * 텔레그램 알림 메시지
     */
    protected function sendMessage(string $msg)
    {
        $token = TELEGRAM_BOT_TOKEN;
        $chatID = TELEGRAM_CHAT_ID;
        $url = sprintf('https://api.telegram.org/bot%s/sendMessage?chat_id=%d&text=%s', $token, $chatID, $msg);
        $response = Http::timeout(60)->retry(3, 100)->get($url);

        return $response->ok();
    }
}
