<?php

use Database\{Listbots, Profile, Settings, Shop};

if ($data == 'getCoin') {
    $coin = getStore('coininvite');
    $Telegram->EditMessageText($chatid, $MessageID, str_replace('#coin', $coin, msg('getCointxt')), 'html', '', true, $button_getcoin);

} elseif ($data == 'shop') {
    $list = Shop::getItems();
    if ($list == []) {
        $Telegram->EditMessageText($chatid, $MessageID, msg('notFoundItem'), 'html', '', true, $button_start);
        die();
    }
    $btn = [];
    foreach ($list as $item) {
        $msg = str_replace(['#coin', '#price', '#hot'], [$item->coin, $item->price, $item->hot == 1 ? '🔥' : ''], msg('ItemShop'));
        $url_pay = "https://jh.ashkancontrol.ir/payment/create_link.php?id=".$item->id."&userid=$chatid";
        if($url_pay !== "false"){
        $btn[] = [["text" => $msg, "url" => $url_pay]];
        }
    }
    $btn[] = [["text" => msg('backmenu'), "callback_data" => "back2"]];


    $Telegram->EditMessageText($chatid, $MessageID, msg('listItem'), 'html', '', true, [
        'inline_keyboard' =>
            $btn
        ,
        'resize_keyboard' => true
    ]);
} elseif (preg_match('/^([Bb]uyShop_)(.*)/', $data)) {
    $dta = str_replace(['buyShop_'], '', $data);
    $getSupportId = Settings::getSettings('idsupport');
    $Telegram->EditMessageText($chatid, $MessageID, str_replace(['#id'], ['' . $getSupportId], msg('buyByPv')), 'html', '', true, $button_start);

} elseif ($data == 'myUrl') {
    $getbot = getStore('botDefUserName');
    $cod = Profile::getUser($chatid)->cod;
    $urlin = $getbot . '?start=' . $cod;
    $Telegram->EditMessageText($chatid, $MessageID, str_replace(['#url'], [$urlin], msg('myLinkTxt')), 'html', '', true, $button_start);
}