forked from mirzaev/pot-php
fixed by garden/campanula
This commit is contained in:
@@ -7,11 +7,7 @@ namespace ${REPO_OWNER}\${REPO_NAME}\models;
|
||||
// Files of the project
|
||||
use ${REPO_OWNER}\${REPO_NAME}\models\core,
|
||||
${REPO_OWNER}\${REPO_NAME}\models\authorizations,
|
||||
${REPO_OWNER}\${REPO_NAME}\models\chat,
|
||||
${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;
|
||||
${REPO_OWNER}\${REPO_NAME}\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;
|
||||
|
||||
@@ -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,28 @@ 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,
|
||||
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 +119,39 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,10 +5,7 @@ declare(strict_types=1);
|
||||
namespace ${REPO_OWNER}\${REPO_NAME}\models;
|
||||
|
||||
// Files of the project
|
||||
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;
|
||||
use ${REPO_OWNER}\${REPO_NAME}\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,33 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ namespace ${REPO_OWNER}\${REPO_NAME}\models\telegram;
|
||||
use ${REPO_OWNER}\${REPO_NAME}\models\core,
|
||||
${REPO_OWNER}\${REPO_NAME}\models\account,
|
||||
${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;
|
||||
|
||||
// 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' => [
|
||||
|
||||
@@ -8,15 +8,7 @@ namespace ${REPO_OWNER}\${REPO_NAME};
|
||||
use ${REPO_OWNER}\${REPO_NAME}\models\account,
|
||||
${REPO_OWNER}\${REPO_NAME}\models\telegram\middlewares,
|
||||
${REPO_OWNER}\${REPO_NAME}\models\telegram\commands,
|
||||
${REPO_OWNER}\${REPO_NAME}\models\telegram\buttons,
|
||||
${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;
|
||||
${REPO_OWNER}\${REPO_NAME}\models\telegram\settings;
|
||||
|
||||
// Library for languages support
|
||||
use mirzaev\languages\language;
|
||||
@@ -81,7 +73,6 @@ $$robot->middleware([middlewares::class, 'account']);
|
||||
$$robot->middleware([middlewares::class, 'language']);
|
||||
$$robot->middleware([middlewares::class, 'localization']);
|
||||
$$robot->middleware([middlewares::class, 'authorizations']);
|
||||
$$robot->middleware([middlewares::class, 'welcome']);
|
||||
|
||||
// Initializing the robot commands handlers
|
||||
$$robot->onCommand('start', [commands::class, 'start']);
|
||||
|
||||
@@ -9,5 +9,7 @@ require ROOT . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
|
||||
define('PROJECT_NAME', '');
|
||||
define('PROJECT_DOMAIN', '');
|
||||
|
||||
defing('LANGUAGE_DEFAULT', language::en);
|
||||
|
||||
// Initializing default theme for the views templater
|
||||
define('THEME', 'default');
|
||||
|
||||
@@ -33,7 +33,8 @@
|
||||
"badfarm/zanzara": "^0.9.1",
|
||||
"twig/twig": "^3.2",
|
||||
"twig/extra-bundle": "^3.7",
|
||||
"twig/intl-extra": "^3.10"
|
||||
"twig/intl-extra": "^3.10",
|
||||
"react/filesystem": "^0.1.2"
|
||||
},
|
||||
"suggest": {
|
||||
"mirzaev/files": "Easy working with files",
|
||||
|
||||
Reference in New Issue
Block a user