forked from mirzaev/deeproots_bot
Fix ID integer length error & change those pesky tabulations
This commit is contained in:
parent
ced4e3241c
commit
49f7601376
|
@ -6,24 +6,24 @@ namespace mirzaev\deeproots\models;
|
||||||
|
|
||||||
// Files of the project
|
// Files of the project
|
||||||
use mirzaev\deeproots\models\core,
|
use mirzaev\deeproots\models\core,
|
||||||
mirzaev\deeproots\models\connection,
|
mirzaev\deeproots\models\connection,
|
||||||
mirzaev\deeproots\models\telegram,
|
mirzaev\deeproots\models\telegram,
|
||||||
mirzaev\deeproots\models\enumerations\language,
|
mirzaev\deeproots\models\enumerations\language,
|
||||||
mirzaev\deeproots\models\account\localization;
|
mirzaev\deeproots\models\account\localization;
|
||||||
|
|
||||||
// Svoboda time
|
// Svoboda time
|
||||||
use svoboda\time\statement as svoboda;
|
use svoboda\time\statement as svoboda;
|
||||||
|
|
||||||
// Baza database
|
// Baza database
|
||||||
use mirzaev\baza\database,
|
use mirzaev\baza\database,
|
||||||
mirzaev\baza\column,
|
mirzaev\baza\column,
|
||||||
mirzaev\baza\record,
|
mirzaev\baza\record,
|
||||||
mirzaev\baza\enumerations\encoding,
|
mirzaev\baza\enumerations\encoding,
|
||||||
mirzaev\baza\enumerations\type;
|
mirzaev\baza\enumerations\type;
|
||||||
|
|
||||||
// Built-in libraries
|
// Built-in libraries
|
||||||
use Exception as exception,
|
use Exception as exception,
|
||||||
RuntimeException as exception_runtime;
|
RuntimeException as exception_runtime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Account
|
* Account
|
||||||
|
@ -35,190 +35,190 @@ use Exception as exception,
|
||||||
*/
|
*/
|
||||||
final class account extends core
|
final class account extends core
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* File
|
* File
|
||||||
*
|
*
|
||||||
* @var string $database Path to the database file
|
* @var string $database Path to the database file
|
||||||
*/
|
*/
|
||||||
protected string $file = DATABASES . DIRECTORY_SEPARATOR . 'accounts.baza';
|
protected string $file = DATABASES . DIRECTORY_SEPARATOR . 'accounts.baza';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Database
|
* Database
|
||||||
*
|
*
|
||||||
* @var database $database The database
|
* @var database $database The database
|
||||||
*/
|
*/
|
||||||
public protected(set) database $database;
|
public protected(set) database $database;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
// Initializing the database
|
// Initializing the database
|
||||||
$this->database = new database()
|
$this->database = new database()
|
||||||
->encoding(encoding::utf8)
|
->encoding(encoding::utf8)
|
||||||
->columns(
|
->columns(
|
||||||
new column('identifier', type::integer_unsigned),
|
new column('identifier', type::long_long_unsigned),
|
||||||
new column('name', type::string, ['length' => 64]),
|
new column('name', type::string, ['length' => 64]),
|
||||||
new column('language', type::string, ['length' => 2]),
|
new column('language', type::string, ['length' => 2]),
|
||||||
new column('authorized_system', type::char),
|
new column('authorized_system', type::char),
|
||||||
new column('authorized_game_play', type::char),
|
new column('authorized_game_play', type::char),
|
||||||
new column('authorized_rating_display', type::char),
|
new column('authorized_rating_display', type::char),
|
||||||
new column('authorized_balance_deposit', type::char),
|
new column('authorized_balance_deposit', type::char),
|
||||||
new column('authorized_balance_withdraw', type::char),
|
new column('authorized_balance_withdraw', type::char),
|
||||||
new column('authorized_settings', type::char),
|
new column('authorized_settings', type::char),
|
||||||
new column('authorized_system_accounts', type::char),
|
new column('authorized_system_accounts', type::char),
|
||||||
new column('authorized_system_questions', type::char),
|
new column('authorized_system_questions', type::char),
|
||||||
new column('authorized_system_settings', type::char),
|
new column('authorized_system_settings', 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)
|
||||||
)
|
)
|
||||||
->connect($this->file);
|
->connect($this->file);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize
|
* Initialize
|
||||||
*
|
*
|
||||||
* Searches for the account record by the telegram account in the database,
|
* Searches for the account record by the telegram account in the database,
|
||||||
* and if it does not find it, then create the account record and the connection record
|
* and if it does not find it, then create the account record and the connection record
|
||||||
*
|
*
|
||||||
* @param record $telegram The telegram account
|
* @param record $telegram The telegram account
|
||||||
*
|
*
|
||||||
* @throws exception_runtime if failed to deactivate the connection between missing account and the telegram account
|
* @throws exception_runtime if failed to deactivate the connection between missing account and the telegram account
|
||||||
* @throws exception_runtime if failed to connect the account with the telegram account
|
* @throws exception_runtime if failed to connect the account with the telegram account
|
||||||
* @throws exception_runtime if failed to find the created account
|
* @throws exception_runtime if failed to find the created account
|
||||||
* @throws exception_runtime if failed to create the account
|
* @throws exception_runtime if failed to create the account
|
||||||
*
|
*
|
||||||
* @return record The account record from the database
|
* @return record The account record from the database
|
||||||
*/
|
*/
|
||||||
public function initialize(record $telegram): record
|
public function initialize(record $telegram): record
|
||||||
{
|
{
|
||||||
// Initializing the connection model
|
// Initializing the connection model
|
||||||
$connection = new connection;
|
$connection = new connection;
|
||||||
|
|
||||||
// Searching for the connection record between theaccount and the telegram account in the database
|
// Searching for the connection record between theaccount and the telegram account in the database
|
||||||
$connected = $connection->database->read(filter: fn(record $record) => $record->telegram === $telegram->identifier, amount: 1)[0] ?? null;
|
$connected = $connection->database->read(filter: fn(record $record) => $record->telegram === $telegram->identifier, amount: 1)[0] ?? null;
|
||||||
|
|
||||||
if ($connected instanceof record) {
|
if ($connected instanceof record) {
|
||||||
// Found the connection record between the account and the telegram account
|
// Found the connection record between the account and the telegram account
|
||||||
|
|
||||||
// Searching for the account in the database
|
// Searching for the account in the database
|
||||||
$account = $this->database->read(filter: fn(record $record) => $record->identifier === $connected->account, amount: 1)[0] ?? null;
|
$account = $this->database->read(filter: fn(record $record) => $record->identifier === $connected->account, amount: 1)[0] ?? null;
|
||||||
|
|
||||||
if ($account instanceof record) {
|
if ($account instanceof record) {
|
||||||
// Found the account
|
// Found the account
|
||||||
|
|
||||||
// Exit (success)
|
// Exit (success)
|
||||||
return $account;
|
return $account;
|
||||||
} else {
|
} else {
|
||||||
// Not found the account
|
// Not found the account
|
||||||
|
|
||||||
// Deactivating the connection between missing account and the telegram account
|
// Deactivating the connection between missing account and the telegram account
|
||||||
$deactivated = $connected->read(
|
$deactivated = $connected->read(
|
||||||
filter: fn(record $record) => $record->identifier === $connected->identifier,
|
filter: fn(record $record) => $record->identifier === $connected->identifier,
|
||||||
update: function (record &$record) {
|
update: function (record &$record) {
|
||||||
$record->active = 0;
|
$record->active = 0;
|
||||||
$record->updated = svoboda::timestamp();
|
$record->updated = svoboda::timestamp();
|
||||||
},
|
},
|
||||||
amount: 1)[0] ?? null;
|
amount: 1)[0] ?? null;
|
||||||
|
|
||||||
if ($deactivated instanceof record && $deactivated->active === 0) {
|
if ($deactivated instanceof record && $deactivated->active === 0) {
|
||||||
// Deactivated the connection between missing account and the telegram account
|
// Deactivated the connection between missing account and the telegram account
|
||||||
|
|
||||||
// Creating the account
|
|
||||||
goto create;
|
|
||||||
} else {
|
|
||||||
// Failed to deactivate the connection between missing account and the telegram account
|
|
||||||
|
|
||||||
// Exit (fail)
|
// Creating the account
|
||||||
throw new exception_runtime('Failed to deactivate the connection between missing account and the telegram account');
|
goto create;
|
||||||
}
|
} else {
|
||||||
}
|
// Failed to deactivate the connection between missing account and the telegram account
|
||||||
} else {
|
|
||||||
// Not found the connection record between the account and the telegram account
|
|
||||||
|
|
||||||
// Creating the account process start
|
// Exit (fail)
|
||||||
create:
|
throw new exception_runtime('Failed to deactivate the connection between missing account and the telegram account');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Not found the connection record between the account and the telegram account
|
||||||
|
|
||||||
// Creating the account
|
// Creating the account process start
|
||||||
$identifier = $this->create("$telegram->name_first $telegram->name_second", language::{$telegram->language ?? language::en->name} ?? language::en);
|
create:
|
||||||
|
|
||||||
if ($identifier) {
|
// Creating the account
|
||||||
// Created the account
|
$identifier = $this->create("$telegram->name_first $telegram->name_second", language::{$telegram->language ?? language::en->name} ?? language::en);
|
||||||
|
|
||||||
// Searching for the created account in the database
|
if ($identifier) {
|
||||||
$account = $this->database->read(filter: fn(record $record) => $record->identifier === $identifier, amount: 1)[0] ?? null;
|
// Created the account
|
||||||
|
|
||||||
if ($account instanceof record) {
|
// Searching for the created account in the database
|
||||||
// Found the created account
|
$account = $this->database->read(filter: fn(record $record) => $record->identifier === $identifier, amount: 1)[0] ?? null;
|
||||||
|
|
||||||
// Connecting the created account with the telegram account
|
if ($account instanceof record) {
|
||||||
$connected = $connection->create(account: $account->identifier, telegram: $telegram->identifier);
|
// Found the created account
|
||||||
|
|
||||||
if ($connected) {
|
// Connecting the created account with the telegram account
|
||||||
// Connected the created account with the telegram account
|
$connected = $connection->create(account: $account->identifier, telegram: $telegram->identifier);
|
||||||
|
|
||||||
// Exit (success)
|
if ($connected) {
|
||||||
return $account;
|
// Connected the created account with the telegram account
|
||||||
} else {
|
|
||||||
// Not connected the created account with the telegram account
|
|
||||||
|
|
||||||
// Exit (fail)
|
// Exit (success)
|
||||||
throw new exception_runtime('Failed to connect the account with the telegram account');
|
return $account;
|
||||||
}
|
} else {
|
||||||
} else {
|
// Not connected the created account with the telegram account
|
||||||
// Not found the created account
|
|
||||||
|
|
||||||
// Exit (fail)
|
// Exit (fail)
|
||||||
throw new exception_runtime('Failed to find the created account');
|
throw new exception_runtime('Failed to connect the account with the telegram account');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Not created the account
|
// Not found the created account
|
||||||
|
|
||||||
// Exit (fail)
|
// Exit (fail)
|
||||||
throw new exception_runtime('Failed to create the account');
|
throw new exception_runtime('Failed to find the created account');
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
}
|
// Not created the account
|
||||||
|
|
||||||
/**
|
// Exit (fail)
|
||||||
* Create
|
throw new exception_runtime('Failed to create the account');
|
||||||
*
|
}
|
||||||
* Creates the account record in the database
|
}
|
||||||
*
|
}
|
||||||
* @param telegram $telegram The telegram account
|
|
||||||
*
|
|
||||||
* @return int|false The record identifier, if created
|
|
||||||
*/
|
|
||||||
public function create(string $name, language $language): int|false
|
|
||||||
{
|
|
||||||
// Initializing the identifier
|
|
||||||
$identifier = $this->database->count() + 1;
|
|
||||||
|
|
||||||
// Initializing the record
|
/**
|
||||||
$record = $this->database->record(
|
* Create
|
||||||
$identifier,
|
*
|
||||||
$name,
|
* Creates the account record in the database
|
||||||
$language->name,
|
*
|
||||||
ACCOUNT_ACCESS_SYSTEM,
|
* @param telegram $telegram The telegram account
|
||||||
ACCOUNT_ACCESS_GAME_PLAY,
|
*
|
||||||
ACCOUNT_ACCESS_RATING_DISPLAY,
|
* @return int|false The record identifier, if created
|
||||||
ACCOUNT_ACCESS_BALANCE_DEPOSIT,
|
*/
|
||||||
ACCOUNT_ACCESS_BALANCE_WITHDRAW,
|
public function create(string $name, language $language): int|false
|
||||||
ACCOUNT_ACCESS_SETTINGS,
|
{
|
||||||
ACCOUNT_ACCESS_SYSTEM_ACCOUNTS,
|
// Initializing the identifier
|
||||||
ACCOUNT_ACCESS_SYSTEM_QUESTIONS,
|
$identifier = $this->database->count() + 1;
|
||||||
ACCOUNT_ACCESS_SYSTEM_SETTINGS,
|
|
||||||
svoboda::timestamp(),
|
|
||||||
svoboda::timestamp()
|
|
||||||
);
|
|
||||||
|
|
||||||
// Creating the record in the database
|
// Initializing the record
|
||||||
$created = $this->database->write($record);
|
$record = $this->database->record(
|
||||||
|
$identifier,
|
||||||
|
$name,
|
||||||
|
$language->name,
|
||||||
|
ACCOUNT_ACCESS_SYSTEM,
|
||||||
|
ACCOUNT_ACCESS_GAME_PLAY,
|
||||||
|
ACCOUNT_ACCESS_RATING_DISPLAY,
|
||||||
|
ACCOUNT_ACCESS_BALANCE_DEPOSIT,
|
||||||
|
ACCOUNT_ACCESS_BALANCE_WITHDRAW,
|
||||||
|
ACCOUNT_ACCESS_SETTINGS,
|
||||||
|
ACCOUNT_ACCESS_SYSTEM_ACCOUNTS,
|
||||||
|
ACCOUNT_ACCESS_SYSTEM_QUESTIONS,
|
||||||
|
ACCOUNT_ACCESS_SYSTEM_SETTINGS,
|
||||||
|
svoboda::timestamp(),
|
||||||
|
svoboda::timestamp()
|
||||||
|
);
|
||||||
|
|
||||||
// Exit (success)
|
// Creating the record in the database
|
||||||
return $created ? $identifier : false;
|
$created = $this->database->write($record);
|
||||||
}
|
|
||||||
|
// Exit (success)
|
||||||
|
return $created ? $identifier : false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,7 @@ final class answer extends core
|
||||||
$this->database = new database()
|
$this->database = new database()
|
||||||
->encoding(encoding::ascii)
|
->encoding(encoding::ascii)
|
||||||
->columns(
|
->columns(
|
||||||
new column('identifier', type::integer_unsigned),
|
new column('identifier', type::long_long_unsigned),
|
||||||
new column('A', type::char),
|
new column('A', type::char),
|
||||||
new column('B', type::char),
|
new column('B', type::char),
|
||||||
new column('C', type::char),
|
new column('C', type::char),
|
||||||
|
|
|
@ -12,17 +12,17 @@ use svoboda\time\statement as svoboda;
|
||||||
|
|
||||||
// Baza database
|
// Baza database
|
||||||
use mirzaev\baza\database,
|
use mirzaev\baza\database,
|
||||||
mirzaev\baza\column,
|
mirzaev\baza\column,
|
||||||
mirzaev\baza\record,
|
mirzaev\baza\record,
|
||||||
mirzaev\baza\enumerations\encoding,
|
mirzaev\baza\enumerations\encoding,
|
||||||
mirzaev\baza\enumerations\type;
|
mirzaev\baza\enumerations\type;
|
||||||
|
|
||||||
// Framework for Telegram
|
// Framework for Telegram
|
||||||
use Zanzara\Telegram\Type\User as telegram;
|
use Zanzara\Telegram\Type\User as telegram;
|
||||||
|
|
||||||
// Built-in libraries
|
// Built-in libraries
|
||||||
use Exception as exception,
|
use Exception as exception,
|
||||||
RuntimeException as exception_runtime;
|
RuntimeException as exception_runtime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Connection between account::class and telegram::class
|
* Connection between account::class and telegram::class
|
||||||
|
@ -34,77 +34,77 @@ use Exception as exception,
|
||||||
*/
|
*/
|
||||||
final class connection extends core
|
final class connection extends core
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* File
|
* File
|
||||||
*
|
*
|
||||||
* @var string $database Path to the database file
|
* @var string $database Path to the database file
|
||||||
*/
|
*/
|
||||||
protected string $file = DATABASES . DIRECTORY_SEPARATOR . 'connection.baza';
|
protected string $file = DATABASES . DIRECTORY_SEPARATOR . 'connection.baza';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Database
|
* Database
|
||||||
*
|
*
|
||||||
* Identifier: The record identifier
|
* Identifier: The record identifier
|
||||||
* Account: The account identifier
|
* Account: The account identifier
|
||||||
* Telegram: The telegram account identifier
|
* Telegram: The telegram account identifier
|
||||||
* Updated: Timestamp of the last the record update
|
* Updated: Timestamp of the last the record update
|
||||||
* Created: Timestamp of the record creating
|
* Created: Timestamp of the record creating
|
||||||
*
|
*
|
||||||
* @var database $database The database
|
* @var database $database The database
|
||||||
*/
|
*/
|
||||||
public protected(set) database $database;
|
public protected(set) database $database;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
// Initializing the database
|
// Initializing the database
|
||||||
$this->database = new database()
|
$this->database = new database()
|
||||||
->encoding(encoding::ascii)
|
->encoding(encoding::ascii)
|
||||||
->columns(
|
->columns(
|
||||||
new column('identifier', type::integer_unsigned),
|
new column('identifier', type::integer_unsigned),
|
||||||
new column('account', type::integer_unsigned),
|
new column('account', type::integer_unsigned),
|
||||||
new column('telegram', type::integer_unsigned),
|
new column('telegram', type::long_long_unsigned),
|
||||||
new column('active', 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)
|
||||||
)
|
)
|
||||||
->connect($this->file);
|
->connect($this->file);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create
|
* Create
|
||||||
*
|
*
|
||||||
* Creates the record in the database
|
* Creates the record in the database
|
||||||
*
|
*
|
||||||
* @param int $account Identifier of the account
|
* @param int $account Identifier of the account
|
||||||
* @param int $telegram Identifier of the telegram account
|
* @param int $telegram Identifier of the telegram account
|
||||||
* @param bool $active Is the connection active?
|
* @param bool $active Is the connection active?
|
||||||
*
|
*
|
||||||
* @return int|false The record identifier, if created
|
* @return int|false The record identifier, if created
|
||||||
*/
|
*/
|
||||||
public function create(int $account, int $telegram, bool $active = true): int|false
|
public function create(int $account, int $telegram, bool $active = true): int|false
|
||||||
{
|
{
|
||||||
// Initializing the identifier
|
// Initializing the identifier
|
||||||
$identifier = $this->database->count() + 1;
|
$identifier = $this->database->count() + 1;
|
||||||
|
|
||||||
// Initializing the record
|
// Initializing the record
|
||||||
$record = $this->database->record(
|
$record = $this->database->record(
|
||||||
$identifier,
|
$identifier,
|
||||||
$account,
|
$account,
|
||||||
$telegram,
|
$telegram,
|
||||||
(int) $active,
|
(int) $active,
|
||||||
svoboda::timestamp(),
|
svoboda::timestamp(),
|
||||||
svoboda::timestamp()
|
svoboda::timestamp()
|
||||||
);
|
);
|
||||||
|
|
||||||
// Creating the record in the database
|
// Creating the record in the database
|
||||||
$created = $this->database->write($record);
|
$created = $this->database->write($record);
|
||||||
|
|
||||||
// Exit (success)
|
// Exit (success)
|
||||||
return $created ? $identifier : false;
|
return $created ? $identifier : false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,55 +16,55 @@ namespace mirzaev\deeproots\models\enumerations;
|
||||||
*/
|
*/
|
||||||
enum language
|
enum language
|
||||||
{
|
{
|
||||||
case en;
|
case en;
|
||||||
case ru;
|
case ru;
|
||||||
case in;
|
case in;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Label
|
* Label
|
||||||
*
|
*
|
||||||
* Initialize label of the language
|
* Initialize label of the language
|
||||||
*
|
*
|
||||||
* @param language|null language Language into which to translate
|
* @param language|null language Language into which to translate
|
||||||
*
|
*
|
||||||
* @return string Translated label of the language
|
* @return string Translated label of the language
|
||||||
*/
|
*/
|
||||||
public function label(?language $language = language::en): string
|
public function label(?language $language = language::en): string
|
||||||
{
|
{
|
||||||
// Exit (success)
|
// Exit (success)
|
||||||
return match ($this) {
|
return match ($this) {
|
||||||
language::en => match ($language) {
|
language::en => match ($language) {
|
||||||
language::en => 'English',
|
language::en => 'English',
|
||||||
language::ru => 'Английский',
|
language::ru => 'Английский',
|
||||||
language::in => 'अंग्रेज़ी',
|
language::in => 'अंग्रेज़ी',
|
||||||
},
|
},
|
||||||
language::ru => match ($language) {
|
language::ru => match ($language) {
|
||||||
language::en => 'Russian',
|
language::en => 'Russian',
|
||||||
language::ru => 'Русский',
|
language::ru => 'Русский',
|
||||||
language::in => 'रूसी',
|
language::in => 'रूसी',
|
||||||
},
|
},
|
||||||
language::in => match ($language) {
|
language::in => match ($language) {
|
||||||
language::en => 'Hindi',
|
language::en => 'Hindi',
|
||||||
language::ru => 'Хинди',
|
language::ru => 'Хинди',
|
||||||
language::in => 'हिन्दी',
|
language::in => 'हिन्दी',
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flag
|
* Flag
|
||||||
*
|
*
|
||||||
* Initialize the flag emoji of the language
|
* Initialize the flag emoji of the language
|
||||||
*
|
*
|
||||||
* @return string The flag emoji of the language
|
* @return string The flag emoji of the language
|
||||||
*/
|
*/
|
||||||
public function flag(): string
|
public function flag(): string
|
||||||
{
|
{
|
||||||
// Exit (success)
|
// Exit (success)
|
||||||
return match ($this) {
|
return match ($this) {
|
||||||
language::en => '🇺🇸',
|
language::en => '🇺🇸',
|
||||||
language::ru => '🇷🇺',
|
language::ru => '🇷🇺',
|
||||||
language::in => '🇮🇳',
|
language::in => '🇮🇳',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ final class question extends core
|
||||||
$this->database = new database()
|
$this->database = new database()
|
||||||
->encoding(encoding::ascii)
|
->encoding(encoding::ascii)
|
||||||
->columns(
|
->columns(
|
||||||
new column('identifier', type::integer_unsigned),
|
new column('identifier', type::long_long_unsigned),
|
||||||
new column('active', 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)
|
||||||
|
|
|
@ -61,7 +61,7 @@ final class localization extends core
|
||||||
$this->database = new database()
|
$this->database = new database()
|
||||||
->encoding(encoding::ascii)
|
->encoding(encoding::ascii)
|
||||||
->columns(
|
->columns(
|
||||||
new column('identifier', type::integer_unsigned),
|
new column('identifier', type::long_long_unsigned),
|
||||||
new column('text', type::string, ['length' => 256]),
|
new column('text', type::string, ['length' => 256]),
|
||||||
new column('A', type::string, ['length' => 128]),
|
new column('A', type::string, ['length' => 128]),
|
||||||
new column('B', type::string, ['length' => 128]),
|
new column('B', type::string, ['length' => 128]),
|
||||||
|
|
|
@ -60,7 +60,7 @@ final class telegram extends core
|
||||||
$this->database = new database()
|
$this->database = new database()
|
||||||
->encoding(encoding::utf8)
|
->encoding(encoding::utf8)
|
||||||
->columns(
|
->columns(
|
||||||
new column('identifier', type::integer_unsigned),
|
new column('identifier', type::long_long_unsigned),
|
||||||
new column('domain', type::string, ['length' => 32]),
|
new column('domain', type::string, ['length' => 32]),
|
||||||
new column('name_first', type::string, ['length' => 64]),
|
new column('name_first', type::string, ['length' => 64]),
|
||||||
new column('name_second', type::string, ['length' => 64]),
|
new column('name_second', type::string, ['length' => 64]),
|
||||||
|
@ -106,7 +106,7 @@ final class telegram extends core
|
||||||
update: function (record &$record) use ($telegram){
|
update: function (record &$record) use ($telegram){
|
||||||
// Writing new values into the record
|
// Writing new values into the record
|
||||||
$record->name_first = $telegram->getFirstName();
|
$record->name_first = $telegram->getFirstName();
|
||||||
$record->name_second = $telegram->getLastName();
|
$record->name_second = (string) $telegram->getLastName();
|
||||||
$record->domain = $telegram->getUsername();
|
$record->domain = $telegram->getUsername();
|
||||||
$record->updated = svoboda::timestamp();
|
$record->updated = svoboda::timestamp();
|
||||||
},
|
},
|
||||||
|
@ -171,12 +171,14 @@ final class telegram extends core
|
||||||
// Initializing the identifier
|
// Initializing the identifier
|
||||||
$identifier = (int) $telegram->getId();
|
$identifier = (int) $telegram->getId();
|
||||||
|
|
||||||
|
echo(svoboda::timestamp());
|
||||||
|
|
||||||
// Initializing the record
|
// Initializing the record
|
||||||
$record = $this->database->record(
|
$record = $this->database->record(
|
||||||
$identifier,
|
$identifier,
|
||||||
$telegram->getUsername(),
|
$telegram->getUsername(),
|
||||||
$telegram->getFirstName(),
|
$telegram->getFirstName(),
|
||||||
$telegram->getLastName(),
|
(string) $telegram->getLastName(),
|
||||||
$telegram->getLanguageCode(),
|
$telegram->getLanguageCode(),
|
||||||
(int) $telegram->isBot(),
|
(int) $telegram->isBot(),
|
||||||
svoboda::timestamp(),
|
svoboda::timestamp(),
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -19,9 +19,9 @@ use Zanzara\Zanzara as zanzara,
|
||||||
Zanzara\Config as config;
|
Zanzara\Config as config;
|
||||||
|
|
||||||
// Enabling debugging
|
// Enabling debugging
|
||||||
/* ini_set('error_reporting', E_ALL);
|
// ini_set('error_reporting', E_ALL);
|
||||||
ini_set('display_errors', 1);
|
// ini_set('display_errors', 1);
|
||||||
ini_set('display_startup_errors', 1); */
|
// ini_set('display_startup_errors', 1);
|
||||||
|
|
||||||
// Initializing path to the public directory
|
// Initializing path to the public directory
|
||||||
define('INDEX', __DIR__);
|
define('INDEX', __DIR__);
|
||||||
|
|
|
@ -23,14 +23,14 @@ $file = DATABASES . DIRECTORY_SEPARATOR . 'telegram.baza';
|
||||||
$database = new database()
|
$database = new database()
|
||||||
->encoding(encoding::utf8)
|
->encoding(encoding::utf8)
|
||||||
->columns(
|
->columns(
|
||||||
new column('identifier', type::integer_unsigned),
|
new column('identifier', type::long_long_unsigned),
|
||||||
new column('domain', type::string, ['length' => 32]),
|
new column('domain', type::string, ['length' => 32]),
|
||||||
new column('name_first', type::string, ['length' => 64]),
|
new column('name_first', type::string, ['length' => 64]),
|
||||||
new column('name_second', type::string, ['length' => 64]),
|
new column('name_second', type::string, ['length' => 64]),
|
||||||
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('updated', type::integer_unsigned),
|
new column('updated', type::integer),
|
||||||
new column('created', type::integer_unsigned)
|
new column('created', type::integer)
|
||||||
)
|
)
|
||||||
->connect($file);
|
->connect($file);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue