<commit_before><?php
/**
 * Inline Games - Telegram Bot (@inlinegamesbot)
 *
 * (c) 2017 Jack'lul <<EMAIL>>
 *
 * For the full copyright and license information, please view
 * the LICENSE file that was distributed with this source code.
 */

namespace Longman\TelegramBot\Commands\SystemCommands;

use Bot\Helper\DebugLog;
use Bot\Manager\Game;
use Longman\TelegramBot\Commands\SystemCommand;
use Longman\TelegramBot\Request;

/**
 * Class CallbackqueryCommand
 *
 * @package Longman\TelegramBot\Commands\SystemCommands
 */
class CallbackqueryCommand extends SystemCommand
{
    public function execute()
    {
        $callback_query = $this->getUpdate()->getCallbackQuery();

        DebugLog::log('Data: ' . $callback_query->getData());

        $game = new Game($callback_query->getInlineMessageId(), explode(';', $callback_query->getData())[0], $this);

        if ($game->canRun()) {
            return $game->run();
        }

        return Request::answerCallbackQuery(
            [
            'callback_query_id' => $callback_query->getId(),
            'text' => __("Bad request!"),
            'show_alert' => true,
            ]
        );
    }
}<commit_msg>Prevent older data triggering 'no id' exception<commit_after><?php
/**
 * Inline Games - Telegram Bot (@inlinegamesbot)
 *
 * (c) 2017 Jack'lul <<EMAIL>>
 *
 * For the full copyright and license information, please view
 * the LICENSE file that was distributed with this source code.
 */

namespace Longman\TelegramBot\Commands\SystemCommands;

use Bot\Helper\DebugLog;
use Bot\Manager\Game;
use Longman\TelegramBot\Commands\SystemCommand;
use Longman\TelegramBot\Request;

/**
 * Class CallbackqueryCommand
 *
 * @package Longman\TelegramBot\Commands\SystemCommands
 */
class CallbackqueryCommand extends SystemCommand
{
    public function execute()
    {
        $callback_query = $this->getUpdate()->getCallbackQuery();

        DebugLog::log('Data: ' . $callback_query->getData());

        $data = $callback_query->getData();

        if ($this->isDataValid($data)) {
            $game = new Game($callback_query->getInlineMessageId(), explode(';', $data)[0], $this);

            if ($game->canRun()) {
                return $game->run();
            }
        }

        return Request::answerCallbackQuery(
            [
            'callback_query_id' => $callback_query->getId(),
            'text' => __("Bad request!"),
            'show_alert' => true,
            ]
        );
    }

    private function isDataValid($data)
    {
        $data = explode(';', $data);

        if (count($data) >= 2) {
            return true;
        }

        return false;
    }
}
{'fraction_non_alphanumeric': 0.13850207000376363, 'fraction_numerical': 0.0041400075272864136, 'mean_word_length': 2.722689075630252, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5515982', 'n_tokens_mistral': 769, 'n_tokens_neox': 762, 'n_words': 169}