generated from mirzaev/pot-php-telegram
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4757a81d95 | |||
| 4fdcae74be | |||
| 4839f950e5 | |||
| 3fa8e067a1 | |||
| 74d2eaa62b | |||
| 0692db9c80 | |||
| ebba2a970e |
@@ -37,7 +37,7 @@
|
||||
"react/filesystem": "^0.1.2",
|
||||
"nyholm/psr7": "^1.8",
|
||||
"irazasyed/telegram-bot-sdk": "^3.15",
|
||||
"nutgram/nutgram": "^4.40",
|
||||
"nutgram/nutgram": "^4.42",
|
||||
"psr/simple-cache": "^3.0",
|
||||
"symfony/cache": "^8.0"
|
||||
},
|
||||
|
||||
14
composer.lock
generated
14
composer.lock
generated
@@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "1f5b64f8a594a24294320f54e2470337",
|
||||
"content-hash": "44219ee87ec9e34c98a5404150eb4ac0",
|
||||
"packages": [
|
||||
{
|
||||
"name": "badfarm/zanzara",
|
||||
@@ -1923,16 +1923,16 @@
|
||||
},
|
||||
{
|
||||
"name": "nutgram/nutgram",
|
||||
"version": "4.40.2",
|
||||
"version": "4.42.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/nutgram/nutgram.git",
|
||||
"reference": "caf0deb11f6dae93b407f5bb85a94d5336a1b945"
|
||||
"reference": "034257dbc29947b73e04b5d92b07d780d8962810"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/nutgram/nutgram/zipball/caf0deb11f6dae93b407f5bb85a94d5336a1b945",
|
||||
"reference": "caf0deb11f6dae93b407f5bb85a94d5336a1b945",
|
||||
"url": "https://api.github.com/repos/nutgram/nutgram/zipball/034257dbc29947b73e04b5d92b07d780d8962810",
|
||||
"reference": "034257dbc29947b73e04b5d92b07d780d8962810",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@@ -1994,7 +1994,7 @@
|
||||
],
|
||||
"support": {
|
||||
"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": [
|
||||
{
|
||||
@@ -2006,7 +2006,7 @@
|
||||
"type": "github"
|
||||
}
|
||||
],
|
||||
"time": "2026-01-25T17:57:40+00:00"
|
||||
"time": "2026-02-12T17:23:52+00:00"
|
||||
},
|
||||
{
|
||||
"name": "nyholm/psr7",
|
||||
|
||||
75
kodorvan/constructor/system/databases/scripts/workers.php
Normal file
75
kodorvan/constructor/system/databases/scripts/workers.php
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace kodorvan\constructor;
|
||||
|
||||
// Files of the project
|
||||
use kodorvan\constructor\models\account,
|
||||
kodorvan\constructor\models\authorizations,
|
||||
kodorvan\constructor\models\worker,
|
||||
kodorvan\constructor\models\tariff;
|
||||
|
||||
// The library for currencies support
|
||||
use mirzaev\currencies\currency;
|
||||
|
||||
// Svoboda time
|
||||
use svoboda\time\statement as svoboda;
|
||||
|
||||
// Baza database
|
||||
use mirzaev\baza\record;
|
||||
|
||||
// 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__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'public');
|
||||
|
||||
// Initializing path to the root directory
|
||||
define('ROOT', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR);
|
||||
|
||||
// Initializing path to the settings directory
|
||||
define('SETTINGS', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'settings');
|
||||
|
||||
// Initializing path to the storage directory
|
||||
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 data
|
||||
require(SETTINGS . DIRECTORY_SEPARATOR . 'telegram.php');
|
||||
|
||||
// Initializing dependencies
|
||||
require ROOT . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
|
||||
|
||||
// Initializing the account model
|
||||
$account_model = new account();
|
||||
|
||||
// Searching for the account
|
||||
$account = $account_model->read(
|
||||
filter: fn(record $record) => $record->domain === 'buddy_volkodav',
|
||||
);
|
||||
|
||||
var_dump($account);
|
||||
|
||||
// Searching for the account authorizations
|
||||
$authorizations = $account->authorizations();
|
||||
|
||||
var_dump($authorizations);
|
||||
|
||||
// Creating the worker
|
||||
$worker = new worker()->write(
|
||||
account: $account->identifier,
|
||||
hour: 2000,
|
||||
currency: currency::rub,
|
||||
active: true
|
||||
);
|
||||
|
||||
var_dump($worker);
|
||||
|
||||
@@ -10,7 +10,7 @@ return [
|
||||
// Главное меню
|
||||
'menu_title' => 'Главное меню',
|
||||
'menu_description_guest' => "🔥 *Создайте ваш первый проект* и получите *ориентировочную стоимость* всего за 2 минуты",
|
||||
'menu_description_partner' => "*Благодарю за выбор нашей команды*. Теперь Вы один из наших %d партнёров!",
|
||||
'menu_description_partner' => "*Благодарю за выбор нашей команды*\. Теперь Вы один из наших %d партнёров!",
|
||||
'menu_update' => 'Последнее обновление',
|
||||
'menu_button_project_new' => 'Создать',
|
||||
'menu_button_projects' => 'Проекты',
|
||||
@@ -24,14 +24,36 @@ return [
|
||||
|
||||
// Проект: создание
|
||||
'project_create_title' => 'Создание проекта',
|
||||
'project_create_description' => 'Получите ориентировочную стоимость всего за 2 минуты\!',
|
||||
/* 'project_create_description' => "Расчитайте ориентировочное время разработки, затем выберите разработчиков и получите стоимость\n\nПосле расчётов можно будет отправить проект в заказ разработчикам и приложить ТЗ, либо краткое описание задачи\n\nМы погружаемся в проекты полностью, поэтому стараемся не распыляться - от степени нагрузки меняется коэффициент стоимости!", */
|
||||
'project_create_description' => "Установите параметры и получите ориентировочное время разработки\n\n_После расчётов можно отправить проект в заказ приложив ТЗ, либо описание задачи_",
|
||||
'project_create_warning_cost' => "Стоимость и сроки выполнения предоставлены для планирования и *не являются публичной офертой*",
|
||||
'project_create_team_warning' => "",
|
||||
'project_create_time' => 'Время',
|
||||
'project_create_time_hours' => 'ч',
|
||||
'project_create_time_hours_from' => 'от',
|
||||
'project_create_time_days' => 'дн',
|
||||
'project_create_cost' => 'Стоимость',
|
||||
'project_create_cost_prepayment' => 'Предоплата',
|
||||
'project_create_team_title' => 'Сбор команды',
|
||||
'project_create_team_description' => '_Вы можете *убрать* или *добавить* специалистов, создавая максимально удобное сотрудничество под вашу систему_',
|
||||
'project_create_team_warning_cost' => '_*Не влияет на время разработки*_',
|
||||
'project_create_team_button_programmers' => 'Программисты: %d%s',
|
||||
'project_create_team_button_designers' => 'Дизайнеры: %d%s',
|
||||
'project_create_team_button_boosters' => 'Бустеры: %d%s',
|
||||
'project_create_cost_title' => 'Стоимость разработки',
|
||||
'project_create_cost_description' => 'Введите предложение по *оплате за 1 час* разработки',
|
||||
'project_create_cost_default' => '*`%d%s`* \- средняя стоимость с учётом *компетенции*, совокупного опыта, *уникальных* разработок\. Цена уже включает\: *наши сервера*, документирование кода, *передачу кода*, ведение репозитория, *техподдержку* и репутационные гарантии',
|
||||
'project_create_cost_warning' => '_Если цена окажется *недостаточной*, мы выставим *справедливое* и *конкурентное* встречное предложение_',
|
||||
'project_create_cost_error_distance' => 'Длина сообщения должна быть от %d и до %d символов',
|
||||
'project_create_cost_error_not_a_number' => 'Значение должно быть числом',
|
||||
'project_create_button_back' => 'Назад',
|
||||
'project_create_button_cost_per_hour' => 'Час',
|
||||
'project_create_button_request' => 'Заказать',
|
||||
|
||||
'project_create_types_title' => 'Выбор типа проекта',
|
||||
'project_create_types_description' => 'Каждый тип имеет уникальные параметры и коэффициент',
|
||||
'project_create_button_type' => 'Тип проекта',
|
||||
'project_create_button_type_selected' => 'Тип',
|
||||
'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' => 'Вектор разработки, основание проекта',
|
||||
@@ -39,21 +61,34 @@ return [
|
||||
'project_create_button_purpose_selected' => 'Назнач.',
|
||||
|
||||
'project_create_integrations_title' => 'Выбор интеграций',
|
||||
'project_create_integrations_description' => 'Синхронизация, скачивание, загрузка, запись...',
|
||||
'project_create_integrations_description' => "Синхронизация заказов, товаров, публикаций и прочего в реальном времени, скачивание, загрузка, админ\-панель, рассылка сообщений, подключение аккаунтов\.\.\.\n\n_Отправка запросов в *API*, генерация и перехват *HTTP\-сообщений*, *эмуляция действий пользователя*_",
|
||||
'project_create_button_integrations' => 'Интеграции',
|
||||
'project_create_button_integrations_selected' => 'Интеграции',
|
||||
|
||||
'project_create_button_team' => 'Команда: %d%s',
|
||||
'project_create_peoples' => '',
|
||||
'project_create_requested' => 'Проект создан и отправлен оператору',
|
||||
'project_create_cancelled' => 'Создание проекта отменено',
|
||||
|
||||
'project_request_title' => 'Заказ #%d',
|
||||
'project_request_architecture' => 'Архитектура',
|
||||
'project_request_purpose' => 'Назначение',
|
||||
'project_request_hours' => 'Часы',
|
||||
'project_request_cost' => 'Стоимость',
|
||||
'project_request_team' => 'Команда',
|
||||
'project_request_empty' => 'Пусто',
|
||||
'project_request_button_accept' => 'Принять',
|
||||
'project_request_button_refuse' => 'Отказать',
|
||||
'project_request_button_edit' => 'Редактировать',
|
||||
'project_request_button_chat' => 'Чат с заказчиком',
|
||||
|
||||
// Проект: типы
|
||||
'project_type_chat_robot' => 'Чат-робот',
|
||||
'project_type_parser' => 'Парсер',
|
||||
'project_type_calculator' => 'Калькулятор',
|
||||
'project_type_crm' => 'CRM',
|
||||
'project_type_site' => 'Сайт',
|
||||
'project_type_program' => 'Программа',
|
||||
'project_type_complex' => 'Нестандартный',
|
||||
'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' => 'Воронка',
|
||||
@@ -65,12 +100,21 @@ return [
|
||||
'project_purpose_marketplace' => 'Маркетплейс',
|
||||
'project_purpose_charity' => 'Благотворительность',
|
||||
'project_purpose_search' => 'Поиск',
|
||||
'project_purpose_calculate' => 'Расчёт',
|
||||
'project_purpose_calcul+ate' => 'Расчёт',
|
||||
'project_purpose_tools' => 'Инструменты',
|
||||
'project_purpose_workers' => 'Рабочие',
|
||||
'project_purpose_objects' => 'Предметы',
|
||||
'project_purpose_events' => 'События',
|
||||
'project_purpose_special' => 'Особенный',
|
||||
'project_purpose_special' => 'Особенное',
|
||||
|
||||
// Проект: интеграции
|
||||
'project_integration_one_c' => '1C',
|
||||
'project_integration_bitrix24' => 'Битрикс 24',
|
||||
'project_integration_moy_sklad' => 'Мой Склад',
|
||||
'project_integration_telegram' => 'Телеграм',
|
||||
'project_integration_mail' => 'Почта',
|
||||
'project_integration_excel' => 'Excel',
|
||||
/* 'project_integration_' => '', */
|
||||
|
||||
// Настройки: язык
|
||||
'settings_language_title' => 'Выбери язык',
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace kodorvan\constructor\models;
|
||||
use kodorvan\constructor\models\core,
|
||||
kodorvan\constructor\models\authorizations,
|
||||
kodorvan\constructor\models\settings,
|
||||
kodorvan\constructor\models\worker,
|
||||
kodorvan\constructor\models\project,
|
||||
kodorvan\constructor\models\project\enumerations\type as project_type,
|
||||
kodorvan\constructor\models\project\enumerations\status as project_status;
|
||||
@@ -65,6 +66,13 @@ final class account extends core implements record_interface
|
||||
*/
|
||||
public protected(set) database $database;
|
||||
|
||||
/**
|
||||
* Serialized
|
||||
*
|
||||
* @var bool $serialized Is the implementator object serialized?
|
||||
*/
|
||||
private bool $serialized = true;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@@ -84,6 +92,7 @@ final class account extends core implements record_interface
|
||||
new column('name_first', type::string, ['length' => 64]),
|
||||
new column('name_second', type::string, ['length' => 64]),
|
||||
new column('language', type::string, ['length' => 2]),
|
||||
new column('currency', type::string, ['length' => 3]),
|
||||
new column('robot', type::char),
|
||||
/* new column('', type::), */
|
||||
new column('active', type::char),
|
||||
@@ -215,6 +224,7 @@ final class account extends core implements record_interface
|
||||
name_second: (string) $telegram->last_name,
|
||||
domain: (string) $telegram->username,
|
||||
language: (string) $telegram->language_code,
|
||||
currency: CURRENCY_DEFAULT,
|
||||
robot: (bool) $telegram->is_bot
|
||||
);
|
||||
|
||||
@@ -256,6 +266,7 @@ final class account extends core implements record_interface
|
||||
* @param string $name_second
|
||||
* @param string $domain
|
||||
* @param language|string $language
|
||||
* @param currency|string $currency
|
||||
* @param bool $robot Is a robot?
|
||||
* @param bool $active Is the record active?
|
||||
*
|
||||
@@ -267,6 +278,7 @@ final class account extends core implements record_interface
|
||||
string $name_first = '',
|
||||
string $name_second = '',
|
||||
language|string $language = LANGUAGE_DEFAULT ?? language::en,
|
||||
currency|string $currency = CURRENCY_DEFAULT ?? currency::usd,
|
||||
bool $robot = false,
|
||||
bool $active = true,
|
||||
): record|false {
|
||||
@@ -278,6 +290,7 @@ final class account extends core implements record_interface
|
||||
$name_first,
|
||||
$name_second,
|
||||
$language instanceof language ? $language->name : (string) $language,
|
||||
$currency instanceof currency ? $currency->name : (string) $currency,
|
||||
(int) $robot,
|
||||
/* */
|
||||
(int) $active,
|
||||
@@ -299,11 +312,22 @@ final class account extends core implements record_interface
|
||||
*/
|
||||
public function serialize(): self
|
||||
{
|
||||
if ($this->serialized) {
|
||||
// The record implementor is serialized
|
||||
|
||||
// Exit (fail)
|
||||
throw new exception_runtime('The record implementor is already serialized');
|
||||
}
|
||||
|
||||
// Serializing the record parameters
|
||||
$this->record->language = $this->record->language->name;
|
||||
$this->record->currency = $this->record->currency->name;
|
||||
$this->record->robot = (int) $this->record->robot;
|
||||
$this->record->active = (int) $this->record->active;
|
||||
|
||||
// Writing the status of serializing
|
||||
$this->serialized = true;
|
||||
|
||||
// Exit (success)
|
||||
return $this;
|
||||
}
|
||||
@@ -315,11 +339,22 @@ final class account extends core implements record_interface
|
||||
*/
|
||||
public function deserialize(): self
|
||||
{
|
||||
if (!$this->serialized) {
|
||||
// The record implementor is deserialized
|
||||
|
||||
// Exit (fail)
|
||||
throw new exception_runtime('The record implementor is already deserialized');
|
||||
}
|
||||
|
||||
// Deserializing the record parameters
|
||||
$this->record->language = language::{$this->record->language} ?? LANGUAGE_DEFAULT ?? language::en;
|
||||
$this->record->currency = currency::{$this->record->currency} ?? CURRENCY_DEFAULT ?? currency::usd;
|
||||
$this->record->robot = (bool) $this->record->robot;
|
||||
$this->record->active = (bool) $this->record->active;
|
||||
|
||||
// Writing the status of serializing
|
||||
$this->serialized = false;
|
||||
|
||||
// Exit (success)
|
||||
return $this;
|
||||
}
|
||||
@@ -347,6 +382,29 @@ final class account extends core implements record_interface
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Worker
|
||||
*
|
||||
* Search for the account worker
|
||||
*
|
||||
* @return worker|null The account worker
|
||||
*/
|
||||
public function worker(): ?worker
|
||||
{
|
||||
// Search for the account worker
|
||||
$worker = new worker()->read(filter: fn(record $record) => $record->active === 1 && $record->account === $this->identifier);
|
||||
|
||||
if ($worker instanceof worker) {
|
||||
// Found the account worker
|
||||
|
||||
// Exit (success)
|
||||
return $worker;
|
||||
}
|
||||
|
||||
// Exit (fail)
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Settings
|
||||
*
|
||||
|
||||
@@ -51,6 +51,13 @@ final class authorizations extends core implements record_interface
|
||||
*/
|
||||
public protected(set) database $database;
|
||||
|
||||
/**
|
||||
* Serialized
|
||||
*
|
||||
* @var bool $serialized Is the implementator object serialized?
|
||||
*/
|
||||
private bool $serialized = true;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@@ -124,12 +131,22 @@ final class authorizations extends core implements record_interface
|
||||
*/
|
||||
public function serialize(): self
|
||||
{
|
||||
if ($this->serialized) {
|
||||
// The record implementor is serialized
|
||||
|
||||
// Exit (fail)
|
||||
throw new exception_runtime('The record implementor is already serialized');
|
||||
}
|
||||
|
||||
// Serializing the record parameters
|
||||
$this->record->system = (int) $this->record->system;
|
||||
$this->record->settings = (int) $this->record->settings;
|
||||
$this->record->system_settings = (int) $this->record->system_settings;
|
||||
$this->record->active = (int) $this->record->active;
|
||||
|
||||
// Writing the status of serializing
|
||||
$this->serialized = true;
|
||||
|
||||
// Exit (success)
|
||||
return $this;
|
||||
}
|
||||
@@ -141,12 +158,22 @@ final class authorizations extends core implements record_interface
|
||||
*/
|
||||
public function deserialize(): self
|
||||
{
|
||||
if (!$this->serialized) {
|
||||
// The record implementor is deserialized
|
||||
|
||||
// Exit (fail)
|
||||
throw new exception_runtime('The record implementor is already deserialized');
|
||||
}
|
||||
|
||||
// Deserializing the record parameters
|
||||
$this->record->system = (bool) $this->record->system;
|
||||
$this->record->settings = (bool) $this->record->settings;
|
||||
$this->record->system_settings = (bool) $this->record->system_settings;
|
||||
$this->record->active = (bool) $this->record->active;
|
||||
|
||||
// Writing the status of serializing
|
||||
$this->serialized = false;
|
||||
|
||||
// Exit (success)
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -53,6 +53,13 @@ final class project extends core implements record_interface
|
||||
*/
|
||||
public protected(set) database $database;
|
||||
|
||||
/**
|
||||
* Serialized
|
||||
*
|
||||
* @var bool $serialized Is the implementator object serialized?
|
||||
*/
|
||||
private bool $serialized = true;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
|
||||
@@ -5,7 +5,9 @@ declare(strict_types=1);
|
||||
namespace kodorvan\constructor\models\project\enumerations;
|
||||
|
||||
// Files of the project
|
||||
use kodorvan\constructor\models\project\enumerations\purpose;
|
||||
use kodorvan\constructor\models\project\enumerations\purpose,
|
||||
kodorvan\constructor\models\project\enumerations\integration,
|
||||
kodorvan\constructor\models\worker\enumerations\type as worker_type;
|
||||
|
||||
// The library for languages support
|
||||
use mirzaev\languages\language;
|
||||
@@ -18,20 +20,18 @@ use InvalidArgumentException as exception_argument,
|
||||
DomainException as exception_domain;
|
||||
|
||||
/**
|
||||
* Type
|
||||
* 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 type
|
||||
enum architecture
|
||||
{
|
||||
case chat_robot;
|
||||
case parser;
|
||||
case calculator;
|
||||
case crm;
|
||||
/* case marketplace; */
|
||||
case script;
|
||||
case site;
|
||||
case program;
|
||||
|
||||
@@ -42,7 +42,7 @@ enum type
|
||||
*
|
||||
* @param language $language The language
|
||||
*
|
||||
* @return string The project type label
|
||||
* @return string The project architecture label
|
||||
*/
|
||||
public function label(language $language = LANGUAGE_DEFAULT): string
|
||||
{
|
||||
@@ -56,17 +56,10 @@ enum type
|
||||
language::en => 'Parser',
|
||||
language::ru => 'Парсер'
|
||||
},
|
||||
static::calculator => match ($language) {
|
||||
language::en => 'Calculator',
|
||||
language::ru => 'Калькулятор'
|
||||
static::script => match ($language) {
|
||||
language::en => 'Script',
|
||||
language::ru => 'Скрипт'
|
||||
},
|
||||
static::crm => match ($language) {
|
||||
default => 'CRM'
|
||||
},
|
||||
/* static::marketplace => match ($language) {
|
||||
language::en => 'Marketplace',
|
||||
language::ru => 'Маркетплейс'
|
||||
}, */
|
||||
static::site => match ($language) {
|
||||
language::en => 'Site',
|
||||
language::ru => 'Сайт'
|
||||
@@ -93,12 +86,10 @@ enum type
|
||||
return match ($this) {
|
||||
static::chat_robot => 2,
|
||||
static::parser => 1,
|
||||
static::calculator => 2,
|
||||
static::crm => 1,
|
||||
/* static::marketplace => 4, */
|
||||
static::site => 1,
|
||||
static::program => 1,
|
||||
static::complex => 2,
|
||||
static::script => 1,
|
||||
static::site => 2,
|
||||
static::program => 2,
|
||||
static::complex => 4,
|
||||
default => 1
|
||||
};
|
||||
}
|
||||
@@ -110,6 +101,13 @@ enum type
|
||||
*/
|
||||
public function purposes(): array
|
||||
{
|
||||
// Initializing purposes
|
||||
$purposes = purpose::cases();
|
||||
|
||||
// Deleting the special purpose
|
||||
$indexes = array_keys($purposes, purpose::special);
|
||||
foreach ($indexes as $index) unset($purposes[$index]);
|
||||
|
||||
// Exit (success)
|
||||
return match ($this) {
|
||||
static::chat_robot => [
|
||||
@@ -119,22 +117,15 @@ enum type
|
||||
purpose::game,
|
||||
purpose::gallery,
|
||||
purpose::crm,
|
||||
purpose::calculate,
|
||||
purpose::landing,
|
||||
purpose::marketplace,
|
||||
purpose::events,
|
||||
purpose::charity
|
||||
],
|
||||
static::parser => [
|
||||
purpose::search
|
||||
],
|
||||
static::calculator => [
|
||||
purpose::calculate
|
||||
],
|
||||
static::crm => [
|
||||
purpose::workers,
|
||||
purpose::tools,
|
||||
purpose::objects,
|
||||
purpose::events
|
||||
static::script => [
|
||||
purpose::logic
|
||||
],
|
||||
static::site => [
|
||||
purpose::funnel,
|
||||
@@ -142,23 +133,15 @@ enum type
|
||||
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 => []
|
||||
};
|
||||
@@ -168,6 +151,8 @@ enum type
|
||||
* Cost
|
||||
*
|
||||
* @return int|float The minimal cost of the project development
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public function cost(currency $currency = CURRENCY_DEFAULT): int|float
|
||||
{
|
||||
@@ -181,13 +166,9 @@ enum type
|
||||
currency::usd => 35,
|
||||
currency::rub => 3500
|
||||
},
|
||||
static::calculator => match ($currency) {
|
||||
currency::usd => 40,
|
||||
currency::rub => 4000
|
||||
},
|
||||
static::crm => match ($currency) {
|
||||
currency::usd => 100,
|
||||
currency::rub => 8000
|
||||
static::script => match ($currency) {
|
||||
currency::usd => 10,
|
||||
currency::rub => 1000
|
||||
},
|
||||
static::site => match ($currency) {
|
||||
currency::usd => 50,
|
||||
@@ -203,4 +184,60 @@ enum type
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 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::site => 3,
|
||||
static::program => 4,
|
||||
static::complex => 5,
|
||||
default => 5
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Workers
|
||||
*
|
||||
* @return array Workers
|
||||
*/
|
||||
public function workers(): array
|
||||
{
|
||||
// Exit (success)
|
||||
return match ($this) {
|
||||
static::chat_robot => [
|
||||
worker_type::programmer->name => 1,
|
||||
worker_type::booster->name => 1
|
||||
],
|
||||
static::parser => [
|
||||
worker_type::programmer->name => 1
|
||||
],
|
||||
static::script => [
|
||||
worker_type::programmer->name => 1
|
||||
],
|
||||
static::site => [
|
||||
worker_type::programmer->name => 1,
|
||||
worker_type::designer->name => 1,
|
||||
worker_type::booster->name => 1
|
||||
],
|
||||
static::program => [
|
||||
worker_type::programmer->name => 1,
|
||||
worker_type::designer->name => 1
|
||||
],
|
||||
static::complex => [
|
||||
worker_type::programmer->name => 1
|
||||
],
|
||||
default => [
|
||||
worker_type::programmer->name => 1
|
||||
]
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
<?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;
|
||||
|
||||
/**
|
||||
* Integration
|
||||
*
|
||||
* @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 integration
|
||||
{
|
||||
case one_c;
|
||||
case bitrix24;
|
||||
case moy_sklad;
|
||||
case telegram;
|
||||
case mail;
|
||||
case excel;
|
||||
|
||||
/**
|
||||
* 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::one_c => '1C',
|
||||
static::bitrix24 => match ($language) {
|
||||
language::en => 'Bitrix 24',
|
||||
language::ru => 'Битрикс 24'
|
||||
},
|
||||
static::moy_sklad => match ($language) {
|
||||
language::en => 'Moy Sklad',
|
||||
language::ru => 'Мой Склад'
|
||||
},
|
||||
static::telegram => match ($language) {
|
||||
language::en => 'Telegram',
|
||||
language::ru => 'Телеграм'
|
||||
},
|
||||
static::mail => match ($language) {
|
||||
language::en => 'Mail',
|
||||
language::ru => 'Почта'
|
||||
},
|
||||
static::excel => 'Excel'
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Length
|
||||
*
|
||||
* @return int Amount of buttons cells length
|
||||
*/
|
||||
public function length(): int
|
||||
{
|
||||
// Exit (success)
|
||||
return match ($this) {
|
||||
static::one_c => 1,
|
||||
static::bitrix24 => 2,
|
||||
static::moy_sklad => 2,
|
||||
static::telegram => 2,
|
||||
static::mail => 1,
|
||||
static::excel => 1,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Coefficient
|
||||
*
|
||||
* @return int|float Coefficient to the project development hours
|
||||
*/
|
||||
public function coefficient(): int|float
|
||||
{
|
||||
// Exit (success)
|
||||
return match ($this) {
|
||||
static::one_c => 3,
|
||||
static::bitrix24 => 3.5,
|
||||
static::moy_sklad => 3,
|
||||
static::telegram => 2,
|
||||
static::mail => 1.2,
|
||||
static::excel => 1.5,
|
||||
default => 2
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -28,15 +28,16 @@ enum purpose
|
||||
case crm;
|
||||
case landing;
|
||||
case marketplace;
|
||||
case charity;
|
||||
/* case charity; */
|
||||
case search;
|
||||
case calculate;
|
||||
case logic;
|
||||
case game;
|
||||
|
||||
case workers;
|
||||
/* case workers;
|
||||
case tools;
|
||||
case objects;
|
||||
case events;
|
||||
case events; */
|
||||
|
||||
case special;
|
||||
|
||||
@@ -45,7 +46,7 @@ enum purpose
|
||||
*
|
||||
* @param language $language The language
|
||||
*
|
||||
* @return string The project type label
|
||||
* @return string The project form label
|
||||
*/
|
||||
public function label(language $language = LANGUAGE_DEFAULT): string
|
||||
{
|
||||
@@ -61,7 +62,7 @@ enum purpose
|
||||
},
|
||||
static::neural_network => match ($language) {
|
||||
language::en => 'Neural network',
|
||||
language::ru => 'Нейросети'
|
||||
language::ru => 'Нейросеть'
|
||||
},
|
||||
static::game => match ($language) {
|
||||
language::en => 'Game',
|
||||
@@ -82,10 +83,10 @@ enum purpose
|
||||
language::en => 'Marketplace',
|
||||
language::ru => 'Маркетплейс'
|
||||
},
|
||||
static::charity => match ($language) {
|
||||
/* static::charity => match ($language) {
|
||||
language::en => 'Charity',
|
||||
language::ru => 'Благотворительность'
|
||||
},
|
||||
}, */
|
||||
static::search => match ($language) {
|
||||
language::en => 'Search',
|
||||
language::ru => 'Поиск'
|
||||
@@ -94,11 +95,15 @@ enum purpose
|
||||
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) {
|
||||
/* static::workers => match ($language) {
|
||||
language::en => 'Workes',
|
||||
language::ru => 'Рабочие'
|
||||
},
|
||||
@@ -113,14 +118,93 @@ enum purpose
|
||||
static::events => match ($language) {
|
||||
language::en => 'Events',
|
||||
language::ru => 'События'
|
||||
},
|
||||
}, */
|
||||
static::special => match ($language) {
|
||||
language::en => 'Special',
|
||||
language::ru => 'Особенный'
|
||||
language::ru => 'Особенное'
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Integrations
|
||||
*
|
||||
* @return array Integrations
|
||||
*/
|
||||
public function integrations(): array
|
||||
{
|
||||
// Exit (success)
|
||||
return match ($this) {
|
||||
static::funnel => [
|
||||
integration::telegram,
|
||||
integration::mail,
|
||||
integration::bitrix24
|
||||
],
|
||||
static::contact => [
|
||||
integration::mail,
|
||||
integration::bitrix24
|
||||
],
|
||||
static::neural_network => [
|
||||
integration::telegram
|
||||
],
|
||||
static::game => [
|
||||
integration::telegram
|
||||
],
|
||||
static::gallery => [],
|
||||
static::crm => [
|
||||
integration::one_c,
|
||||
integration::moy_sklad,
|
||||
integration::excel
|
||||
],
|
||||
static::landing => [
|
||||
integration::telegram
|
||||
],
|
||||
static::marketplace => [
|
||||
integration::one_c,
|
||||
integration::moy_sklad,
|
||||
integration::excel
|
||||
],
|
||||
/* static::charity => [
|
||||
integration::one_c,
|
||||
integration::moy_sklad,
|
||||
integration::excel
|
||||
], */
|
||||
static::search => [],
|
||||
static::calculate => [
|
||||
integration::one_c,
|
||||
integration::moy_sklad,
|
||||
integration::excel
|
||||
],
|
||||
/* static::logic => [],
|
||||
static::tools => [
|
||||
integration::one_c,
|
||||
integration::moy_sklad,
|
||||
integration::excel
|
||||
],
|
||||
static::workers => [
|
||||
integration::one_c,
|
||||
integration::moy_sklad,
|
||||
integration::excel
|
||||
],
|
||||
static::objects => [
|
||||
integration::one_c,
|
||||
integration::moy_sklad,
|
||||
integration::excel
|
||||
],
|
||||
static::events => [
|
||||
integration::one_c,
|
||||
integration::moy_sklad,
|
||||
integration::excel
|
||||
],
|
||||
static::special => [
|
||||
integration::one_c,
|
||||
integration::moy_sklad,
|
||||
integration::excel
|
||||
], */
|
||||
default => []
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Length
|
||||
*
|
||||
@@ -138,13 +222,14 @@ enum purpose
|
||||
static::crm => 1,
|
||||
static::landing => 1,
|
||||
static::marketplace => 2,
|
||||
static::charity => 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::events => 1, */
|
||||
static::special => 4,
|
||||
default => 1
|
||||
};
|
||||
@@ -153,27 +238,28 @@ enum purpose
|
||||
/**
|
||||
* Coefficient
|
||||
*
|
||||
* @return int|float Coefficient to the project development cost
|
||||
* @return int|float Coefficient to the project development hours
|
||||
*/
|
||||
public function coefficient(): int|float
|
||||
{
|
||||
// Exit (success)
|
||||
return match ($this) {
|
||||
static::funnel => 1.4,
|
||||
static::funnel => 2,
|
||||
static::contact => 1.1,
|
||||
static::neural_network => 2,
|
||||
static::neural_network => 4,
|
||||
static::game => 3,
|
||||
static::gallery => 1,
|
||||
static::crm => 3,
|
||||
static::landing => 1.2,
|
||||
static::marketplace => 2,
|
||||
static::charity => 0.8,
|
||||
static::crm => 6,
|
||||
static::landing => 1.5,
|
||||
static::marketplace => 8,
|
||||
/* static::charity => 0.8, */
|
||||
static::search => 1,
|
||||
static::calculate => 1.1,
|
||||
static::calculate => 2,
|
||||
/* static::logic => 1,
|
||||
static::tools => 1,
|
||||
static::workers => 1.2,
|
||||
static::objects => 1,
|
||||
static::events => 1.5,
|
||||
static::events => 1.5, */
|
||||
static::special => 2,
|
||||
default => 1
|
||||
};
|
||||
|
||||
@@ -51,6 +51,13 @@ final class settings extends core implements record_interface
|
||||
*/
|
||||
public protected(set) database $database;
|
||||
|
||||
/**
|
||||
* Serialized
|
||||
*
|
||||
* @var bool $serialized Is the implementator object serialized?
|
||||
*/
|
||||
private bool $serialized = true;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
@@ -111,9 +118,19 @@ final class settings extends core implements record_interface
|
||||
*/
|
||||
public function serialize(): self
|
||||
{
|
||||
if ($this->serialized) {
|
||||
// The record implementor is serialized
|
||||
|
||||
// Exit (fail)
|
||||
throw new exception_runtime('The record implementor is already serialized');
|
||||
}
|
||||
|
||||
// Serializing the record parameters
|
||||
$this->record->active = (int) $this->record->active;
|
||||
|
||||
// Writing the status of serializing
|
||||
$this->serialized = true;
|
||||
|
||||
// Exit (success)
|
||||
return $this;
|
||||
}
|
||||
@@ -125,9 +142,19 @@ final class settings extends core implements record_interface
|
||||
*/
|
||||
public function deserialize(): self
|
||||
{
|
||||
if (!$this->serialized) {
|
||||
// The record implementor is deserialized
|
||||
|
||||
// Exit (fail)
|
||||
throw new exception_runtime('The record implementor is already deserialized');
|
||||
}
|
||||
|
||||
// Deserializing the record parameters
|
||||
$this->record->active = (bool) $this->record->active;
|
||||
|
||||
// Writing the status of serializing
|
||||
$this->serialized = false;
|
||||
|
||||
// Exit (success)
|
||||
return $this;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -5,8 +5,7 @@ declare(strict_types=1);
|
||||
namespace kodorvan\constructor\models\telegram\middlewares;
|
||||
|
||||
// Files of the project
|
||||
use kodorvan\constructor\models\core,
|
||||
kodorvan\constructor\models\account as model,
|
||||
use kodorvan\constructor\models\account as model,
|
||||
kodorvan\constructor\models\authorizations;
|
||||
|
||||
// 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
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
||||
*/
|
||||
final class account extends core
|
||||
final class account
|
||||
{
|
||||
/**
|
||||
* Account
|
||||
|
||||
@@ -5,8 +5,7 @@ declare(strict_types=1);
|
||||
namespace kodorvan\constructor\models\telegram\middlewares;
|
||||
|
||||
// Files of the project
|
||||
use kodorvan\constructor\models\core,
|
||||
kodorvan\constructor\models\account,
|
||||
use kodorvan\constructor\models\account,
|
||||
kodorvan\constructor\models\authorizations as model;
|
||||
|
||||
// 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
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
||||
*/
|
||||
final class authorizations extends core
|
||||
final class authorizations
|
||||
{
|
||||
/**
|
||||
* Authorizations
|
||||
|
||||
@@ -5,8 +5,7 @@ declare(strict_types=1);
|
||||
namespace kodorvan\constructor\models\telegram\middlewares;
|
||||
|
||||
// Files of the project
|
||||
use kodorvan\constructor\models\core,
|
||||
kodorvan\constructor\models\account,
|
||||
use kodorvan\constructor\models\account,
|
||||
kodorvan\constructor\models\authorizations;
|
||||
|
||||
// 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
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
||||
*/
|
||||
final class language extends core
|
||||
final class language
|
||||
{
|
||||
/**
|
||||
* Language
|
||||
|
||||
@@ -5,8 +5,7 @@ declare(strict_types=1);
|
||||
namespace kodorvan\constructor\models\telegram\middlewares;
|
||||
|
||||
// Files of the project
|
||||
use kodorvan\constructor\models\core,
|
||||
kodorvan\constructor\models\account,
|
||||
use kodorvan\constructor\models\account,
|
||||
kodorvan\constructor\models\localization as model,
|
||||
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
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
||||
*/
|
||||
final class localization extends core
|
||||
final class localization
|
||||
{
|
||||
/**
|
||||
* Localization
|
||||
|
||||
@@ -5,8 +5,7 @@ declare(strict_types=1);
|
||||
namespace kodorvan\constructor\models\telegram\middlewares;
|
||||
|
||||
// Files of the project
|
||||
use kodorvan\constructor\models\core,
|
||||
kodorvan\constructor\models\account,
|
||||
use kodorvan\constructor\models\account,
|
||||
kodorvan\constructor\models\authorizations;
|
||||
|
||||
// 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
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
||||
*/
|
||||
final class settings extends core
|
||||
final class settings
|
||||
{
|
||||
/**
|
||||
* Settings
|
||||
@@ -75,7 +74,7 @@ final class settings extends core
|
||||
|
||||
// Sending the message
|
||||
$robot->sendMessage(
|
||||
text: '⛔ *' . $localization['not_authorized_settings'] . '*',
|
||||
text: "⛔ *$localization->not_authorized_settings*",
|
||||
parse_mode: mode::MARKDOWN
|
||||
);
|
||||
|
||||
|
||||
@@ -5,8 +5,7 @@ declare(strict_types=1);
|
||||
namespace kodorvan\constructor\models\telegram\middlewares\system;
|
||||
|
||||
// Files of the project
|
||||
use kodorvan\constructor\models\core,
|
||||
kodorvan\constructor\models\account,
|
||||
use kodorvan\constructor\models\account,
|
||||
kodorvan\constructor\models\authorizations;
|
||||
|
||||
// The library for languages support
|
||||
@@ -23,14 +22,14 @@ use SergiX44\Nutgram\Nutgram as telegram,
|
||||
use Error as error;
|
||||
|
||||
/**
|
||||
* Telegram middleware: language
|
||||
* Telegram middleware: system settings
|
||||
*
|
||||
* @package kodorvan\constructor\models\telegram\middlewares\system
|
||||
*
|
||||
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
||||
*/
|
||||
final class settings extends core
|
||||
final class settings
|
||||
{
|
||||
/**
|
||||
* System settings (middleware)
|
||||
|
||||
227
kodorvan/constructor/system/models/worker.php
Normal file
227
kodorvan/constructor/system/models/worker.php
Normal file
@@ -0,0 +1,227 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace kodorvan\constructor\models;
|
||||
|
||||
// Files of the project
|
||||
use kodorvan\constructor\models\core,
|
||||
kodorvan\constructor\models\authorizations,
|
||||
kodorvan\constructor\models\settings,
|
||||
kodorvan\constructor\models\project,
|
||||
kodorvan\constructor\models\account,
|
||||
kodorvan\constructor\models\project\enumerations\type as project_type,
|
||||
kodorvan\constructor\models\project\enumerations\status as project_status;
|
||||
|
||||
// The library for languages support
|
||||
use mirzaev\languages\language;
|
||||
|
||||
// The library for currencies support
|
||||
use mirzaev\currencies\currency;
|
||||
|
||||
// Baza database
|
||||
use mirzaev\baza\database,
|
||||
mirzaev\baza\column,
|
||||
mirzaev\baza\record,
|
||||
mirzaev\baza\enumerations\encoding,
|
||||
mirzaev\baza\enumerations\type;
|
||||
|
||||
// Active Record pattern
|
||||
use mirzaev\record\interfaces\record as record_interface,
|
||||
mirzaev\record\traits\record as record_trait;
|
||||
|
||||
// Svoboda time
|
||||
use svoboda\time\statement as svoboda;
|
||||
|
||||
// Framework for Telegram
|
||||
use SergiX44\Nutgram\Telegram\Types\User\User as telegram_user;
|
||||
|
||||
// Built-in libraries
|
||||
use Exception as exception,
|
||||
RuntimeException as exception_runtime;
|
||||
|
||||
/**
|
||||
* Worker
|
||||
*
|
||||
* @package kodorvan\constructor\models
|
||||
*
|
||||
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
|
||||
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
|
||||
*/
|
||||
final class worker extends core implements record_interface
|
||||
{
|
||||
use record_trait;
|
||||
|
||||
/**
|
||||
* File
|
||||
*
|
||||
* @var string $file Path to the database file
|
||||
*/
|
||||
protected string $file = DATABASES . DIRECTORY_SEPARATOR . 'workers.baza';
|
||||
|
||||
/**
|
||||
* Database
|
||||
*
|
||||
* @var database $database The database
|
||||
*/
|
||||
public protected(set) database $database;
|
||||
|
||||
/**
|
||||
* Serialized
|
||||
*
|
||||
* @var bool $serialized Is the implementator object serialized?
|
||||
*/
|
||||
private bool $serialized = true;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @method record|null $record The record
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(?record $record = null)
|
||||
{
|
||||
// Initializing the database
|
||||
$this->database = new database()
|
||||
->encoding(encoding::utf8)
|
||||
->columns(
|
||||
new column('identifier', type::long_long_unsigned),
|
||||
new column('account', type::long_long_unsigned),
|
||||
new column('hour', type::integer_unsigned),
|
||||
new column('currency', type::string, ['length' => 3]),
|
||||
new column('active', type::char),
|
||||
new column('updated', type::integer_unsigned),
|
||||
new column('created', type::integer_unsigned)
|
||||
)
|
||||
->connect($this->file);
|
||||
|
||||
// Initializing the record
|
||||
$record instanceof record and $this->record = $record;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write
|
||||
*
|
||||
* @param int $account The account identifier
|
||||
* @param int|float $hour Cost per hour
|
||||
* @param currency|string $currency Currency of cost per hour
|
||||
* @param bool $active Is the record active?
|
||||
*
|
||||
* @return record|false The record, if created
|
||||
*/
|
||||
public function write(
|
||||
int $account,
|
||||
int|float $hour,
|
||||
currency|string $currency = CURRENCY_DEFAULT ?? currency::usd,
|
||||
bool $active = true,
|
||||
): record|false {
|
||||
// Initializing the record
|
||||
$record = $this->database->record(
|
||||
$this->database->count() + 1,
|
||||
(int) $account,
|
||||
$hour,
|
||||
$currency instanceof currency ? $currency->name : (string) $currency,
|
||||
(int) $active,
|
||||
svoboda::timestamp(),
|
||||
svoboda::timestamp()
|
||||
);
|
||||
|
||||
// Writing the record into the database
|
||||
$created = $this->database->write($record);
|
||||
|
||||
// Exit (success)
|
||||
return $created ? $record : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Account
|
||||
*
|
||||
* Search for the worker account
|
||||
*
|
||||
* @return account|null The account worker
|
||||
*/
|
||||
public function account(): ?account
|
||||
{
|
||||
// Search for the worker account
|
||||
$account = new account()->read(filter: fn(record $record) => $record->active === 1 && $record->identifier === $this->account);
|
||||
|
||||
if ($account instanceof account) {
|
||||
// Found the worker account
|
||||
|
||||
// Exit (success)
|
||||
return $account;
|
||||
}
|
||||
|
||||
// Exit (fail)
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Workers
|
||||
*
|
||||
* Search for workers
|
||||
*
|
||||
* @param int $amount Amount
|
||||
*
|
||||
* @return array Workers
|
||||
*/
|
||||
public static function workers(int $amount = 100): array
|
||||
{
|
||||
// Search for workers and exit (success/fail)
|
||||
return new static()->database->read(
|
||||
filter: fn(record $record) => $record->active === 1,
|
||||
amount: $amount
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize
|
||||
*
|
||||
* @return self The instance from which the method was called (fluent interface)
|
||||
*/
|
||||
public function serialize(): self
|
||||
{
|
||||
if ($this->serialized) {
|
||||
// The record implementor is serialized
|
||||
|
||||
// Exit (fail)
|
||||
throw new exception_runtime('The record implementor is already serialized');
|
||||
}
|
||||
|
||||
// Serializing the record parameters
|
||||
$this->record->currency = $this->record->currency->name;
|
||||
$this->record->active = (int) $this->record->active;
|
||||
|
||||
// Writing the status of serializing
|
||||
$this->serialized = true;
|
||||
|
||||
// Exit (success)
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deserialize
|
||||
*
|
||||
* @return self The instance from which the method was called (fluent interface)
|
||||
*/
|
||||
public function deserialize(): self
|
||||
{
|
||||
if (!$this->serialized) {
|
||||
// The record implementor is deserialized
|
||||
|
||||
// Exit (fail)
|
||||
throw new exception_runtime('The record implementor is already deserialized');
|
||||
}
|
||||
|
||||
// Deserializing the record parameters
|
||||
$this->record->currency = currency::{$this->record->currency} ?? CURRENCY_DEFAULT ?? currency::usd;
|
||||
$this->record->active = (bool) $this->record->active;
|
||||
|
||||
// Writing the status of serializing
|
||||
$this->serialized = false;
|
||||
|
||||
// Exit (success)
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace kodorvan\constructor\models\worker\enumerations;
|
||||
|
||||
// The library for languages support
|
||||
use mirzaev\languages\language;
|
||||
|
||||
// Built-in libraries
|
||||
use InvalidArgumentException as exception_argument,
|
||||
DomainException as exception_domain;
|
||||
|
||||
/**
|
||||
* Type
|
||||
*
|
||||
* @package kodorvan\neurobot\models\worker\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 programmer;
|
||||
case designer;
|
||||
case booster;
|
||||
|
||||
/**
|
||||
* 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::programmer => match ($language) {
|
||||
language::en => 'Programmer',
|
||||
language::ru => 'Программист'
|
||||
},
|
||||
static::designer => match ($language) {
|
||||
language::en => 'Designer',
|
||||
language::ru => 'Дизайнер'
|
||||
},
|
||||
static::booster => match ($language) {
|
||||
language::en => 'Booster',
|
||||
language::ru => 'Бустер'
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -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(); */
|
||||
@@ -60,9 +60,9 @@ require ROOT . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
|
||||
|
||||
// Initializing the robot
|
||||
$robot = new telegram(
|
||||
token: TELEGRAM['constructor']['key'],
|
||||
token: TELEGRAM['key'],
|
||||
config: new telegram_settings(
|
||||
botName: TELEGRAM['constructor']['name']
|
||||
botName: TELEGRAM['name']
|
||||
)
|
||||
);
|
||||
|
||||
@@ -72,5 +72,5 @@ $robot->setWebhook(
|
||||
ip_address: SERVER_IP_ADDRESS,
|
||||
max_connections: 10,
|
||||
drop_pending_updates: false,
|
||||
secret_token: 'bebra228'
|
||||
secret_token: TELEGRAM['password']
|
||||
);
|
||||
|
||||
@@ -71,14 +71,14 @@ require ROOT . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
|
||||
|
||||
// Initializing the robot
|
||||
$robot = new telegram(
|
||||
token: TELEGRAM['constructor']['key'],
|
||||
token: TELEGRAM['key'],
|
||||
config: new telegram_settings(
|
||||
botName: TELEGRAM['constructor']['name'],
|
||||
botName: TELEGRAM['name'],
|
||||
cache: new cache(new cache_adapter())
|
||||
)
|
||||
);
|
||||
|
||||
$webhook = new webhook(secretToken: 'bebra228');
|
||||
$webhook = new webhook(secretToken: TELEGRAM['password']);
|
||||
$webhook->setSafeMode(true);
|
||||
|
||||
$robot->setRunningMode($webhook);
|
||||
@@ -88,7 +88,6 @@ $robot->middleware(middleware_language::class);
|
||||
$robot->middleware(middleware_localization::class);
|
||||
$robot->middleware(middleware_authorizations::class);
|
||||
|
||||
|
||||
// Start
|
||||
$robot->registerCommand(command_start::class);
|
||||
$robot->onCommand('start telegram voronka', command_start::class);
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
*
|
||||
!.gitignore
|
||||
!*.sample
|
||||
!*/
|
||||
!*.md
|
||||
|
||||
@@ -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"
|
||||
@@ -21,10 +21,22 @@ 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_LANGUAGE_ADD', PROJECT_REPOSITORY . '/src/branch/stable/' . PROJECT_CREATOR . '/' . PROJECT_NAME . '/system/localizations');
|
||||
/* define('PROJECT_CERTIFICATE', SETTINGS . DIRECTORY_SEPARATOR . 'cert.pem'); */
|
||||
|
||||
define('CURRENCY_DEFAULT', currency::usd);
|
||||
define('LANGUAGE_DEFAULT', language::en);
|
||||
|
||||
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_DAY_HOURS', 4);
|
||||
define('PROJECT_CREATE_DAY_ADDITIONAL', 1);
|
||||
define('PROJECT_CREATE_COST_HOUR_DEFAULT', 20);
|
||||
define('PROJECT_CREATE_COST_CURRENCY', CURRENCY_DEFAULT);
|
||||
|
||||
define('PROJECT_CREATE_REQUEST_RECEIVERS', [
|
||||
'-0000000000000'
|
||||
]);
|
||||
|
||||
// Initializing default theme for the views templater
|
||||
define('THEME', 'default');
|
||||
|
||||
@@ -2,18 +2,17 @@
|
||||
|
||||
// Telegram API chat-robot
|
||||
return [
|
||||
'constructor' => [
|
||||
'identifier' => 0,
|
||||
'name' => 'kodorvan',
|
||||
'domain' => '',
|
||||
'key' => '',
|
||||
'database' => [
|
||||
'host' => '/run/mysqld/mysqld.sock',
|
||||
'port' => 3306,
|
||||
'user' => '',
|
||||
'password' => '',
|
||||
'database' => '',
|
||||
]
|
||||
'identifier' => 0,
|
||||
'domain' => 'kodorvan_bot',
|
||||
'name' => 'kodorvan',
|
||||
'password' => '',
|
||||
'key' => '',
|
||||
'database' => [
|
||||
'host' => '/run/mysqld/mysqld.sock',
|
||||
'port' => 3306,
|
||||
'user' => '',
|
||||
'password' => '',
|
||||
'database' => '',
|
||||
]
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user