<?php

use Database\{ QuestionUsers, Question};
use inc\{functions, fileStorage};

//region Accept Qus
if (preg_match('/^([Qq]usGameaccept_)(.*)/', $data)) {
    $dta = str_replace(['QusGameaccept_'], '', $data);
    if (QuestionUsers::hasQuestion($dta)) {
        $qus = QuestionUsers::getQuestion($dta);
        Question::addQuestion($qus->type, $qus->question, $qus->sex);
        fileStorage::removeFile('question');
        QuestionUsers::removeQuestion($dta);
        $Telegram->deleteMessage($chatid, $MessageID);
        $Telegram->answerCallbackQuery($Telegram->callback_query()->getId(), msg('DoneacceptQusGame'), false);
    }
}
//endregion Accept Qus
//region Reject Qus
if (preg_match('/^([Qq]usGamereject_)(.*)/', $data)) {
    $dta = str_replace(['QusGamereject_'], '', $data);
    if (QuestionUsers::hasQuestion($dta)) {
        QuestionUsers::removeQuestion($dta);
        $Telegram->deleteMessage($chatid, $MessageID);
        $Telegram->answerCallbackQuery($Telegram->callback_query()->getId(), msg('rejectQusGame'), false);
    }
}
//endregion Accept Qus
