<?php


namespace App\Services;


use App\Models\Config;
use App\Models\Room;

class ChannelService
{

    public static function createRoomNotice($roomId)
    {
        $channelMessage = Config::where('field', 'channel_message')->first()->val;
        $channelMessage = json_decode($channelMessage, true);
        $chatId = $channelMessage['chatId'];
        $username = config('services.telegram.username');
        $room = Room::where('room_id', $roomId)->first();
        $text = "新房间通知\n";
        $text .= "‼️如果还未关注，请先关注 @{$username} 后再加入房间\n";
        $text .= "\n";
        $text .= "游戏：{$room->game_name}   {$room->rounds}局\n";
        $text .= "底分：{$room->base_score} USDT\n";
        $text .= "人数：{$room->participants}人\n";
        // $text .= "游戏介绍：{$room->introduction}\n";
        $text .= "-------------------\n";
        $text .= "‼️1.开始游戏前，非房主请点击准备，房主等待大家准备后，点击开始游戏。\n";
        $text .= "‼️2.游戏结束后，请务必上传双方和第三方的战绩截图。如出现争议，平台将以三方截图为依据进行审核，以确保比赛的公平与公正\n";
        $keyboard = [[
            ['text' => "加入房间", 'callback_data' => "channelJoin@@{$roomId}"]
        ]];
        return [
            'chat_id' => "@{$chatId}",
            'text' => $text,
            'reply_markup' => json_encode(['inline_keyboard' => $keyboard])
        ];


    }
}