<?php

declare(strict_types=1);

namespace kodorvan\edabil\models\telegram\commands;

// Files of the project
use kodorvan\edabil\models\core,
	kodorvan\edabil\models\account,
	kodorvan\edabil\models\settings,
	kodorvan\edabil\models\localization,
	kodorvan\edabil\models\telegram\processes\language\select as process_language_select;

// Library for languages support
use mirzaev\languages\language;

// The library for escaping all markdown symbols
use function mirzaev\unmarkdown;

// Framework for Telegram
use SergiX44\Nutgram\Nutgram as telegram,
	SergiX44\Nutgram\Telegram\Properties\ParseMode as mode,
	SergiX44\Nutgram\Telegram\Types\Message\Message as message,
	SergiX44\Nutgram\Handlers\Type\Command as command,
	SergiX44\Nutgram\Telegram\Types\Internal\InputFile as input,
	SergiX44\Nutgram\Telegram\Types\Keyboard\InlineKeyboardMarkup as keyboard,
	SergiX44\Nutgram\Telegram\Types\Keyboard\InlineKeyboardButton as button;

/**
 * Command: start
 *
 * @package kodorvan\edabil\models\telegram\commands
 *
 * @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
 * @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
 */
final class start extends command
{
	/**
	 * Command
	 *
	 * @var string $name Name of the command
	 */
	protected string $command = 'start';

	/**
	 * Description
	 *
	 * @var string $description
	 */
	protected ?string $description = 'Main menu';

	/**
	 * Localizations
	 *
	 * Descriptions of the command
	 *
	 * @var array $localizedDescriptions
	 */
	protected array $localizedDescriptions = [
		'ru' => 'Главное меню',
		'*' => 'Main menu'
	];

	/**
	 * Handle
	 *
	 * Processing the command
	 *
	 * @param telegram $robot The chat-robot instance
	 *
	 * @return void
	 */
	public function handle(telegram $robot): void
	{
		// Initializing the language
		$language = $robot->get('language') ?? LANGUAGE_DEFAULT;

		// Initializing the menu message localization
		$localization = $robot->get('localization') ?? new localization($language);

		// Initializing the account
		$account = $robot->get('account');

		// Initializing the keyboard
		$keyboard = keyboard::make();

		// Writing the row into the keyboard
		$keyboard->addRow(
			button::make(
				text: '🧠 Bebra',
				callback_data: 'bebra'
			)
		);

		$robot->sendMessage(
			text: implode(
				"\n\n",
				array_filter(
					[
						"📋 *$localization->menu_title*",
						unmarkdown($localization->menu_pipetc)
					]
				)
			),
			parse_mode: mode::MARKDOWN,
			disable_notification: true,
			reply_markup: $keyboard
		);
	}
}
