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