This commit is contained in:
2026-01-07 14:56:30 +05:00
parent 680a9659e3
commit 3d4e1a9cd2
148 changed files with 5784 additions and 95 deletions

View File

@@ -33,7 +33,9 @@
"badfarm/zanzara": "^0.9.1",
"twig/twig": "^3.2",
"twig/extra-bundle": "^3.7",
"twig/intl-extra": "^3.10"
"twig/intl-extra": "^3.10",
"nyholm/psr7": "^1.8",
"react/filesystem": "^0.1.2"
},
"suggest": {
"mirzaev/files": "Easy working with files",
@@ -52,5 +54,11 @@
},
"scripts": {
"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

File diff suppressed because it is too large Load Diff

View File

@@ -7,11 +7,7 @@ namespace garden\campanula\models;
// Files of the project
use garden\campanula\models\core,
garden\campanula\models\authorizations,
garden\campanula\models\chat,
garden\campanula\models\settings,
garden\campanula\models\tariff,
garden\campanula\models\code,
garden\campanula\models\enumerations\tariff as tariff_type;
garden\campanula\models\settings;
// The library for languages support
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('robot', type::char),
/* new column('', type::), */
new column('active', type::char),
new column('updated', type::integer_unsigned),
new column('created', type::integer_unsigned)
)
@@ -115,8 +112,7 @@ final class account extends core implements record_interface
if (
$account->domain !== (string) $telegram->getUsername() ||
$account->name_first !== (string) $telegram->getFirstName() ||
$account->name_second !== (string) $telegram->getLastName() ||
$account->language !== (string) $telegram->getLanguageCode()
$account->name_second !== (string) $telegram->getLastName()
) {
// The telegram account was updated
@@ -128,7 +124,6 @@ final class account extends core implements record_interface
$record->domain = (string) $telegram->getUsername();
$record->name_first = (string) $telegram->getFirstName();
$record->name_second = (string) $telegram->getLastName();
$record->language = (string) $telegram->getLanguageCode();
$record->updated = svoboda::timestamp();
},
amount: 1
@@ -211,7 +206,7 @@ final class account extends core implements record_interface
$record = $this->write(
telegram_identifier: (int) $telegram->getId(),
name_first: (string) $telegram->getFirstName(),
name_last: (string) $telegram->getLastName(),
name_second: (string) $telegram->getLastName(),
domain: (string) $telegram->getUsername(),
language: (string) $telegram->getLanguageCode(),
robot: (bool) $telegram->isBot()
@@ -232,18 +227,6 @@ final class account extends core implements record_interface
// Creating the account settings
$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
$record = $this->database->read(
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 string $name_first
* @param string $name_last
* @param string $name_second
* @param string $domain
* @param language|string $language
* @param bool $robot Is a robot?
* @param bool $active Is the record active?
*
* @return record|false The record, if created
*/
@@ -275,9 +259,10 @@ final class account extends core implements record_interface
int $telegram_identifier,
string $domain = '',
string $name_first = '',
string $name_last = '',
string $name_second = '',
language|string $language = LANGUAGE_DEFAULT ?? language::en,
bool $robot = false,
bool $active = true,
): record|false {
// Initializing the record
$record = $this->database->record(
@@ -285,10 +270,11 @@ final class account extends core implements record_interface
(int) $telegram_identifier,
$domain,
$name_first,
$name_last,
$name_second,
$language instanceof language ? $language->name : (string) $language,
(int) $robot,
/* */
(int) $active,
svoboda::timestamp(),
svoboda::timestamp()
);
@@ -309,6 +295,8 @@ final class account extends core implements record_interface
{
// Serializing the record parameters
$this->record->language = $this->record->language->name;
$this->record->robot = (int) $this->record->robot;
$this->record->active = (int) $this->record->active;
// Exit (success)
return $this;
@@ -323,6 +311,8 @@ final class account extends core implements record_interface
{
// Deserializing the record parameters
$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)
return $this;
@@ -360,7 +350,7 @@ final class account extends core implements record_interface
*/
public function settings(): ?settings
{
// Search for the account settings
// Search for the account settings
$settings = new settings()->read(filter: fn(record $record) => $record->active === 1 && $record->account === $this->identifier);
if ($settings instanceof settings) {
@@ -374,4 +364,3 @@ final class account extends core implements record_interface
return null;
}
}

View File

@@ -71,9 +71,9 @@ final class authorizations extends core implements record_interface
new column('account', type::long_long_unsigned),
new column('system', type::char),
new column('settings', type::char),
new column('chat', type::char),
/* new column('', type::char), */
new column('system_settings', type::char),
new column('active', type::char),
new column('updated', type::integer_unsigned),
new column('created', type::integer_unsigned)
)
@@ -87,25 +87,27 @@ final class authorizations extends core implements record_interface
* Write
*
* @param int $account The account identifier
* @param int $system
* @param int $settings
* @param int $system_settings
* @param bool $system
* @param bool $settings
* @param bool $system_settings
* @param bool $active Is the record active?
*
* @return int|false The record identifier, if created
*/
public function write(
int $account,
int $system = 1,
int $settings = 1,
int $system_settings = 0,
): int|false
{
bool $system = true,
bool $settings = true,
bool $system_settings = false,
bool $active = true,
): int|false {
$record = $this->database->record(
$this->database->count() + 1,
$account,
$system,
$settings,
$system_settings,
(int) $system,
(int) $settings,
(int) $system_settings,
(int) $active,
svoboda::timestamp(),
svoboda::timestamp()
);
@@ -116,5 +118,38 @@ final class authorizations extends core implements record_interface
// 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->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 garden\campanula\models;
// Files of the project
use garden\campanula\models\core,
garden\campanula\models\tariff,
garden\campanula\models\enumerations\tariff as tariff_type,
garden\campanula\models\enumerations\acquiring as acquiring;
use garden\campanula\models\core;
// 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('account', type::long_long_unsigned),
/* new column('', type::), */
new column('active', type::char),
new column('updated', type::integer_unsigned),
new column('created', type::integer_unsigned)
)
@@ -82,16 +80,19 @@ final class settings extends core implements record_interface
/**
* 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
*/
public function write(
int $account = 0,
int $account,
bool $active = true,
): int|false {
$record = $this->database->record(
$this->database->count() + 1,
$account,
(int) $active,
svoboda::timestamp(),
svoboda::timestamp()
);
@@ -102,5 +103,32 @@ final class settings extends core implements record_interface
// 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;
}
}

View File

@@ -8,7 +8,6 @@ namespace garden\campanula\models\telegram;
use garden\campanula\models\core,
garden\campanula\models\account,
garden\campanula\models\settings,
garden\campanula\models\telegram\settings as telegram_settings,
garden\campanula\models\telegram\processes\language\select as process_language_select;
// Library for languages support
@@ -77,47 +76,11 @@ final class commands extends core
// Initializing the 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
$context->sendMessage(
<<<TXT
$title
$howto
TXT,
[
'reply_markup' => [

Some files were not shown because too many files have changed in this diff Show More