generated from mirzaev/pot-php-telegram
main menu
This commit is contained in:
@@ -34,7 +34,8 @@
|
|||||||
"twig/twig": "^3.2",
|
"twig/twig": "^3.2",
|
||||||
"twig/extra-bundle": "^3.7",
|
"twig/extra-bundle": "^3.7",
|
||||||
"twig/intl-extra": "^3.10",
|
"twig/intl-extra": "^3.10",
|
||||||
"react/filesystem": "^0.1.2"
|
"react/filesystem": "^0.1.2",
|
||||||
|
"nyholm/psr7": "^1.8"
|
||||||
},
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"mirzaev/files": "Easy working with files",
|
"mirzaev/files": "Easy working with files",
|
||||||
@@ -53,5 +54,11 @@
|
|||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"pre-update-cmd": "./install.sh"
|
"pre-update-cmd": "./install.sh"
|
||||||
|
},
|
||||||
|
"config": {
|
||||||
|
"allow-plugins": {
|
||||||
|
"php-http/discovery": true,
|
||||||
|
"wyrihaximus/composer-update-bin-autoload-path": true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
5673
composer.lock
generated
Normal file
5673
composer.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
0
install.sh
Normal file → Executable file
0
install.sh
Normal file → Executable file
@@ -9,6 +9,13 @@ return [
|
|||||||
|
|
||||||
// Главное меню
|
// Главное меню
|
||||||
'menu_title' => 'Главное меню',
|
'menu_title' => 'Главное меню',
|
||||||
|
'menu_description_guest' => "*Создайте ваш первый проект* и получите *ориентировочную стоимость* всего за 2 минуты\n\nПосле расчёта *сформируйте заявку* к проджект\-менеджеру для более глубокого анализа и составлении ТЗ\n\nПри желании этот этап можно пропустить сразу *связавшись с оператором* _\(график работы указан в его профиле\)_",
|
||||||
|
'menu_description_partner' => "Надеемся, что наше сотрудничество оставляет сугубо *положительные эмоции* и способствует *развитию обоих сторон*\n\n*Благодарим за выбор нашей команды*",
|
||||||
|
'menu_experiment' => "Чат\-робот находится в *экспериментальном* режиме\n_Просьба сообщать при обнаружении любых проблем, спасибо_",
|
||||||
|
'menu_update' => 'Последнее обновление',
|
||||||
|
'menu_button_project_new' => 'Создать',
|
||||||
|
'menu_button_projects' => 'Проекты',
|
||||||
|
'menu_button_operator' => 'Связь с оператором',
|
||||||
|
|
||||||
// Аккаунт
|
// Аккаунт
|
||||||
'account_title' => 'Аккаунт',
|
'account_title' => 'Аккаунт',
|
||||||
@@ -7,7 +7,8 @@ namespace kodorvan\constructor\models;
|
|||||||
// Files of the project
|
// Files of the project
|
||||||
use kodorvan\constructor\models\core,
|
use kodorvan\constructor\models\core,
|
||||||
kodorvan\constructor\models\authorizations,
|
kodorvan\constructor\models\authorizations,
|
||||||
kodorvan\constructor\models\settings;
|
kodorvan\constructor\models\settings,
|
||||||
|
kodorvan\constructor\models\projects;
|
||||||
|
|
||||||
// The library for languages support
|
// The library for languages support
|
||||||
use mirzaev\languages\language;
|
use mirzaev\languages\language;
|
||||||
@@ -363,5 +364,22 @@ final class account extends core implements record_interface
|
|||||||
// Exit (fail)
|
// Exit (fail)
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Projects
|
||||||
|
*
|
||||||
|
* Search for the account projects
|
||||||
|
*
|
||||||
|
* @param int $amount Maximum amount
|
||||||
|
*
|
||||||
|
* @return array The account projects
|
||||||
|
*/
|
||||||
|
public function projects(int $amount = 20): array
|
||||||
|
{
|
||||||
|
// Search for the account projects
|
||||||
|
$projects = new project()->database->read(filter: fn(record $record) => $record->active === 1 && $record->account === $this->identifier, amount: $amount);
|
||||||
|
|
||||||
|
// Exit (success/fail)
|
||||||
|
return $projects;
|
||||||
|
}
|
||||||
|
}
|
||||||
139
kodorvan/constructor/system/models/project.php
Normal file
139
kodorvan/constructor/system/models/project.php
Normal file
@@ -0,0 +1,139 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace kodorvan\constructor\models;
|
||||||
|
|
||||||
|
// Files of the project
|
||||||
|
use kodorvan\constructor\models\core;
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
|
||||||
|
// Built-in libraries
|
||||||
|
use Exception as exception,
|
||||||
|
RuntimeException as exception_runtime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Project
|
||||||
|
*
|
||||||
|
* @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 project extends core implements record_interface
|
||||||
|
{
|
||||||
|
use record_trait;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* File
|
||||||
|
*
|
||||||
|
* @var string $database Path to the database file
|
||||||
|
*/
|
||||||
|
protected string $file = DATABASES . DIRECTORY_SEPARATOR . 'project.baza';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Database
|
||||||
|
*
|
||||||
|
* @var database $database The database
|
||||||
|
*/
|
||||||
|
public protected(set) database $database;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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('name', type::string, ['length' => 64]),
|
||||||
|
/* new column('', type::), */
|
||||||
|
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 string $name Name of the project
|
||||||
|
* @param int $active Is the record active?
|
||||||
|
*
|
||||||
|
* @return int|false The record identifier, if created
|
||||||
|
*/
|
||||||
|
public function write(
|
||||||
|
int $account,
|
||||||
|
string $name = '',
|
||||||
|
bool $active = true,
|
||||||
|
): int|false {
|
||||||
|
$record = $this->database->record(
|
||||||
|
$this->database->count() + 1,
|
||||||
|
$account,
|
||||||
|
$name,
|
||||||
|
(int) $active,
|
||||||
|
svoboda::timestamp(),
|
||||||
|
svoboda::timestamp()
|
||||||
|
);
|
||||||
|
|
||||||
|
// Writing the record into the database
|
||||||
|
$created = $this->database->write($record);
|
||||||
|
|
||||||
|
// Exit (success)
|
||||||
|
return $created ? $record->identifier : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Serialize
|
||||||
|
*
|
||||||
|
* @return self The instance from which the method was called (fluent interface)
|
||||||
|
*/
|
||||||
|
public function serialize(): self
|
||||||
|
{
|
||||||
|
// Serializing the record parameters
|
||||||
|
$this->record->active = (int) $this->record->active;
|
||||||
|
|
||||||
|
// Exit (success)
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deserialize
|
||||||
|
*
|
||||||
|
* @return self The instance from which the method was called (fluent interface)
|
||||||
|
*/
|
||||||
|
public function deserialize(): self
|
||||||
|
{
|
||||||
|
// Deserializing the record parameters
|
||||||
|
$this->record->active = (bool) $this->record->active;
|
||||||
|
|
||||||
|
// Exit (success)
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
<?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;
|
||||||
|
}
|
||||||
144
kodorvan/constructor/system/models/project/type.php
Normal file
144
kodorvan/constructor/system/models/project/type.php
Normal file
@@ -0,0 +1,144 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace kodorvan\constructor\models\project;
|
||||||
|
|
||||||
|
// Files of the type
|
||||||
|
use kodorvan\constructor\models\core,
|
||||||
|
kodorvan\constructor\models\project\enumerations\type as project_type;
|
||||||
|
|
||||||
|
// Baza database
|
||||||
|
use mirzaev\baza\database,
|
||||||
|
mirzaev\baza\column,
|
||||||
|
mirzaev\baza\record,
|
||||||
|
mirzaev\baza\enumerations\encoding,
|
||||||
|
mirzaev\baza\enumerations\type as baza_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;
|
||||||
|
|
||||||
|
// Built-in libraries
|
||||||
|
use Exception as exception,
|
||||||
|
RuntimeException as exception_runtime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Type
|
||||||
|
*
|
||||||
|
* @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 type extends core implements record_interface
|
||||||
|
{
|
||||||
|
use record_trait;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* File
|
||||||
|
*
|
||||||
|
* @var string $database Path to the database file
|
||||||
|
*/
|
||||||
|
protected string $file = DATABASES . DIRECTORY_SEPARATOR . 'project' . DIRECTORY_SEPARATOR . 'type.baza';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Database
|
||||||
|
*
|
||||||
|
* @var database $database The database
|
||||||
|
*/
|
||||||
|
public protected(set) database $database;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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', baza_type::long_long_unsigned),
|
||||||
|
new column('account', baza_type::long_long_unsigned),
|
||||||
|
new column('type', baza_type::string, ['length' => 32]),
|
||||||
|
new column('special', baza_type::string, ['length' => 256]),
|
||||||
|
new column('active', baza_type::char),
|
||||||
|
new column('updated', baza_type::integer_unsigned),
|
||||||
|
new column('created', baza_type::integer_unsigned)
|
||||||
|
)
|
||||||
|
->connect($this->file);
|
||||||
|
|
||||||
|
// Initializing the record
|
||||||
|
$record instanceof record and $this->record = $record;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write
|
||||||
|
*
|
||||||
|
* @param int $account The account identifier
|
||||||
|
* @param project_type $type Type of the project
|
||||||
|
* @param string $special Information about special project
|
||||||
|
* @param int $active Is the record active?
|
||||||
|
*
|
||||||
|
* @return int|false The record identifier, if created
|
||||||
|
*/
|
||||||
|
public function write(
|
||||||
|
int $account,
|
||||||
|
project_type $type = project_type::special,
|
||||||
|
string $special = '',
|
||||||
|
bool $active = true,
|
||||||
|
): int|false {
|
||||||
|
$record = $this->database->record(
|
||||||
|
$this->database->count() + 1,
|
||||||
|
$account,
|
||||||
|
$type->name,
|
||||||
|
$type === project_type::special ? $special : '',
|
||||||
|
(int) $active,
|
||||||
|
svoboda::timestamp(),
|
||||||
|
svoboda::timestamp()
|
||||||
|
);
|
||||||
|
|
||||||
|
// Writing the record into the database
|
||||||
|
$created = $this->database->write($record);
|
||||||
|
|
||||||
|
// Exit (success)
|
||||||
|
return $created ? $record->identifier : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Serialize
|
||||||
|
*
|
||||||
|
* @return self The instance from which the method was called (fluent interface)
|
||||||
|
*/
|
||||||
|
public function serialize(): self
|
||||||
|
{
|
||||||
|
// Serializing the record parameters
|
||||||
|
$this->record->active = (int) $this->record->active;
|
||||||
|
$this->record->type = $this->record->type->name;
|
||||||
|
|
||||||
|
// Exit (success)
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deserialize
|
||||||
|
*
|
||||||
|
* @return self The instance from which the method was called (fluent interface)
|
||||||
|
*/
|
||||||
|
public function deserialize(): self
|
||||||
|
{
|
||||||
|
// Deserializing the record parameters
|
||||||
|
$this->record->active = (bool) $this->record->active;
|
||||||
|
$this->record->type = project_type::{$this->record->active};
|
||||||
|
|
||||||
|
// Exit (success)
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -41,20 +41,6 @@ final class commands extends core
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function start(context $context): void
|
public static function start(context $context): void
|
||||||
{
|
|
||||||
static::menu($context);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Menu
|
|
||||||
*
|
|
||||||
* Responce for command: '/menu'
|
|
||||||
*
|
|
||||||
* @param context $context Request data from Telegram
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public static function menu(context $context): void
|
|
||||||
{
|
{
|
||||||
// Initializing the account
|
// Initializing the account
|
||||||
$account = $context->get('account');
|
$account = $context->get('account');
|
||||||
@@ -74,23 +60,55 @@ final class commands extends core
|
|||||||
if ($localization) {
|
if ($localization) {
|
||||||
// Initialized localization
|
// Initialized localization
|
||||||
|
|
||||||
// Initializing the title
|
// Initializing the message title text
|
||||||
$title = '📋 *' . $localization['menu_title'] . '*';
|
$title = '📋 *' . $localization['menu_title'] . '*';
|
||||||
|
|
||||||
|
// Initializing the keyboard array
|
||||||
|
/* $keyboard = [];
|
||||||
|
|
||||||
|
foreach (project) */
|
||||||
|
|
||||||
|
// Calculating amount of projects
|
||||||
|
$projects = count($account->projects());
|
||||||
|
|
||||||
|
// Initializing the message description text
|
||||||
|
$description = $projects > 0 ? $localization['menu_description_partner'] : ('🔥 ' . $localization['menu_description_guest']);
|
||||||
|
|
||||||
|
// Initializing the message experiment text
|
||||||
|
$experiment = '⚠️ ' . $localization['menu_experiment'];
|
||||||
|
|
||||||
|
// Initializing the message last update text
|
||||||
|
exec(command: 'git log --oneline $(git describe --tags --abbrev=0 @^)..@ -1 --format="%at" | xargs -I{} date -d @{} "+%Y.%m.%d %H:%M"', output: $git);
|
||||||
|
$update = empty($git) ? '' : "\n*" . $localization['menu_update'] . ':* ' . $git;
|
||||||
|
|
||||||
// Sending the message
|
// Sending the message
|
||||||
$context->sendMessage(
|
$context->sendMessage(
|
||||||
<<<TXT
|
<<<TXT
|
||||||
$title
|
$title
|
||||||
|
|
||||||
|
$description
|
||||||
|
|
||||||
|
$experiment$update
|
||||||
TXT,
|
TXT,
|
||||||
[
|
[
|
||||||
'reply_markup' => [
|
'reply_markup' => [
|
||||||
'inline_keyboard' => [
|
'inline_keyboard' => [
|
||||||
/* [
|
|
||||||
[
|
[
|
||||||
'text' => '⚙️ ' . $localization[''],
|
[
|
||||||
'callback_data' => ''
|
'text' => '📂 ' . $localization['menu_button_project_new'],
|
||||||
|
'callback_data' => 'calculator'
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'text' => '🗂 ' . $localization['menu_button_projects'] . ': ' . $projects,
|
||||||
|
'callback_data' => 'projects'
|
||||||
|
]
|
||||||
|
],
|
||||||
|
[
|
||||||
|
[
|
||||||
|
'text' => '📡 ' . $localization['menu_button_operator'],
|
||||||
|
'callback_data' => 'operator'
|
||||||
|
]
|
||||||
]
|
]
|
||||||
] */
|
|
||||||
],
|
],
|
||||||
'disable_notification' => true,
|
'disable_notification' => true,
|
||||||
'remove_keyboard' => true
|
'remove_keyboard' => true
|
||||||
@@ -353,4 +371,3 @@ final class commands extends core
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user