2 Commits
0.3.0 ... 0.5.0

Author SHA1 Message Date
ebba2a970e architecture, hours, settings, creating process logics 2026-02-23 23:34:24 +05:00
8d83ab152f created the calculator 2026-02-08 21:58:22 +05:00
27 changed files with 1755 additions and 401 deletions

View File

@@ -37,7 +37,9 @@
"react/filesystem": "^0.1.2", "react/filesystem": "^0.1.2",
"nyholm/psr7": "^1.8", "nyholm/psr7": "^1.8",
"irazasyed/telegram-bot-sdk": "^3.15", "irazasyed/telegram-bot-sdk": "^3.15",
"nutgram/nutgram": "^4.40" "nutgram/nutgram": "^4.42",
"psr/simple-cache": "^3.0",
"symfony/cache": "^8.0"
}, },
"suggest": { "suggest": {
"mirzaev/files": "Easy working with files", "mirzaev/files": "Easy working with files",

14
composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "4cea1a922de2838a239ca7633443750c", "content-hash": "44219ee87ec9e34c98a5404150eb4ac0",
"packages": [ "packages": [
{ {
"name": "badfarm/zanzara", "name": "badfarm/zanzara",
@@ -1923,16 +1923,16 @@
}, },
{ {
"name": "nutgram/nutgram", "name": "nutgram/nutgram",
"version": "4.40.2", "version": "4.42.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/nutgram/nutgram.git", "url": "https://github.com/nutgram/nutgram.git",
"reference": "caf0deb11f6dae93b407f5bb85a94d5336a1b945" "reference": "034257dbc29947b73e04b5d92b07d780d8962810"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/nutgram/nutgram/zipball/caf0deb11f6dae93b407f5bb85a94d5336a1b945", "url": "https://api.github.com/repos/nutgram/nutgram/zipball/034257dbc29947b73e04b5d92b07d780d8962810",
"reference": "caf0deb11f6dae93b407f5bb85a94d5336a1b945", "reference": "034257dbc29947b73e04b5d92b07d780d8962810",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -1994,7 +1994,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/nutgram/nutgram/issues", "issues": "https://github.com/nutgram/nutgram/issues",
"source": "https://github.com/nutgram/nutgram/tree/4.40.2" "source": "https://github.com/nutgram/nutgram/tree/4.42.0"
}, },
"funding": [ "funding": [
{ {
@@ -2006,7 +2006,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2026-01-25T17:57:40+00:00" "time": "2026-02-12T17:23:52+00:00"
}, },
{ {
"name": "nyholm/psr7", "name": "nyholm/psr7",

View File

@@ -25,6 +25,8 @@ return [
'settings_language_button_add' => 'Add a language', 'settings_language_button_add' => 'Add a language',
// Authorization // Authorization
'authorization_system' => 'System',
'authorization_settings' => 'Settings',
'not_authorized_system' => 'You do not have access to the system', 'not_authorized_system' => 'You do not have access to the system',
'not_authorized_settings' => 'You do not have access to the settings', 'not_authorized_settings' => 'You do not have access to the settings',
'not_authorized_system_settings' => 'You do not have access to the system settings', 'not_authorized_system_settings' => 'You do not have access to the system settings',

View File

@@ -10,7 +10,7 @@ return [
// Главное меню // Главное меню
'menu_title' => 'Главное меню', 'menu_title' => 'Главное меню',
'menu_description_guest' => "🔥 *Создайте ваш первый проект* и получите *ориентировочную стоимость* всего за 2 минуты", 'menu_description_guest' => "🔥 *Создайте ваш первый проект* и получите *ориентировочную стоимость* всего за 2 минуты",
'menu_description_partner' => "*Благодарю за выбор нашей команды*. Теперь Вы один из наших %d партнёров!", 'menu_description_partner' => "*Благодарю за выбор нашей команды*\. Теперь Вы один из наших %d партнёров!",
'menu_update' => 'Последнее обновление', 'menu_update' => 'Последнее обновление',
'menu_button_project_new' => 'Создать', 'menu_button_project_new' => 'Создать',
'menu_button_projects' => 'Проекты', 'menu_button_projects' => 'Проекты',
@@ -22,6 +22,59 @@ return [
'account_authorized_settings' => 'Доступ к изменению настроек', 'account_authorized_settings' => 'Доступ к изменению настроек',
'account_authorized_system_settings' => 'Системный доступ к системным настройкам', 'account_authorized_system_settings' => 'Системный доступ к системным настройкам',
// Проект: создание
'project_create_title' => 'Создание проекта',
/* 'project_create_description' => "Расчитайте ориентировочное время разработки, затем выберите разработчиков и получите стоимость\n\nПосле расчётов можно будет отправить проект в заказ разработчикам и приложить ТЗ, либо краткое описание задачи\n\nМы погружаемся в проекты полностью, поэтому стараемся не распыляться - от степени нагрузки меняется коэффициент стоимости!", */
'project_create_description' => "Задайте параметры и получите ориентировочное время разработки, затем выберите разработчиков и получите стоимость их работы\n\nосле расчётов можно отправить проект в заказ и приложить ТЗ, либо описание задачи_",
'project_create_time' => 'Время разработки',
'project_create_time_hours' => 'ч',
'project_create_time_hours_from' => 'от',
'project_create_button_request' => 'Заказать',
'project_create_architectures_title' => 'Выбор архитектуры проекта',
'project_create_architectures_description' => 'Каждая архитектура имеет уникальные параметры и коэффициенты \- это основа дальнейших расчётов\!',
'project_create_button_architecture' => 'Архитектура',
'project_create_button_architecture_selected' => 'Архитектура',
'project_create_purposes_title' => 'Выбор назначения',
'project_create_purposes_description' => 'Вектор разработки, основание проекта',
'project_create_button_purpose' => 'Назначение',
'project_create_button_purpose_selected' => 'Назнач.',
'project_create_integrations_title' => 'Выбор интеграций',
'project_create_integrations_description' => 'Синхронизация, скачивание, загрузка, запись...',
'project_create_button_integrations' => 'Интеграции',
'project_create_button_integrations_selected' => 'Интеграции',
'project_create_requested' => 'Проект создан и отправлен оператору',
'project_create_cancelled' => 'Создание проекта отменено',
// Проект: типы
'project_architecture_chat_robot' => 'Чат-робот',
'project_architecture_parser' => 'Парсер',
'project_architecture_calculator' => 'Калькулятор',
'project_architecture_crm' => 'CRM',
'project_architecture_site' => 'Сайт',
'project_architecture_program' => 'Программа',
'project_architecture_complex' => 'Нестандартная',
// Проект: назначение
'project_purpose_funnel' => 'Воронка',
'project_purpose_contact' => 'Контакты',
'project_purpose_neural_network' => 'Нейросеть',
'project_purpose_gallery' => 'Галерея',
'project_purpose_crm' => 'CRM',
'project_purpose_landing' => 'Лендинг',
'project_purpose_marketplace' => 'Маркетплейс',
'project_purpose_charity' => 'Благотворительность',
'project_purpose_search' => 'Поиск',
'project_purpose_calculate' => 'Расчёт',
'project_purpose_tools' => 'Инструменты',
'project_purpose_workers' => 'Рабочие',
'project_purpose_objects' => 'Предметы',
'project_purpose_events' => 'События',
'project_purpose_special' => 'Особенный',
// Настройки: язык // Настройки: язык
'settings_language_title' => 'Выбери язык', 'settings_language_title' => 'Выбери язык',
'settings_language_description' => 'Выбранный язык будет использоваться для генерации системного отображения', 'settings_language_description' => 'Выбранный язык будет использоваться для генерации системного отображения',
@@ -30,6 +83,8 @@ return [
'settings_language_button_add' => 'Добавить язык', 'settings_language_button_add' => 'Добавить язык',
// Авторизация // Авторизация
'authorization_system' => 'Система',
'authorization_settings' => 'Настройки',
'not_authorized_system' => 'У тебя нет доступа к системе', 'not_authorized_system' => 'У тебя нет доступа к системе',
'not_authorized_settings' => 'У тебя нет доступа к настройкам', 'not_authorized_settings' => 'У тебя нет доступа к настройкам',
'not_authorized_system_settings' => 'У тебя нет доступа к системным настройкам', 'not_authorized_system_settings' => 'У тебя нет доступа к системным настройкам',

View File

@@ -15,6 +15,9 @@ use kodorvan\constructor\models\core,
// The library for languages support // The library for languages support
use mirzaev\languages\language; use mirzaev\languages\language;
// The library for currencies support
use mirzaev\currencies\currency;
// Baza database // Baza database
use mirzaev\baza\database, use mirzaev\baza\database,
mirzaev\baza\column, mirzaev\baza\column,

View File

@@ -0,0 +1,226 @@
<?php
declare(strict_types=1);
namespace kodorvan\constructor\models\project\enumerations;
// Files of the project
use kodorvan\constructor\models\project\enumerations\purpose;
// The library for languages support
use mirzaev\languages\language;
// The library for currencies support
use mirzaev\currencies\currency;
// Built-in libraries
use InvalidArgumentException as exception_argument,
DomainException as exception_domain;
/**
* Architecture
*
* @package kodorvan\neurobot\models\project\enumerations
*
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/
enum architecture
{
case chat_robot;
case parser;
case script;
case crm;
case site;
case program;
/* case calculator; */
case complex;
/**
* Label
*
* @param language $language The language
*
* @return string The project architecture label
*/
public function label(language $language = LANGUAGE_DEFAULT): string
{
// Exit (success)
return match ($this) {
static::chat_robot => match ($language) {
language::en => 'Chat-robot',
language::ru => 'Чат-робот'
},
static::parser => match ($language) {
language::en => 'Parser',
language::ru => 'Парсер'
},
static::script => match ($language) {
language::en => 'Script',
language::ru => 'Скрипт'
},
static::crm => match ($language) {
default => 'CRM'
},
static::site => match ($language) {
language::en => 'Site',
language::ru => 'Сайт'
},
static::program => match ($language) {
language::en => 'Program',
language::ru => 'Программа'
},
static::complex => match ($language) {
language::en => 'Non-standart',
language::ru => 'Нестандартный'
}
};
}
/**
* Length
*
* @return int Amount of buttons cells length
*/
public function length(): int
{
// Exit (success)
return match ($this) {
static::chat_robot => 2,
static::parser => 1,
static::script => 1,
static::crm => 1,
static::site => 1,
static::program => 1,
static::complex => 2,
default => 1
};
}
/**
* Purposes
*
* @return array Purposes
*/
public function purposes(): array
{
// Exit (success)
return match ($this) {
static::chat_robot => [
purpose::funnel,
purpose::contact,
purpose::neural_network,
purpose::game,
purpose::gallery,
purpose::crm,
purpose::calculate,
purpose::landing,
purpose::marketplace,
purpose::events,
purpose::charity
],
static::parser => [
purpose::search
],
static::script => [
purpose::logic
],
static::crm => [
purpose::workers,
purpose::tools,
purpose::objects,
purpose::events
],
static::site => [
purpose::funnel,
purpose::contact,
purpose::neural_network,
purpose::gallery,
purpose::crm,
purpose::calculate,
purpose::landing,
purpose::marketplace,
purpose::workers,
purpose::tools,
purpose::objects,
purpose::events,
purpose::charity
],
static::program => [
purpose::neural_network,
purpose::crm,
purpose::calculate,
purpose::marketplace,
purpose::workers,
purpose::tools,
purpose::objects,
purpose::events,
purpose::charity
],
default => []
};
}
/**
* Cost
*
* @return int|float The minimal cost of the project development
*
* @deprecated
*/
public function cost(currency $currency = CURRENCY_DEFAULT): int|float
{
// Exit (success)
return match ($this) {
static::chat_robot => match ($currency) {
currency::usd => 20,
currency::rub => 2000
},
static::parser => match ($currency) {
currency::usd => 35,
currency::rub => 3500
},
static::script => match ($currency) {
currency::usd => 10,
currency::rub => 1000
},
static::crm => match ($currency) {
currency::usd => 100,
currency::rub => 8000
},
static::site => match ($currency) {
currency::usd => 50,
currency::rub => 5000
},
static::program => match ($currency) {
currency::usd => 70,
currency::rub => 6000
},
static::complex => match ($currency) {
currency::usd => 100,
currency::rub => 10000
}
};
}
/**
* Coefficient
*
* @return int The project development hours
*/
public function coefficient(): int|float
{
// Exit (success)
return (int) match ($this) {
static::chat_robot => 3,
static::parser => 2,
static::script => 1,
static::crm => 6,
static::site => 3,
static::program => 4,
static::complex => 5,
default => 5
};
}
}

View File

@@ -0,0 +1,188 @@
<?php
declare(strict_types=1);
namespace kodorvan\constructor\models\project\enumerations;
// The library for languages support
use mirzaev\languages\language;
// Built-in libraries
use InvalidArgumentException as exception_argument,
DomainException as exception_domain;
/**
* Purpose
*
* @package kodorvan\neurobot\models\project\enumerations
*
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/
enum purpose
{
case funnel;
case contact;
case neural_network;
case gallery;
case crm;
case landing;
case marketplace;
case charity;
case search;
case calculate;
case logic;
case game;
case workers;
case tools;
case objects;
case events;
case special;
/**
* Label
*
* @param language $language The language
*
* @return string The project form label
*/
public function label(language $language = LANGUAGE_DEFAULT): string
{
// Exit (success)
return match ($this) {
static::funnel => match ($language) {
language::en => 'Funnel',
language::ru => 'Воронка'
},
static::contact => match ($language) {
language::en => 'Contact',
language::ru => 'Контакты'
},
static::neural_network => match ($language) {
language::en => 'Neural network',
language::ru => 'Нейросеть'
},
static::game => match ($language) {
language::en => 'Game',
language::ru => 'Игра'
},
static::gallery => match ($language) {
language::en => 'Gallery',
language::ru => 'Галерея'
},
static::crm => match ($language) {
default => 'CRM'
},
static::landing => match ($language) {
language::en => 'Landing',
language::ru => 'Лендинг'
},
static::marketplace => match ($language) {
language::en => 'Marketplace',
language::ru => 'Маркетплейс'
},
static::charity => match ($language) {
language::en => 'Charity',
language::ru => 'Благотворительность'
},
static::search => match ($language) {
language::en => 'Search',
language::ru => 'Поиск'
},
static::calculate => match ($language) {
language::en => 'Calculate',
language::ru => 'Расчёты'
},
static::logic => match ($language) {
language::en => 'Logic',
language::ru => 'Логика'
},
static::game => match ($language) {
language::en => 'Game',
language::ru => 'Игра'
},
static::workers => match ($language) {
language::en => 'Workes',
language::ru => 'Рабочие'
},
static::tools => match ($language) {
language::en => 'Tools',
language::ru => 'Инструменты'
},
static::objects => match ($language) {
language::en => 'Objects',
language::ru => 'Предметы'
},
static::events => match ($language) {
language::en => 'Events',
language::ru => 'События'
},
static::special => match ($language) {
language::en => 'Special',
language::ru => 'Особенный'
}
};
}
/**
* Length
*
* @return int Amount of buttons cells length
*/
public function length(): int
{
// Exit (success)
return match ($this) {
static::funnel => 2,
static::contact => 2,
static::neural_network => 3,
static::game => 1,
static::gallery => 1,
static::crm => 1,
static::landing => 1,
static::marketplace => 2,
static::charity => 2,
static::search => 2,
static::calculate => 2,
static::logic => 1,
static::tools => 1,
static::workers => 1,
static::objects => 1,
static::events => 1,
static::special => 4,
default => 1
};
}
/**
* Coefficient
*
* @return int|float Coefficient to the project development hours
*/
public function coefficient(): int|float
{
// Exit (success)
return match ($this) {
static::funnel => 1.4,
static::contact => 1.1,
static::neural_network => 2,
static::game => 3,
static::gallery => 1,
static::crm => 3,
static::landing => 1.2,
static::marketplace => 2,
static::charity => 0.8,
static::search => 1,
static::calculate => 1.1,
static::logic => 1,
static::tools => 1,
static::workers => 1.2,
static::objects => 1,
static::events => 1.5,
static::special => 2,
default => 1
};
}
}

View File

@@ -1,30 +0,0 @@
<?php
declare(strict_types=1);
namespace kodorvan\constructor\models\project\enumerations;
// Built-in libraries
use InvalidArgumentException as exception_argument,
DomainException as exception_domain;
/**
* Type
*
* @package kodorvan\neurobot\models\project\enumerations
*
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/
enum type
{
case telegram_voronka;
case parser;
case calculator;
case crm;
case marketplace;
case site;
case program;
case special;
}

View File

@@ -1,121 +0,0 @@
<?php
declare(strict_types=1);
namespace kodorvan\constructor\models\telegram;
// Files of the project
use kodorvan\constructor\models\core,
kodorvan\constructor\models\account,
kodorvan\constructor\models\settings,
kodorvan\constructor\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 Zanzara\Context as context,
Zanzara\Telegram\Type\Message as message,
Zanzara\Telegram\Type\Input\InputFile as file_input;
/**
* Telegram commands
*
* @package kodorvan\constructor\models\telegram
*
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/
final class commands extends core
{
/**
* Account
*
* Responce for the command: "/account"
*
* Sends information about account with menu
*
* @param context $context Request data from Telegram
*
* @return void
*/
public static function account(context $context): void
{
// Initializing the account
$account = $context->get('account');
if ($account instanceof account) {
// Initialized the account
// Initializing localization
$localization = $context->get('localization');
if ($localization) {
// Initialized localization
// Initializing title for the message
$title = '🫵 ' . $localization['account_title'];
// Declaring buufer of rows about authorizations
$authorizations = '';
// Initializing rows about authorization
foreach ($account->values() as $key => $value) {
// Iterating over account parameters
if (str_starts_with($key, 'authorized_')) {
// Iterating over account authorizations
// Skipping system authorizations
if (str_starts_with($key, 'authorized_system_')) continue;
// Writing into buffer of rows about authorizations
$authorizations .= ($value ? '✅' : '❎') . ' *' . ($localization["account_$key"] ?? $key) . ':* ' . ($value ? $localization['yes'] : $localization['no']) . "\n";
}
}
// Trimming the last line break character
$authorizations = trim($authorizations, "\n");
// Sending the message
$context->sendMessage(
<<<TXT
$title
$authorizations
TXT,
[
'reply_markup' => [
'remove_keyboard' => true,
'disable_notification' => true
],
'link_preview_options' => [
'is_disabled' => true
]
]
);
} else {
// Not initialized localization
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize localization*')
->then(function (message $message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
}
} else {
// Not initialized the account
// Sending the message
$context->sendMessage('⚠️ *Failed to initialize your Telegram account*')
->then(function (message $message) use ($context) {
// Ending the conversation process
$context->endConversation();
});
}
}
}

View File

@@ -0,0 +1,118 @@
<?php
declare(strict_types=1);
namespace kodorvan\constructor\models\telegram\commands;
// Files of the project
use kodorvan\constructor\models\core,
kodorvan\constructor\models\account as model,
kodorvan\constructor\models\settings,
kodorvan\constructor\models\localization,
kodorvan\constructor\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: account
*
* @package kodorvan\constructor\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 account extends command
{
/**
* Command
*
* @var string $name Name of the command
*/
protected string $command = 'account';
/**
* Description
*
* @var string $description
*/
protected ?string $description = 'Account profile';
/**
* Localizations
*
* Descriptions of the command
*
* @var array $localizedDescriptions
*/
protected array $localizedDescriptions = [
'ru' => 'Профиль аккаунта',
'*' => 'Account profile'
];
/**
* 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');
// Declaring buufer of rows about authorizations
$authorizations = '';
// Initializing rows about authorization
foreach ($account->authorizations()?->record->values() as $key => $value) {
// Iterating over account parameters
if (match ($key) {
'identifier', 'account', 'active', 'updated', 'created' => false,
default => true
} && !str_starts_with($key, 'system_')) {
// The value is not metadata and system authorozations
// Writing into buffer of rows about authorizations
$authorizations .= ($value ? '✅' : '❎') . ' *' . ($localization["authorization_$key"] ?? $key) . ':* ' . ($value ? $localization->yes : $localization->no) . "\n";
}
}
// Trimming the last line break character
$authorizations = trim($authorizations, "\n");
$robot->sendMessage(
text: implode(
"\n\n",
[
"🫵 *$localization->account_title*",
$authorizations
]
),
parse_mode: mode::MARKDOWN,
disable_notification: true
);
}
}

View File

@@ -119,10 +119,13 @@ final class language extends command
// Initializing buffer of languages // Initializing buffer of languages
$languages = type::cases(); $languages = type::cases();
// Deleting the actual language from buffer of languages // Initializing the selected language index
unset($languages[array_search($language, $languages, strict: true)]); $selected = array_search($language, $languages, strict: true);
// Sorting buffer of languages by the actual language // Exclude the selected language from buffer of languages
if ($selected !== false) unset($languages[$selected]);
// Sorting buffer of languages by the selected language
$languages = [$language, ...$languages]; $languages = [$language, ...$languages];
foreach ($languages as $language) { foreach ($languages as $language) {

View File

@@ -111,7 +111,7 @@ final class start extends command
$keyboard->addRow( $keyboard->addRow(
button::make( button::make(
text: "📡 $localization->menu_button_operator", text: "📡 $localization->menu_button_operator",
callback_data: 'operator' url: PROJECT_OPERATOR_URL ?? PROJECT_MEDIA_URL ?? 'https://t.me/kodorvan'
) )
); );

View File

@@ -0,0 +1,977 @@
<?php
declare(strict_types=1);
namespace kodorvan\constructor\models\telegram\conversations\project;
// Files of the project
use kodorvan\constructor\models\core,
kodorvan\constructor\models\account,
kodorvan\constructor\models\localization,
kodorvan\constructor\models\settings,
kodorvan\constructor\models\project\enumerations\architecture as project_architecture,
kodorvan\constructor\models\project\enumerations\purpose as project_purpose,
kodorvan\constructor\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\Conversations\InlineMenu as menu,
SergiX44\Nutgram\Telegram\Properties\ParseMode as mode,
SergiX44\Nutgram\Handlers\Type\Command as command,
SergiX44\Nutgram\Telegram\Types\Message\Message as message,
SergiX44\Nutgram\Telegram\Types\Internal\InputFile as input,
SergiX44\Nutgram\Telegram\Types\Keyboard\InlineKeyboardMarkup as keyboard,
SergiX44\Nutgram\Telegram\Types\Keyboard\InlineKeyboardButton as button;
// Built-in libraries
use Error as error;
/**
* Telegram project
*
* @package kodorvan\constructor\models\telegram
*
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/
final class create extends menu
{
/**
* Text
*
* @var string $text The message text
*/
public string $text = '';
/**
* Architecture
*
* @var project_architecture $architecture The project architecture
*/
public project_architecture $architecture;
/**
* Purpose
*
* @var project_purpose $purpose The project purpose
*/
public project_purpose $purpose;
/**
* Start
*
* Generate the project create menu and start the process
*
* @param telegram $robot The robot
* @param bool $new Create a new process?
*
* @return void
*/
public function start(telegram $robot, bool $new = true): void
{
if ($new) {
// Requested creating a new process
// Ending the conversation
$robot->endConversation();
}
// Initializing the account language
$language = $robot->get('language') ?? LANGUAGE_DEFAULT;
// Initializing the account localization
$localization = $robot->get('localization') ?? new localization($language);
// Initializing the account
$account = $robot->get('account');
// Initializing the project development hours
$hours = $this->hours();
// Generating the message text
$text = implode(
"\n\n",
[
"🏛 *$localization->project_create_title*",
/* $hours > 0 ? "*$localization->project_create_time* " . unmarkdown((string) $hours) . " $localization->hours" : $localization->project_create_description */
$hours > 0
? "*$localization->project_create_time:* $hours$localization->project_create_time_hours"
: $localization->project_create_description,
]
);
if ($this->text !== $text) {
$this->menuText(
text: $text,
opt: [
'parse_mode' => mode::MARKDOWN
]
);
}
if (isset($this->architecture)) {
// Initialized the project architecture
// Initializing the buffer for the first row
$first = [];
// Writing the project architecture button into the buffer of the first row
$first[0] = button::make(
text: $localization['project_architecture_' . $this->architecture?->name] ?? $this->architecture?->label(language: $language),
callback_data: '@architectures'
);
if (isset($this->purpose) || $this->architecture === project_architecture::complex) {
// Initialized the project purpose
// Writing the project purpose button into the buffer of the first row
$first[1] = button::make(
text: $localization['project_purpose_' . $this->purpose?->name] ?? $this->purpose?->label(language: $language),
callback_data: '@purposes'
);
// Writing the project buttons first row
$this->addButtonRow(...$first);
// Initializing the row
$row = [];
// Initializing the maximum amount of buttons in a row
$break = 2;
if (match ($this->architecture) {
project_architecture::chat_robot,
project_architecture::parser,
project_architecture::crm,
project_architecture::site,
project_architecture::program,
project_architecture::complex => true,
default => false
}) {
// Integrations
if (isset($this->integrations)) {
// Initialized the project integrations
} else {
// Not initialized the project integrations
}
}
if (match ($this->architecture) {
project_architecture::chat_robot,
project_architecture::parser,
project_architecture::crm,
project_architecture::site,
project_architecture::program,
project_architecture::complex => true,
default => false
}) {
// Server
if (isset($this->server)) {
// Initialized the project server
} else {
// Not initialized the project server
}
}
if (match ($this->architecture) {
project_architecture::crm,
project_architecture::site,
project_architecture::program,
project_architecture::complex => true,
default => false
}) {
// Interface
if (isset($this->interface)) {
// Initialized the project interface
if ($this->architecture === project_architecture::crm) {
// CRM
// site, mobile or desktop program
} else if ($this->architecture === project_architecture::program) {
// Program
// mobile or desktop
}
} else {
// Not initialized the project interface
if ($this->architecture === project_architecture::crm) {
// CRM
// site, mobile or desktop program
} else if ($this->architecture === project_architecture::program) {
// Program
// mobile or desktop
}
}
}
if (match ($this->architecture) {
project_architecture::chat_robot,
project_architecture::parser,
project_architecture::crm,
project_architecture::site,
project_architecture::program,
project_architecture::complex => true,
default => false
}) {
// Repository
if (isset($this->repository)) {
// Initialized the project repository
} else {
// Not initialized the project repository
}
}
if (match ($this->architecture) {
project_architecture::chat_robot,
project_architecture::parser,
project_architecture::crm,
project_architecture::site,
project_architecture::program,
project_architecture::complex => true,
default => false
}) {
// Launch strategy (fast, quality, progressively)
if (isset($this->strategy)) {
// Initialized the project strategy
} else {
// Not initialized the project strategy
}
}
if (match ($this->architecture) {
project_architecture::crm,
project_architecture::site,
project_architecture::program,
project_architecture::complex => true,
default => false
}) {
// Testing
if (isset($this->testing)) {
// Initialized the project testing
} else {
// Not initialized the project testing
}
}
if (match ($this->architecture) {
project_architecture::crm,
project_architecture::site,
project_architecture::program,
project_architecture::complex => true,
default => false
}) {
// Security
if (isset($this->security)) {
// Initialized the project security
} else {
// Not initialized the project security
}
}
if (match ($this->architecture) {
project_architecture::chat_robot,
project_architecture::parser,
project_architecture::crm,
project_architecture::site,
project_architecture::program,
project_architecture::complex => true,
default => false
}) {
// Documenting
if (isset($this->documenting)) {
// Initialized the project documenting
} else {
// Not initialized the project documenting
}
}
if (match ($this->architecture) {
project_architecture::chat_robot,
project_architecture::crm,
project_architecture::site,
project_architecture::program,
project_architecture::complex => true,
default => false
}) {
// Localization
if (isset($this->localization)) {
// Initialized the project localization
} else {
// Not initialized the project localization
}
}
if (match ($this->architecture) {
project_architecture::chat_robot,
project_architecture::parser,
project_architecture::crm,
project_architecture::site,
project_architecture::complex => true,
default => false
}) {
// Journal
if (isset($this->journal)) {
// Initialized the project journal
} else {
// Not initialized the project journal
}
}
if (match ($this->architecture) {
project_architecture::chat_robot,
project_architecture::crm,
project_architecture::site,
project_architecture::program,
project_architecture::complex => true,
default => false
}) {
// Scalability
if (isset($this->scalability)) {
// Initialized the project scalability
} else {
// Not initialized the project scalability
}
}
if (match ($this->architecture) {
project_architecture::chat_robot,
project_architecture::crm,
project_architecture::site,
project_architecture::complex => true,
default => false
}) {
// Framework
if (isset($this->framework)) {
// Initialized the project framework
} else {
// Not initialized the project framework
}
}
if (match ($this->architecture) {
project_architecture::chat_robot,
project_architecture::parser,
project_architecture::crm,
project_architecture::site,
project_architecture::program,
project_architecture::complex => true,
default => false
}) {
// Database
if (isset($this->database)) {
// Initialized the project database
} else {
// Not initialized the project database
}
}
if (match ($this->architecture) {
project_architecture::chat_robot,
project_architecture::crm,
project_architecture::site,
project_architecture::program,
project_architecture::complex => true,
default => false
}) {
// Depth of development
if (isset($this->depth)) {
// Initialized the project depth of development
} else {
// Not initialized the project depth of development
}
}
if (match ($this->architecture) {
project_architecture::chat_robot,
project_architecture::parser,
project_architecture::crm,
project_architecture::site,
project_architecture::program,
project_architecture::complex => true,
default => false
}) {
// architecture of cooperation
if (isset($this->cooperation)) {
// Initialized the project cooperation
} else {
// Not initialized the project cooperation
}
}
} else {
// Not initialized the project purpose
// Writing the project purpose button into the buffer of the first row
$first[1] = button::make(
text: "🔸 $localization->project_create_button_purpose",
callback_data: '@purposes'
);
// Writing the project buttons first row
$this->addButtonRow(...$first);
}
} else {
// Not initialized the project architecture
// Writing the project architecture button
$this->addButtonRow(
button::make(
text: "🔸 $localization->project_create_button_architecture",
callback_data: '@architectures'
)
);
}
if ($hours > 0) {
// The project development hours was calculated
// Writing the project architecture button
$this->addButtonRow(
button::make(
text: "☑️ $localization->project_create_button_request",
callback_data: '@request'
)
);
}
// Updating the message and saving its text
$this->text = $this->orNext('stop')->showMenu()->text;
}
/**
* Architectures
*
* Generate the project architecture select menu
*
* @param telegram $robot The robot
*
* @return void
*/
public function architectures(telegram $robot): void
{
// Initializing the account language
$language = $robot->get('language') ?? LANGUAGE_DEFAULT;
// Initializing the account localization
$localization = $robot->get('localization') ?? new localization($language);
// Initializing the account
$account = $robot->get('account');
// Updating the message text
$this->menuText(
text: implode(
"\n\n",
[
"⚙️ *$localization->project_create_architectures_title*",
$localization->project_create_architectures_description,
]
),
opt: [
'parse_mode' => mode::MARKDOWN
]
);
// Deleting the message buttons
$this->clearButtons();
// Initializing the row
$row = [];
// Declaring the buffer of the row buttons length
$length = 0;
// Initializing the maximum amount of buttons in a row
$break = 4;
// Initializing buffer of architectures
$architectures = project_architecture::cases();
if (isset($this->architecture)) {
// Initialized the selected architecture
// Initializing the selected purpose index
$selected = array_search($this->architecture ?? null, $architectures, strict: true);
if ($selected !== false) {
// Found the selected architecture index
// Exclude the selected architecture from buffer of architectures
unset($architectures[$selected]);
}
}
// Declaring the generated buttons registry
$generated = [];
foreach ($architectures as $index => $architecture) {
// Iterating over architectures
if (array_search($architecture, $generated)) {
// The architecture button is already generated
// Skipping the iteration
continue;
}
if ($length + $architecture->length() > $break && !empty($row)) {
// Reached the limit of buttons in a row
// Writing the row into the menu
$this->addButtonRow(...$row);
// Writing buttons into the generated buttons registry
$generated += $row;
// Reinitializing the row buttons length
/* $length -= $break; */
$length = 0;
// Reinitializing the row
$row = [];
}
// Addition to row buttons length
$length += $architecture->length();
// Writing the architecture button into the row
$row[] = button::make(
text: $localization['project_architecture_' . $architecture->name] ?? $architecture->label(language: $language),
callback_data: "$architecture->name@architecture"
);
// Initializing the next architecture
$next = $architectures[$index + 1] ?? null;
if ($next?->length() >= $break) {
// The next architecture is the full-length button
// Writing the row into the menu
$this->addButtonRow(...$row);
// Writing buttons into the generated buttons registry
$generated += $row;
// Reinitializing the row
$row = [];
// Reinitializing the row buttons length
$length = 0;
// Writing the button into the menu
$this->addButtonRow(button::make(
text: $localization['project_architecture_' . $next->name] ?? $next->label(language: $language),
callback_data: "$next->name@architecture"
));
// Writing the button into the generated buttons registry
$generated[] = $next;
}
}
if (!empty($row) > 0) {
// The row was not writed
// Writing the row into the menu
$this->addButtonRow(...$row);
}
// Deinitializing deprecated variables
unset($row, $limit, $length, $generated, $architectures, $architecture);
// Updating the message and saving its text
$this->text = $this->showMenu()->text;
}
/**
* architecture
*
* Write the project architecture
*
* @param telegram $robot The robot
*
* @return void
*/
public function architecture(telegram $robot): void
{
// Initializing the language
$language = $robot->get('language') ?? LANGUAGE_DEFAULT;
// Initializing the account localization
$localization = $robot->get('localization') ?? new localization($language);
// Initializing the project architecture
$this->architecture = project_architecture::{$robot->callbackQuery()->data};
// Initializing the project architecture purposes
$purposes = $this->architecture->purposes();
if (count($purposes) === 1) {
// The project architecture has only 1 purpose
// Initializing the project purpose
$this->purpose = $purposes[0];
} else if (isset($this->purpose) && array_search($this->purpose, $purposes) !== false) {
// The project architrcture purpose is the same from deprecated purpose
// keep it
} else {
//
// Deinitializing the project purpose
unset($this->purpose);
}
// Sending the popup notification
$robot->answerCallbackQuery(
text: $localization['project_architecture_' . $this->architecture?->name] ?? $this->architecture?->label(language: $language),
show_alert: false
);
// Deleting the message buttons
$this->clearButtons();
// Deleting the message buttons
$this->start(robot: $robot, new: false);
}
/**
* Purposes
*
* Generate the project purpose select menu
*
* @param telegram $robot The robot
*
* @return void
*/
public function purposes(telegram $robot): void
{
// Initializing the account language
$language = $robot->get('language') ?? LANGUAGE_DEFAULT;
// Initializing the account localization
$localization = $robot->get('localization') ?? new localization($language);
// Initializing the account
$account = $robot->get('account');
// Updating the message text
$this->menuText(
text: implode(
"\n\n",
[
"🛠 *$localization->project_create_purposes_title*",
$localization->project_create_purposes_description,
]
),
opt: [
'parse_mode' => mode::MARKDOWN
]
);
// Deleting the message buttons
$this->clearButtons();
// Initializing the row
$row = [];
// Declaring the buffer of the row buttons length
$length = 0;
// Initializing the maximum amount of buttons in a row
$break = 4;
// Initializing buffer of purposes
$purposes = $this->architecture->purposes();
if (isset($this->purpose)) {
// Initialized the selected purpose
// Initializing the selected purpose index
$selected = array_search($this->purpose ?? null, $purposes, strict: true);
if ($selected !== false) {
// Found the selected purpose index
// Exclude the selected purpose from buffer of purposes
unset($purposes[$selected]);
}
}
// Declaring the generated buttons registry
$generated = [];
foreach ($purposes as $index => $purpose) {
// Iterating over purposes
if (array_search($purpose, $generated)) {
// The purpose button is already generated
// Skipping the iteration
continue;
}
if ($length + $purpose->length() > $break && !empty($row)) {
// Reached the limit of buttons in a row
// Writing the row into the menu
$this->addButtonRow(...$row);
// Writing buttons into the generated buttons registry
$generated += $row;
// Reinitializing the row buttons length
/* $length -= $break; */
$length = 0;
// Reinitializing the row
$row = [];
}
// Addition to row buttons length
$length += $purpose->length();
// Initializing the coefficient
$coefficient = $purpose->coefficient();
// Writing the purpose button into the row
$row[] = button::make(
/* text: ($localization['project_purpose_' . $purpose->name] ?? $purpose->label(language: $language)) . (!empty($coefficient) ? ' x' . $coefficient : ''), */
text: $localization['project_purpose_' . $purpose->name] ?? $purpose->label(language: $language),
callback_data: "$purpose->name@purpose"
);
// Initializing the next purpose
$next = $purposes[$index + 1] ?? null;
if ($next?->length() >= $break) {
// The next purpose is the full-length button
// Writing the row into the menu
$this->addButtonRow(...$row);
// Writing buttons into the generated buttons registry
$generated += $row;
// Reinitializing the row
$row = [];
// Reinitializing the row buttons length
$length = 0;
// Initializing the coefficient
$coefficient = $next->coefficient();
// Writing the button into the menu
$this->addButtonRow(button::make(
/* text: ($localization['project_purpose_' . $next->name] ?? $next->label(language: $language)) . (!empty($coefficient) ? ' x' . $coefficient : ''), */
text: $localization['project_purpose_' . $next->name] ?? $next->label(language: $language),
callback_data: "$next->name@purpose"
));
// Writing the button into the generated buttons registry
$generated[] = $next;
}
}
if (!empty($row) > 0) {
// The row was not writed
// Writing the row into the menu
$this->addButtonRow(...$row);
}
// Writing the "special" button into the menu
$this->addButtonRow(button::make(
/* text: ($localization->project_purpose_special ?? project_purpose::special->label(language: $language)) . ' x' . project_purpose::special->coefficient(), */
text: $localization->project_purpose_special ?? project_purpose::special->label(language: $language),
callback_data: project_purpose::special->name . '@purpose'
));
// Deinitializing deprecated variables
unset($row, $limit, $length, $generated, $purposes, $purpose);
// Updating the message and saving its text
$this->text = $this->showMenu()->text;
}
/**
* Purpose
*
* Write the project purpose
*
* @param telegram $robot The robot
*
* @return void
*/
public function purpose(telegram $robot): void
{
// Initializing the account language
$language = $robot->get('language') ?? LANGUAGE_DEFAULT;
// Initializing the account localization
$localization = $robot->get('localization') ?? new localization($language);
// Initializing the project purpose
$this->purpose = project_purpose::{$robot->callbackQuery()->data};
// Sending the popup notification
$robot->answerCallbackQuery(
text: $localization['project_purpose_' . $this->purpose?->name] ?? $this->purpose?->label(language: $language),
show_alert: false
);
// Deleting the message buttons
$this->clearButtons();
// Deleting the message buttons
$this->start(robot: $robot, new: false);
}
/**
* Hours
*
* Calculate the project development hours
*
* @return int|float The project development hours
*/
public function hours(): int|float
{ // Declaring coefficient
$coefficient = PROJECT_CREATE_START_COEFFICIENT ?? 0;
if (isset($this->architecture)) {
// Initialized the project architecture
// Adding into the coefficient
$coefficient += $this->architecture->coefficient();
}
if (isset($this->purpose)) {
// Initialized the project purpose
// Adding into the coefficient
$coefficient += $this->purpose->coefficient();
}
// Initializing start hours
$start = PROJECT_CREATE_START_HOURS ?? 1;
$start < 1 and $start = 1;
// Initializing additional hours
$additional = PROJECT_CREATE_HOURS_ADDITIONAL ?? 0;
// Calculating the development hours
$hours = $start * $coefficient + $additional;
// Calculating and exit (success)
return ceil(max($hours, PROJECT_CREATE_HOURS_MINIMAL));
}
/**
* Request
*
*
*
* @param telegram $robot The robot
*
* @return void
*/
public function request(telegram $robot): void
{
// Initializing the account language
$language = $robot->get('language') ?? LANGUAGE_DEFAULT;
// Initializing the account localization
$localization = $robot->get('localization') ?? new localization($language);
// Sending the message
$robot->sendMessage(
text: "✅ *$localization->project_create_requested*",
parse_mode: mode::MARKDOWN,
disable_notification: true
);
// Ending the conversation
$this->end();
}
/**
* Stop
*
* Delete the project create menu and terminating the process
*
* @param telegram $robot The robot
*
* @return void
*/
public function stop(telegram $robot): void
{
// Initializing the account language
$language = $robot->get('language') ?? LANGUAGE_DEFAULT;
// Initializing the account localization
$localization = $robot->get('localization') ?? new localization($language);
// Sending the message
$robot->sendMessage(
text: "⚠️ *$localization->project_create_cancelled*",
parse_mode: mode::MARKDOWN,
disable_notification: true
);
// Ending the conversation
$this->end();
}
}

View File

@@ -5,8 +5,7 @@ declare(strict_types=1);
namespace kodorvan\constructor\models\telegram\middlewares; namespace kodorvan\constructor\models\telegram\middlewares;
// Files of the project // Files of the project
use kodorvan\constructor\models\core, use kodorvan\constructor\models\account as model,
kodorvan\constructor\models\account as model,
kodorvan\constructor\models\authorizations; kodorvan\constructor\models\authorizations;
// The library for languages support // The library for languages support
@@ -30,7 +29,7 @@ use Error as error;
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License * @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy> * @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/ */
final class account extends core final class account
{ {
/** /**
* Account * Account

View File

@@ -5,8 +5,7 @@ declare(strict_types=1);
namespace kodorvan\constructor\models\telegram\middlewares; namespace kodorvan\constructor\models\telegram\middlewares;
// Files of the project // Files of the project
use kodorvan\constructor\models\core, use kodorvan\constructor\models\account,
kodorvan\constructor\models\account,
kodorvan\constructor\models\authorizations as model; kodorvan\constructor\models\authorizations as model;
// The library for languages support // The library for languages support
@@ -30,7 +29,7 @@ use Error as error;
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License * @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy> * @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/ */
final class authorizations extends core final class authorizations
{ {
/** /**
* Authorizations * Authorizations

View File

@@ -5,8 +5,7 @@ declare(strict_types=1);
namespace kodorvan\constructor\models\telegram\middlewares; namespace kodorvan\constructor\models\telegram\middlewares;
// Files of the project // Files of the project
use kodorvan\constructor\models\core, use kodorvan\constructor\models\account,
kodorvan\constructor\models\account,
kodorvan\constructor\models\authorizations; kodorvan\constructor\models\authorizations;
// The library for languages support // The library for languages support
@@ -30,7 +29,7 @@ use Error as error;
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License * @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy> * @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/ */
final class language extends core final class language
{ {
/** /**
* Language * Language

View File

@@ -5,8 +5,7 @@ declare(strict_types=1);
namespace kodorvan\constructor\models\telegram\middlewares; namespace kodorvan\constructor\models\telegram\middlewares;
// Files of the project // Files of the project
use kodorvan\constructor\models\core, use kodorvan\constructor\models\account,
kodorvan\constructor\models\account,
kodorvan\constructor\models\localization as model, kodorvan\constructor\models\localization as model,
kodorvan\constructor\models\authorizations; kodorvan\constructor\models\authorizations;
@@ -32,7 +31,7 @@ use Exception as exception,
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License * @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy> * @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/ */
final class localization extends core final class localization
{ {
/** /**
* Localization * Localization
@@ -61,30 +60,14 @@ final class localization extends core
if ($language instanceof language) { if ($language instanceof language) {
// Initialized the language // Initialized the language
try { // Initializing the localization
// Initializing the localization $localization = new model($language);
$localization = new model($language);
// Writing localization into the robot variable // Writing localization into the robot variable
$robot->set('localization', $localization); $robot->set('localization', $localization);
// Continuation of the process // Continuation of the process
$next($robot); $next($robot);
} catch (exception $exception) {
// Not initialized the localization
// Writing the exception into the errors output buffer
error_log((string) $exception);
// Sending the message
$robot->sendMessage(
text: '⚠️ *Failed to initialize the localization*',
parse_mode: mode::MARKDOWN
);
// Ending the conversation process
$robot->endConversation();
}
} }
} }
} }

View File

@@ -5,8 +5,7 @@ declare(strict_types=1);
namespace kodorvan\constructor\models\telegram\middlewares; namespace kodorvan\constructor\models\telegram\middlewares;
// Files of the project // Files of the project
use kodorvan\constructor\models\core, use kodorvan\constructor\models\account,
kodorvan\constructor\models\account,
kodorvan\constructor\models\authorizations; kodorvan\constructor\models\authorizations;
// The library for languages support // The library for languages support
@@ -30,7 +29,7 @@ use Error as error;
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License * @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy> * @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/ */
final class settings extends core final class settings
{ {
/** /**
* Settings * Settings
@@ -75,7 +74,7 @@ final class settings extends core
// Sending the message // Sending the message
$robot->sendMessage( $robot->sendMessage(
text: '⛔ *' . $localization['not_authorized_settings'] . '*', text: "⛔ *$localization->not_authorized_settings*",
parse_mode: mode::MARKDOWN parse_mode: mode::MARKDOWN
); );

View File

@@ -5,8 +5,7 @@ declare(strict_types=1);
namespace kodorvan\constructor\models\telegram\middlewares\system; namespace kodorvan\constructor\models\telegram\middlewares\system;
// Files of the project // Files of the project
use kodorvan\constructor\models\core, use kodorvan\constructor\models\account,
kodorvan\constructor\models\account,
kodorvan\constructor\models\authorizations; kodorvan\constructor\models\authorizations;
// The library for languages support // The library for languages support
@@ -23,14 +22,14 @@ use SergiX44\Nutgram\Nutgram as telegram,
use Error as error; use Error as error;
/** /**
* Telegram middleware: language * Telegram middleware: system settings
* *
* @package kodorvan\constructor\models\telegram\middlewares\system * @package kodorvan\constructor\models\telegram\middlewares\system
* *
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License * @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy> * @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/ */
final class settings extends core final class settings
{ {
/** /**
* System settings (middleware) * System settings (middleware)

View File

@@ -0,0 +1,81 @@
<?php
declare(strict_types=1);
namespace kodorvan\constructor\models\telegram;
// Files of the project
use kodorvan\constructor\models\core,
kodorvan\constructor\models\account,
kodorvan\constructor\models\localization,
kodorvan\constructor\models\settings as model,
kodorvan\constructor\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;
// Built-in libraries
use Error as error;
/**
* Telegram project
*
* @package kodorvan\constructor\models\telegram
*
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/
final class project extends core
{
/**
* Language
*
* Write the language into the account and the robot instance
*
* @param telegram $robot The chat-robot instance
* @param language $language The language
*
* @return void
*/
public static function create(telegram $robot, language $language = LANGUAGE_DEFAULT): void
{
/* // Initializing the account
$account = $robot->get('account');
if ($account instanceof account) {
// Initialized the account
// Initializing the menu message localization
$localization = new localization($language);
if ($localization instanceof localization) {
// Initialized the localization
// Sending the message
$robot->sendMessage(
text: "✅ *$localization->settings_language_update_success:* " . trim($from->flag() . ' ' . $from->label($to)) . ' → *' . trim($to->flag() . ' ' . $to->label($to)) . '*',
parse_mode: mode::MARKDOWN,
disable_notification: true
);
// Sending the message
$robot->answerCallbackQuery(
text: $to->label($to),
show_alert: false
);
}
} */
}
}

View File

@@ -1,109 +0,0 @@
<?php
declare(strict_types=1);
namespace kodorvan\constructor;
// Files of the project
use kodorvan\constructor\models\account,
kodorvan\constructor\models\telegram\middlewares,
kodorvan\constructor\models\telegram\commands\start,
kodorvan\constructor\models\telegram\settings;
// Library for languages support
use mirzaev\languages\language;
// Framework for PHP
use mirzaev\minimal\core,
mirzaev\minimal\route;
// Framework for Telegram
use Telegram\Bot\BotsManager as telegram;
// Enabling debugging
/* ini_set('error_reporting', E_ALL);
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1); */
// Initializing path to the public directory
define('INDEX', __DIR__);
// Initializing path to the project root directory
define('ROOT', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR);
// Initializing path to the directory of views
define('VIEWS', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'views');
// Initializing path to the directory of settings
define('SETTINGS', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'settings');
// Initializing system settings
require SETTINGS . DIRECTORY_SEPARATOR . 'system.php';
// Initializing path to the directory of the storage
define('STORAGE', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'storage');
// Initializing path to the databases directory
define('DATABASES', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'databases');
// Initializing path to the localizations directory
define('LOCALIZATIONS', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'localizations');
// Initiailizing Telegram chat-robot settings
define('TELEGRAM', require(SETTINGS . DIRECTORY_SEPARATOR . 'telegram.php'));
// Initializing dependencies
require ROOT . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
// Initializing the robots manager settings
$settings = [
'bots' => [
'constructor' => [
'token' => TELEGRAM['constructor']['key'],
'certificate_path' => PROJECT_CERTIFICATE,
'webhook_url' => 'https://' . PROJECT_DOMAIN . '/telegram/constructor.php',
'commands' => [
start::class,
]
],
'async_requests' => true,
'base_bot_url' => 'https://' . PROJECT_DOMAIN . '/telegram',
]
];
// Initializing the robots manager
$robot = new telegram($settings);
var_dump($telegram->bot('constructor')->getWebhookUpdate());
/* // Initializing the updates listener
$robot->onUpdate(function (context $context): void {});
// Initializing the robot middlewares
$robot->middleware([middlewares::class, 'account']);
$robot->middleware([middlewares::class, 'language']);
$robot->middleware([middlewares::class, 'localization']);
$robot->middleware([middlewares::class, 'authorizations']);
// Initializing the robot commands handlers
$robot->onCommand('start', [commands::class, 'start']);
$robot->onCommand('start telegram voronka', [commands::class, 'start']);
$robot->onCommand('start parser', [commands::class, 'start']);
$robot->onCommand('start calculator', [commands::class, 'start']);
$robot->onCommand('language', [commands::class, 'language'])->middleware([middlewares::class, 'settings']);
$robot->onCommand('society', [commands::class, 'society']);
// Initializing the robot settings language buttons handlers
foreach (language::cases() as $language) {
// Iterating over languages
// Initializing language buttons
$robot->onCbQueryData(["settings_language_$language->name"], fn(context $context) => settings::language($context, $language));
};
$robot->onCbQueryData('project_create', ['process_project_create', 'name']);
// Starting chat-robot
$robot->run(); */

View File

@@ -18,8 +18,8 @@ use mirzaev\minimal\core,
mirzaev\minimal\route; mirzaev\minimal\route;
// Framework for Telegram // Framework for Telegram
/* use Telegram\Bot\BotsManager as telegram; */
use SergiX44\Nutgram\Nutgram as telegram, use SergiX44\Nutgram\Nutgram as telegram,
SergiX44\Nutgram\Configuration as telegram_settings,
SergiX44\Nutgram\RunningMode\Webhook as webhook, SergiX44\Nutgram\RunningMode\Webhook as webhook,
SergiX44\Nutgram\Telegram\Types\Internal\InputFile as input; SergiX44\Nutgram\Telegram\Types\Internal\InputFile as input;
@@ -59,7 +59,12 @@ define('TELEGRAM', require(SETTINGS . DIRECTORY_SEPARATOR . 'telegram.php'));
require ROOT . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php'; require ROOT . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
// Initializing the robot // Initializing the robot
$robot = new telegram(TELEGRAM['constructor']['key']); $robot = new telegram(
token: TELEGRAM['key'],
config: new telegram_settings(
botName: TELEGRAM['name']
)
);
$robot->setWebhook( $robot->setWebhook(
url: 'https://' . PROJECT_DOMAIN . '/telegram/constructor/webhook.php', url: 'https://' . PROJECT_DOMAIN . '/telegram/constructor/webhook.php',
@@ -67,63 +72,5 @@ $robot->setWebhook(
ip_address: SERVER_IP_ADDRESS, ip_address: SERVER_IP_ADDRESS,
max_connections: 10, max_connections: 10,
drop_pending_updates: false, drop_pending_updates: false,
secret_token: 'bebra228' secret_token: TELEGRAM['password']
); );
/* // Initializing the robots manager settings
$settings = [
'bots' => [
'constructor' => [
'token' => TELEGRAM['constructor']['key'],
'certificate_path' => PROJECT_CERTIFICATE,
'webhook_url' => 'https://' . PROJECT_DOMAIN . '/telegram/constructor/webhook.php',
'commands' => [
start::class,
]
],
'async_requests' => true,
'base_bot_url' => 'https://' . PROJECT_DOMAIN . '/telegram',
]
];
// Initializing the robots manager
$telegram = new telegram($settings);
$updates = $telegram->bot('constructor')->setWebhook([
'url' => 'https://' . PROJECT_DOMAIN . '/telegram/constructor/webhook.php',
'certificate' => PROJECT_CERTIFICATE
]);
*/
/* // Initializing the updates listener
$robot->onUpdate(function (context $context): void {});
// Initializing the robot middlewares
$robot->middleware([middlewares::class, 'account']);
$robot->middleware([middlewares::class, 'language']);
$robot->middleware([middlewares::class, 'localization']);
$robot->middleware([middlewares::class, 'authorizations']);
// Initializing the robot commands handlers
$robot->onCommand('start', [commands::class, 'start']);
$robot->onCommand('start telegram voronka', [commands::class, 'start']);
$robot->onCommand('start parser', [commands::class, 'start']);
$robot->onCommand('start calculator', [commands::class, 'start']);
$robot->onCommand('language', [commands::class, 'language'])->middleware([middlewares::class, 'settings']);
$robot->onCommand('society', [commands::class, 'society']);
// Initializing the robot settings language buttons handlers
foreach (language::cases() as $language) {
// Iterating over languages
// Initializing language buttons
$robot->onCbQueryData(["settings_language_$language->name"], fn(context $context) => settings::language($context, $language));
};
$robot->onCbQueryData('project_create', ['process_project_create', 'name']);
// Starting chat-robot
$robot->run(); */

View File

@@ -8,8 +8,10 @@ namespace kodorvan\constructor;
use kodorvan\constructor\models\account, use kodorvan\constructor\models\account,
kodorvan\constructor\models\telegram\settings, kodorvan\constructor\models\telegram\settings,
kodorvan\constructor\models\telegram\commands\start as command_start, kodorvan\constructor\models\telegram\commands\start as command_start,
kodorvan\constructor\models\telegram\commands\account as command_account,
kodorvan\constructor\models\telegram\commands\society as command_society, kodorvan\constructor\models\telegram\commands\society as command_society,
kodorvan\constructor\models\telegram\commands\language as command_language, kodorvan\constructor\models\telegram\commands\language as command_language,
kodorvan\constructor\models\telegram\conversations\project\create as conversation_project_create,
kodorvan\constructor\models\telegram\middlewares\account as middleware_account, kodorvan\constructor\models\telegram\middlewares\account as middleware_account,
kodorvan\constructor\models\telegram\middlewares\language as middleware_language, kodorvan\constructor\models\telegram\middlewares\language as middleware_language,
kodorvan\constructor\models\telegram\middlewares\localization as middleware_localization, kodorvan\constructor\models\telegram\middlewares\localization as middleware_localization,
@@ -24,10 +26,14 @@ use mirzaev\minimal\core,
mirzaev\minimal\route; mirzaev\minimal\route;
// Framework for Telegram // Framework for Telegram
/* use Telegram\Bot\BotsManager as telegram; */
use SergiX44\Nutgram\Nutgram as telegram, use SergiX44\Nutgram\Nutgram as telegram,
SergiX44\Nutgram\Configuration as telegram_settings,
SergiX44\Nutgram\RunningMode\Webhook as webhook; SergiX44\Nutgram\RunningMode\Webhook as webhook;
// The symphony cache library
use Symfony\Component\Cache\Adapter\FilesystemAdapter as cache_adapter,
Symfony\Component\Cache\Psr16Cache as cache;
// Enabling debugging // Enabling debugging
/* ini_set('error_reporting', E_ALL); /* ini_set('error_reporting', E_ALL);
ini_set('display_errors', 1); ini_set('display_errors', 1);
@@ -64,9 +70,15 @@ define('TELEGRAM', require(SETTINGS . DIRECTORY_SEPARATOR . 'telegram.php'));
require ROOT . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php'; require ROOT . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
// Initializing the robot // Initializing the robot
$robot = new telegram(TELEGRAM['constructor']['key']); $robot = new telegram(
token: TELEGRAM['key'],
config: new telegram_settings(
botName: TELEGRAM['name'],
cache: new cache(new cache_adapter())
)
);
$webhook = new webhook(secretToken: 'bebra228'); $webhook = new webhook(secretToken: TELEGRAM['password']);
$webhook->setSafeMode(true); $webhook->setSafeMode(true);
$robot->setRunningMode($webhook); $robot->setRunningMode($webhook);
@@ -76,25 +88,28 @@ $robot->middleware(middleware_language::class);
$robot->middleware(middleware_localization::class); $robot->middleware(middleware_localization::class);
$robot->middleware(middleware_authorizations::class); $robot->middleware(middleware_authorizations::class);
// Start
// Initializing the robot commands handlers
$robot->registerCommand(command_start::class); $robot->registerCommand(command_start::class);
$robot->onCommand('start telegram voronka', command_start::class); $robot->onCommand('start telegram voronka', command_start::class);
$robot->onCommand('start parser', command_start::class); $robot->onCommand('start parser', command_start::class);
$robot->onCommand('start calculator', command_start::class); $robot->onCommand('start calculator', command_start::class);
$robot->registerCommand(command_language::class)->middleware(middleware_settings::class); // Account
$robot->registerCommand(command_society::class); $robot->registerCommand(command_account::class);
// Initializing the robot settings language buttons handlers // Language
$robot->registerCommand(command_language::class)->middleware(middleware_settings::class);
foreach (language::cases() as $language) { foreach (language::cases() as $language) {
// Iterating over languages // Iterating over languages
// Initializing language buttons // Select the language
$robot->onCallbackQueryData("settings_language_$language->name", fn(telegram $robot) => settings::language(robot: $robot, language: $language)); $robot->onCallbackQueryData('settings_language_$language->name', fn(telegram $robot) => settings::language(robot: $robot, language: $language));
}; };
/* $robot->onCbQueryData('project_create', ['process_project_create', 'name']); */ // Society
$robot->registerCommand(command_society::class);
// Project: create
$robot->onCallbackQueryData('project_create', conversation_project_create::class);
$robot->run(); $robot->run();

View File

@@ -1,3 +1,5 @@
* *
!.gitignore !.gitignore
!*.sample !*.sample
!*/
!*.md

View File

@@ -0,0 +1 @@
openssl req -newkey rsa:2048 -sha256 -nodes -keyout private.key -x509 -days 365 -out public.pem -subj "/C=US/ST=New York/L=Brooklyn/O=Example Brooklyn Company/CN=Sex"

View File

@@ -3,20 +3,36 @@
// The library for languages support // The library for languages support
use mirzaev\languages\language; use mirzaev\languages\language;
// The library for currencies support
use mirzaev\currencies\currency;
// Initializing dependencies // Initializing dependencies
require ROOT . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php'; require ROOT . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
define('SERVER_IP_ADDRESS', '5.140.110.25'); define('SERVER_IP_ADDRESS', '5.140.110.25');
define('REPOSITORY', 'https://git.svoboda.works');
define('PROJECT_CREATOR', 'kodorvan'); define('PROJECT_CREATOR', 'kodorvan');
define('PROJECT_NAME', 'constructor'); define('PROJECT_NAME', 'constructor');
define('PROJECT_DOMAIN', 'constructor.kodorvan.tech'); define('PROJECT_DOMAIN', 'constructor.kodorvan.tech');
define('PROJECT_CERTIFICATE', SETTINGS . DIRECTORY_SEPARATOR . 'certificate' . DIRECTORY_SEPARATOR . 'public.pem'); define('PROJECT_CERTIFICATE', SETTINGS . DIRECTORY_SEPARATOR . 'certificate' . DIRECTORY_SEPARATOR . 'public.pem');
define('REPOSITORY', 'https://git.svoboda.works'); define('PROJECT_MEDIA_URL', 'https://t.me/kodorvan');
define('PROJECT_OPERATOR_URL', 'https://t.me/kodorvan?direct');
define('PROJECT_REPOSITORY', REPOSITORY . '/' . PROJECT_CREATOR . '/' . PROJECT_NAME); define('PROJECT_REPOSITORY', REPOSITORY . '/' . PROJECT_CREATOR . '/' . PROJECT_NAME);
define('PROJECT_REPOSITORY_LANGUAGE_ADD', PROJECT_REPOSITORY . '/src/branch/stable/' . PROJECT_CREATOR . '/' . PROJECT_NAME . '/system/localizations'); define('PROJECT_REPOSITORY_LANGUAGE_ADD', PROJECT_REPOSITORY . '/src/branch/stable/' . PROJECT_CREATOR . '/' . PROJECT_NAME . '/system/localizations');
/* define('PROJECT_CERTIFICATE', SETTINGS . DIRECTORY_SEPARATOR . 'cert.pem'); */
define('PROJECT_CREATE_START_HOURS', 1);
define('PROJECT_CREATE_START_COEFFICIENT', 0);
define('PROJECT_CREATE_HOURS_ADDITIONAL', 0);
define('PROJECT_CREATE_HOURS_MINIMAL', 4);
define('PROJECT_CREATE_COST_HOUR_DEFAULT', 1200);
define('PROJECT_CREATE_REQUEST_CHATS', [
]);
define('CURRENCY_DEFAULT', currency::rub);
define('LANGUAGE_DEFAULT', language::en); define('LANGUAGE_DEFAULT', language::en);
// Initializing default theme for the views templater // Initializing default theme for the views templater

View File

@@ -2,17 +2,17 @@
// Telegram API chat-robot // Telegram API chat-robot
return [ return [
'constructor' => [ 'identifier' => 0,
'identifier' => 0, 'domain' => 'kodorvan_bot',
'domain' => '', 'name' => 'kodorvan',
'key' => '', 'password' => '',
'database' => [ 'key' => '',
'host' => '/run/mysqld/mysqld.sock', 'database' => [
'port' => 3306, 'host' => '/run/mysqld/mysqld.sock',
'user' => '', 'port' => 3306,
'password' => '', 'user' => '',
'database' => '', 'password' => '',
] 'database' => '',
] ]
]; ];