1
0
forked from mirzaev/pot-php

fixed by garden/campanula

This commit is contained in:
2026-01-07 14:57:15 +05:00
parent 190ef8eabd
commit a0ca54bf25
7 changed files with 102 additions and 89 deletions

View File

@@ -7,11 +7,7 @@ namespace ${REPO_OWNER}\${REPO_NAME}\models;
// Files of the project // Files of the project
use ${REPO_OWNER}\${REPO_NAME}\models\core, use ${REPO_OWNER}\${REPO_NAME}\models\core,
${REPO_OWNER}\${REPO_NAME}\models\authorizations, ${REPO_OWNER}\${REPO_NAME}\models\authorizations,
${REPO_OWNER}\${REPO_NAME}\models\chat, ${REPO_OWNER}\${REPO_NAME}\models\settings;
${REPO_OWNER}\${REPO_NAME}\models\settings,
${REPO_OWNER}\${REPO_NAME}\models\tariff,
${REPO_OWNER}\${REPO_NAME}\models\code,
${REPO_OWNER}\${REPO_NAME}\models\enumerations\tariff as tariff_type;
// The library for languages support // The library for languages support
use mirzaev\languages\language; use mirzaev\languages\language;
@@ -84,6 +80,7 @@ final class account extends core implements record_interface
new column('language', type::string, ['length' => 2]), new column('language', type::string, ['length' => 2]),
new column('robot', type::char), new column('robot', type::char),
/* new column('', type::), */ /* new column('', type::), */
new column('active', type::char),
new column('updated', type::integer_unsigned), new column('updated', type::integer_unsigned),
new column('created', type::integer_unsigned) new column('created', type::integer_unsigned)
) )
@@ -115,8 +112,7 @@ final class account extends core implements record_interface
if ( if (
$$account->domain !== (string) $$telegram->getUsername() || $$account->domain !== (string) $$telegram->getUsername() ||
$$account->name_first !== (string) $$telegram->getFirstName() || $$account->name_first !== (string) $$telegram->getFirstName() ||
$$account->name_second !== (string) $$telegram->getLastName() || $$account->name_second !== (string) $$telegram->getLastName()
$$account->language !== (string) $$telegram->getLanguageCode()
) { ) {
// The telegram account was updated // The telegram account was updated
@@ -128,7 +124,6 @@ final class account extends core implements record_interface
$$record->domain = (string) $$telegram->getUsername(); $$record->domain = (string) $$telegram->getUsername();
$$record->name_first = (string) $$telegram->getFirstName(); $$record->name_first = (string) $$telegram->getFirstName();
$$record->name_second = (string) $$telegram->getLastName(); $$record->name_second = (string) $$telegram->getLastName();
$$record->language = (string) $$telegram->getLanguageCode();
$$record->updated = svoboda::timestamp(); $$record->updated = svoboda::timestamp();
}, },
amount: 1 amount: 1
@@ -211,7 +206,7 @@ final class account extends core implements record_interface
$$record = $$this->write( $$record = $$this->write(
telegram_identifier: (int) $$telegram->getId(), telegram_identifier: (int) $$telegram->getId(),
name_first: (string) $$telegram->getFirstName(), name_first: (string) $$telegram->getFirstName(),
name_last: (string) $$telegram->getLastName(), name_second: (string) $$telegram->getLastName(),
domain: (string) $$telegram->getUsername(), domain: (string) $$telegram->getUsername(),
language: (string) $$telegram->getLanguageCode(), language: (string) $$telegram->getLanguageCode(),
robot: (bool) $$telegram->isBot() robot: (bool) $$telegram->isBot()
@@ -232,18 +227,6 @@ final class account extends core implements record_interface
// Creating the account settings // Creating the account settings
$$settings->write(account: $$record->identifier); $$settings->write(account: $$record->identifier);
// Initializing the chat model
$$chat = new chat();
// Creating the account chat
$$record->chat = $$chat->write(account: $$record->identifier, network: NETWORK_DEFAULT);
// Initializing the tariff model
$$tariff = new tariff();
// Creating the tariff record
$$record->tariff = $$tariff->write(account: $$record->identifier, invoice: 0, active: 1, type: TARIFF_DEFAULT ?? tariff_type::free);
// Writing the record into the database // Writing the record into the database
$$record = $$this->database->read( $$record = $$this->database->read(
filter: fn(record $$_record) => $$_record->identifier === $$record->identifier, filter: fn(record $$_record) => $$_record->identifier === $$record->identifier,
@@ -264,10 +247,11 @@ final class account extends core implements record_interface
* *
* @param int $$telegram_identifier The telegram account identifier * @param int $$telegram_identifier The telegram account identifier
* @param string $$name_first * @param string $$name_first
* @param string $$name_last * @param string $$name_second
* @param string $$domain * @param string $$domain
* @param language|string $$language * @param language|string $$language
* @param bool $$robot Is a robot? * @param bool $$robot Is a robot?
* @param bool $$active Is the record active?
* *
* @return record|false The record, if created * @return record|false The record, if created
*/ */
@@ -275,9 +259,10 @@ final class account extends core implements record_interface
int $$telegram_identifier, int $$telegram_identifier,
string $$domain = '', string $$domain = '',
string $$name_first = '', string $$name_first = '',
string $$name_last = '', string $$name_second = '',
language|string $$language = LANGUAGE_DEFAULT ?? language::en, language|string $$language = LANGUAGE_DEFAULT ?? language::en,
bool $$robot = false, bool $$robot = false,
bool $$active = true,
): record|false { ): record|false {
// Initializing the record // Initializing the record
$$record = $$this->database->record( $$record = $$this->database->record(
@@ -285,10 +270,11 @@ final class account extends core implements record_interface
(int) $$telegram_identifier, (int) $$telegram_identifier,
$$domain, $$domain,
$$name_first, $$name_first,
$$name_last, $$name_second,
$$language instanceof language ? $$language->name : (string) $$language, $$language instanceof language ? $$language->name : (string) $$language,
(int) $$robot, (int) $$robot,
/* */ /* */
(int) $$active,
svoboda::timestamp(), svoboda::timestamp(),
svoboda::timestamp() svoboda::timestamp()
); );
@@ -309,6 +295,8 @@ final class account extends core implements record_interface
{ {
// Serializing the record parameters // Serializing the record parameters
$$this->record->language = $$this->record->language->name; $$this->record->language = $$this->record->language->name;
$$this->record->robot = (int) $$this->record->robot;
$$this->record->active = (int) $$this->record->active;
// Exit (success) // Exit (success)
return $$this; return $$this;
@@ -323,6 +311,8 @@ final class account extends core implements record_interface
{ {
// Deserializing the record parameters // Deserializing the record parameters
$$this->record->language = language::{$$this->record->language} ?? LANGUAGE_DEFAULT ?? language::en; $$this->record->language = language::{$$this->record->language} ?? LANGUAGE_DEFAULT ?? language::en;
$$this->record->robot = (bool) $$this->record->robot;
$$this->record->active = (bool) $$this->record->active;
// Exit (success) // Exit (success)
return $$this; return $$this;

View File

@@ -71,9 +71,9 @@ final class authorizations extends core implements record_interface
new column('account', type::long_long_unsigned), new column('account', type::long_long_unsigned),
new column('system', type::char), new column('system', type::char),
new column('settings', type::char), new column('settings', type::char),
new column('chat', type::char),
/* new column('', type::char), */ /* new column('', type::char), */
new column('system_settings', type::char), new column('system_settings', type::char),
new column('active', type::char),
new column('updated', type::integer_unsigned), new column('updated', type::integer_unsigned),
new column('created', type::integer_unsigned) new column('created', type::integer_unsigned)
) )
@@ -87,25 +87,28 @@ final class authorizations extends core implements record_interface
* Write * Write
* *
* @param int $$account The account identifier * @param int $$account The account identifier
* @param int $$system * @param bool $$system
* @param int $$settings * @param bool $$settings
* @param int $$system_settings * @param bool $$system_settings
* @param bool $$active Is the record active?
* *
* @return int|false The record identifier, if created * @return int|false The record identifier, if created
*/ */
public function write( public function write(
int $$account, int $$account,
int $$system = 1, bool $$system = true,
int $$settings = 1, bool $$settings = true,
int $$system_settings = 0, bool $$system_settings = false,
bool $$active = true,
): int|false ): int|false
{ {
$$record = $$this->database->record( $$record = $$this->database->record(
$$this->database->count() + 1, $$this->database->count() + 1,
$$account, $$account,
$$system, (int) $$system,
$$settings, (int) $$settings,
$$system_settings, (int) $$system_settings,
(int) $$active,
svoboda::timestamp(), svoboda::timestamp(),
svoboda::timestamp() svoboda::timestamp()
); );
@@ -116,5 +119,39 @@ final class authorizations extends core implements record_interface
// Exit (success) // Exit (success)
return $$created ? $$record->identifier : false; 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->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;
// 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->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;
// Exit (success)
return $$this;
}
} }

View File

@@ -5,10 +5,7 @@ declare(strict_types=1);
namespace ${REPO_OWNER}\${REPO_NAME}\models; namespace ${REPO_OWNER}\${REPO_NAME}\models;
// Files of the project // Files of the project
use ${REPO_OWNER}\${REPO_NAME}\models\core, use ${REPO_OWNER}\${REPO_NAME}\models\core;
${REPO_OWNER}\${REPO_NAME}\models\tariff,
${REPO_OWNER}\${REPO_NAME}\models\enumerations\tariff as tariff_type,
${REPO_OWNER}\${REPO_NAME}\models\enumerations\acquiring as acquiring;
// Baza database // Baza database
use mirzaev\baza\database, use mirzaev\baza\database,
@@ -70,6 +67,7 @@ final class settings extends core implements record_interface
new column('identifier', type::long_long_unsigned), new column('identifier', type::long_long_unsigned),
new column('account', type::long_long_unsigned), new column('account', type::long_long_unsigned),
/* new column('', type::), */ /* new column('', type::), */
new column('active', type::char),
new column('updated', type::integer_unsigned), new column('updated', type::integer_unsigned),
new column('created', type::integer_unsigned) new column('created', type::integer_unsigned)
) )
@@ -82,16 +80,19 @@ final class settings extends core implements record_interface
/** /**
* Write * Write
* *
* @param int $$account The account identifier (0 for disable) * @param int $$account The account identifier
* @param int $$active Is the record active?
* *
* @return int|false The record identifier, if created * @return int|false The record identifier, if created
*/ */
public function write( public function write(
int $$account = 0, int $$account,
bool $$active = true,
): int|false { ): int|false {
$$record = $$this->database->record( $$record = $$this->database->record(
$$this->database->count() + 1, $$this->database->count() + 1,
$$account, $$account,
(int) $$active,
svoboda::timestamp(), svoboda::timestamp(),
svoboda::timestamp() svoboda::timestamp()
); );
@@ -102,5 +103,33 @@ final class settings extends core implements record_interface
// Exit (success) // Exit (success)
return $$created ? $$record->identifier : false; 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;
}
} }

View File

@@ -8,7 +8,6 @@ namespace ${REPO_OWNER}\${REPO_NAME}\models\telegram;
use ${REPO_OWNER}\${REPO_NAME}\models\core, use ${REPO_OWNER}\${REPO_NAME}\models\core,
${REPO_OWNER}\${REPO_NAME}\models\account, ${REPO_OWNER}\${REPO_NAME}\models\account,
${REPO_OWNER}\${REPO_NAME}\models\settings, ${REPO_OWNER}\${REPO_NAME}\models\settings,
${REPO_OWNER}\${REPO_NAME}\models\telegram\settings as telegram_settings,
${REPO_OWNER}\${REPO_NAME}\models\telegram\processes\language\select as process_language_select; ${REPO_OWNER}\${REPO_NAME}\models\telegram\processes\language\select as process_language_select;
// Library for languages support // Library for languages support
@@ -77,47 +76,11 @@ final class commands extends core
// Initializing the title // Initializing the title
$$title = '📋 *' . $$localization['menu_title'] . '*'; $$title = '📋 *' . $$localization['menu_title'] . '*';
// Initializing accounts
/* $$accounts_message = '*' . $$localization['menu_accounts'] . ':* ' . ((new account)->database->count() ?? 0); */
// Initializing the account tariff
$$tariff = $$account->tariff();
// Declaring the tariff button
$$tariff_button = [];
if ($$tariff instanceof tariff) {
// Initialized the account tariff
// Initializing the tariff button
$$tariff_button = [
'text' => '🔐 ' . $$tariff->type->label($$language) . ' (' . $$tariff->used . '/' . $$tariff->tokens . ')',
'callback_data' => 'tariffs'
];
} else {
// Initialized the account tariff
// Initializing the tariff button
$$tariff_button = [
'text' => '⚠️ ' . $$localization['menu_tariff_empty'],
'callback_data' => 'tariffs'
];
}
// Initializing the account chat
$$chat = $$account->chat();
// Initializing the chto text
$$howto = $$localization['menu_howto'];
// Sending the message // Sending the message
$$context->sendMessage( $$context->sendMessage(
<<<TXT <<<TXT
$$title $$title
$$howto
TXT, TXT,
[ [
'reply_markup' => [ 'reply_markup' => [

View File

@@ -8,15 +8,7 @@ namespace ${REPO_OWNER}\${REPO_NAME};
use ${REPO_OWNER}\${REPO_NAME}\models\account, use ${REPO_OWNER}\${REPO_NAME}\models\account,
${REPO_OWNER}\${REPO_NAME}\models\telegram\middlewares, ${REPO_OWNER}\${REPO_NAME}\models\telegram\middlewares,
${REPO_OWNER}\${REPO_NAME}\models\telegram\commands, ${REPO_OWNER}\${REPO_NAME}\models\telegram\commands,
${REPO_OWNER}\${REPO_NAME}\models\telegram\buttons, ${REPO_OWNER}\${REPO_NAME}\models\telegram\settings;
${REPO_OWNER}\${REPO_NAME}\models\telegram\chat,
${REPO_OWNER}\${REPO_NAME}\models\telegram\account as telegram_account,
${REPO_OWNER}\${REPO_NAME}\models\telegram\settings,
${REPO_OWNER}\${REPO_NAME}\models\telegram\network,
${REPO_OWNER}\${REPO_NAME}\models\telegram\tariff,
${REPO_OWNER}\${REPO_NAME}\models\acquirings\yookassa,
${REPO_OWNER}\${REPO_NAME}\models\enumerations\tariff as tariff_type,
${REPO_OWNER}\${REPO_NAME}\models\telegram\processes\settings\chat\memory\messages as processes_settings_chat_memory_messages;
// Library for languages support // Library for languages support
use mirzaev\languages\language; use mirzaev\languages\language;
@@ -81,7 +73,6 @@ $$robot->middleware([middlewares::class, 'account']);
$$robot->middleware([middlewares::class, 'language']); $$robot->middleware([middlewares::class, 'language']);
$$robot->middleware([middlewares::class, 'localization']); $$robot->middleware([middlewares::class, 'localization']);
$$robot->middleware([middlewares::class, 'authorizations']); $$robot->middleware([middlewares::class, 'authorizations']);
$$robot->middleware([middlewares::class, 'welcome']);
// Initializing the robot commands handlers // Initializing the robot commands handlers
$$robot->onCommand('start', [commands::class, 'start']); $$robot->onCommand('start', [commands::class, 'start']);

View File

@@ -9,5 +9,7 @@ require ROOT . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
define('PROJECT_NAME', ''); define('PROJECT_NAME', '');
define('PROJECT_DOMAIN', ''); define('PROJECT_DOMAIN', '');
defing('LANGUAGE_DEFAULT', language::en);
// Initializing default theme for the views templater // Initializing default theme for the views templater
define('THEME', 'default'); define('THEME', 'default');

View File

@@ -33,7 +33,8 @@
"badfarm/zanzara": "^0.9.1", "badfarm/zanzara": "^0.9.1",
"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"
}, },
"suggest": { "suggest": {
"mirzaev/files": "Easy working with files", "mirzaev/files": "Easy working with files",