<?php

use Database\Games;

if ($Telegram->isMessage()) {
    if ($Telegram->message()->getViaBot()->getUsername() == USERNAME_BOT) {
        $dt = $Telegram->data['message']['reply_markup']['inline_keyboard'][1][0]['callback_data'];
        $rand_id = explode('_', $dt)[1];
        if (Games::hasGame($rand_id)) {
            Games::updateMsgId($rand_id, $Telegram->MessageID());
            Games::updateChatid($rand_id, $chatid);
        }
    }
}

if ($Telegram->isEditedMessage()) {
    if ($Telegram->edited_message()->getViaBot()->getUsername() == USERNAME_BOT) {
        $dt = $Telegram->data['edited_message']['reply_markup']['inline_keyboard'][0][0]['switch_inline_query_current_chat'];
        file_put_contents('1.json',json_encode($Telegram->data['edited_message']['reply_markup']['inline_keyboard']));
        $rand_id = explode('_', $dt)[1];
        if (Games::hasGame($rand_id)) {
            Games::updateMsgId($rand_id, $Telegram->MessageID());
        }
    }

}