forked from mirzaev/deeproots_bot
Integrated upstream changes to baza for issue #25
This commit is contained in:
parent
c545a98f91
commit
8147d2a3bf
|
@ -60,12 +60,7 @@ final class account extends core
|
||||||
$this->database = new database()
|
$this->database = new database()
|
||||||
->encoding(encoding::utf8)
|
->encoding(encoding::utf8)
|
||||||
->columns(
|
->columns(
|
||||||
/**
|
new column('identifier', type::integer_unsigned),
|
||||||
* FIXME: waiting on https://git.svoboda.works/mirzaev/baza/issues/25
|
|
||||||
* baza is writing only the first half of 64bit integer/integer_unsigned
|
|
||||||
* to the database file. type::integer_unsigned should be used here.
|
|
||||||
*/
|
|
||||||
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),
|
||||||
|
|
|
@ -61,12 +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),
|
||||||
* FIXME: waiting on https://git.svoboda.works/mirzaev/baza/issues/25
|
|
||||||
* baza is writing only the first half of 64bit integer/integer_unsigned
|
|
||||||
* to the database file. type::integer_unsigned should be used here.
|
|
||||||
*/
|
|
||||||
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),
|
||||||
|
|
|
@ -67,12 +67,7 @@ final class connection extends core
|
||||||
->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),
|
||||||
* FIXME: waiting on https://git.svoboda.works/mirzaev/baza/issues/25
|
|
||||||
* baza is writing only the first half of 64bit integer/integer_unsigned
|
|
||||||
* to the database file. type::integer_unsigned should be used here.
|
|
||||||
*/
|
|
||||||
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)
|
||||||
|
|
|
@ -61,12 +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),
|
||||||
* FIXME: waiting on https://git.svoboda.works/mirzaev/baza/issues/25
|
|
||||||
* baza is writing only the first half of 64bit integer/integer_unsigned
|
|
||||||
* to the database file. type::integer_unsigned should be used here.
|
|
||||||
*/
|
|
||||||
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,12 +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),
|
||||||
* FIXME: waiting on https://git.svoboda.works/mirzaev/baza/issues/25
|
|
||||||
* baza is writing only the first half of 64bit integer/integer_unsigned
|
|
||||||
* to the database file. type::integer_unsigned should be used here.
|
|
||||||
*/
|
|
||||||
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]),
|
||||||
|
|
|
@ -34,7 +34,7 @@ final class commands extends core
|
||||||
/**
|
/**
|
||||||
* Menu
|
* Menu
|
||||||
*
|
*
|
||||||
* Responce for the commands: "/start", '/menu'
|
* Response for the commands: "/start", '/menu'
|
||||||
*
|
*
|
||||||
* @param context $context Request data from Telegram
|
* @param context $context Request data from Telegram
|
||||||
*
|
*
|
||||||
|
@ -87,7 +87,7 @@ final class commands extends core
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
)->then(function (message $message) use ($context, $localization, $account) {
|
)->then(function (message $message) use ($context, $localization, $account) {
|
||||||
// Sended the message
|
// Sent the message
|
||||||
|
|
||||||
if (
|
if (
|
||||||
$account->authorized_system_accounts ||
|
$account->authorized_system_accounts ||
|
||||||
|
@ -397,17 +397,17 @@ final class commands extends core
|
||||||
[
|
[
|
||||||
[
|
[
|
||||||
'text' => '🏛️ ' . $localization['repository_button_code'],
|
'text' => '🏛️ ' . $localization['repository_button_code'],
|
||||||
'url' => 'https://git.mirzaev.sexy/mirzaev/deeproots'
|
'url' => 'https://git.svoboda.works/deeproots/deeproots'
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
[
|
[
|
||||||
'text' => '⚠️ ' . $localization['repository_button_issues'],
|
'text' => '⚠️ ' . $localization['repository_button_issues'],
|
||||||
'url' => 'https://git.mirzaev.sexy/mirzaev/deeproots/issues'
|
'url' => 'https://git.svoboda.works/deeproots/deeproots/issues'
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'text' => '🌱 ' . $localization['repository_button_suggestions'],
|
'text' => '🌱 ' . $localization['repository_button_suggestions'],
|
||||||
'url' => 'https://git.mirzaev.sexy/mirzaev/deeproots/issues'
|
'url' => 'https://git.svoboda.works/deeproots/deeproots/issues'
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
|
|
@ -339,152 +339,6 @@ final class middlewares extends core
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Contact (middleware)
|
|
||||||
*
|
|
||||||
* Check the account for access to contact with the organization
|
|
||||||
*
|
|
||||||
* @param context $context
|
|
||||||
* @param node $next
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public static function contact(context $context, node $next): void
|
|
||||||
{
|
|
||||||
// Is the process stopped?
|
|
||||||
if ($context->get('stop')) return;
|
|
||||||
|
|
||||||
// Initializing the account
|
|
||||||
$account = $context->get('account');
|
|
||||||
|
|
||||||
if ($account instanceof record) {
|
|
||||||
// Initialized the account
|
|
||||||
|
|
||||||
if ($account->authorized_contact) {
|
|
||||||
// Authorized the account to contact with the organization
|
|
||||||
|
|
||||||
// Continuation of the process
|
|
||||||
$next($context);
|
|
||||||
} else {
|
|
||||||
// Not authorized the account to contact with the organization
|
|
||||||
|
|
||||||
// Initializing localization
|
|
||||||
$localization = $context->get('localization');
|
|
||||||
|
|
||||||
if ($localization) {
|
|
||||||
// Initialized localization
|
|
||||||
|
|
||||||
// Sending the message
|
|
||||||
$context->sendMessage('⛔ *' . $localization['not_authorized_contact'] . '*')
|
|
||||||
->then(function (message $message) use ($context) {
|
|
||||||
// Sended the message
|
|
||||||
|
|
||||||
// Ending the conversation process
|
|
||||||
$context->endConversation();
|
|
||||||
});
|
|
||||||
|
|
||||||
// Stopping the process
|
|
||||||
$context->set('stop', true);
|
|
||||||
} else {
|
|
||||||
// Not initialized localization
|
|
||||||
|
|
||||||
// Sending the message
|
|
||||||
$context->sendMessage('⚠️ *Failed to initialize localization*')
|
|
||||||
->then(function (message $message) use ($context) {
|
|
||||||
// Sended the message
|
|
||||||
|
|
||||||
// Ending the conversation process
|
|
||||||
$context->endConversation();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Not initialized the account
|
|
||||||
|
|
||||||
// Sending the message
|
|
||||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
|
||||||
->then(function (message $message) use ($context) {
|
|
||||||
// Sended the message
|
|
||||||
|
|
||||||
// Ending the conversation process
|
|
||||||
$context->endConversation();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Settings (middleware)
|
|
||||||
*
|
|
||||||
* Check the account for access to settings
|
|
||||||
*
|
|
||||||
* @param context $context
|
|
||||||
* @param node $next
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public static function settings(context $context, node $next): void
|
|
||||||
{
|
|
||||||
// Is the process stopped?
|
|
||||||
if ($context->get('stop')) return;
|
|
||||||
|
|
||||||
// Initializing the account
|
|
||||||
$account = $context->get('account');
|
|
||||||
|
|
||||||
if ($account instanceof record) {
|
|
||||||
// Initialized the account
|
|
||||||
|
|
||||||
if ($account->authorized_settings) {
|
|
||||||
// Authorized the account to the settings
|
|
||||||
|
|
||||||
// Continuation of the process
|
|
||||||
$next($context);
|
|
||||||
} else {
|
|
||||||
// Not authorized the account to the settings
|
|
||||||
|
|
||||||
// Initializing localization
|
|
||||||
$localization = $context->get('localization');
|
|
||||||
|
|
||||||
if ($localization) {
|
|
||||||
// Initialized localization
|
|
||||||
|
|
||||||
// Sending the message
|
|
||||||
$context->sendMessage('⛔ *' . $localization['not_authorized_settings'] . '*')
|
|
||||||
->then(function (message $message) use ($context) {
|
|
||||||
// Sended the message
|
|
||||||
|
|
||||||
// Ending the conversation process
|
|
||||||
$context->endConversation();
|
|
||||||
});
|
|
||||||
|
|
||||||
// Stopping the process
|
|
||||||
$context->set('stop', true);
|
|
||||||
} else {
|
|
||||||
// Not initialized localization
|
|
||||||
|
|
||||||
// Sending the message
|
|
||||||
$context->sendMessage('⚠️ *Failed to initialize localization*')
|
|
||||||
->then(function (message $message) use ($context) {
|
|
||||||
// Sended the message
|
|
||||||
|
|
||||||
// Ending the conversation process
|
|
||||||
$context->endConversation();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Not initialized the account
|
|
||||||
|
|
||||||
// Sending the message
|
|
||||||
$context->sendMessage('⚠️ *Failed to initialize the account*')
|
|
||||||
->then(function (message $message) use ($context) {
|
|
||||||
// Sended the message
|
|
||||||
|
|
||||||
// Ending the conversation process
|
|
||||||
$context->endConversation();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Questions (system) (middleware)
|
* Questions (system) (middleware)
|
||||||
*
|
*
|
||||||
|
|
|
@ -89,12 +89,11 @@ $robot->onCommand('start', [commands::class, 'menu']);
|
||||||
$robot->onCommand('menu', [commands::class, 'menu']);
|
$robot->onCommand('menu', [commands::class, 'menu']);
|
||||||
$robot->onCommand('account', [commands::class, 'account']);
|
$robot->onCommand('account', [commands::class, 'account']);
|
||||||
/* $robot->onCommand('svoboda', [commands::class, 'svoboda']); */
|
/* $robot->onCommand('svoboda', [commands::class, 'svoboda']); */
|
||||||
$robot->onCommand('language', [commands::class, 'language'])->middleware([middlewares::class, 'settings']);
|
$robot->onCommand('language', [commands::class, 'language'])->middleware([middlewares::class, 'language']);
|
||||||
$robot->onCommand('repository', [commands::class, 'repository']);
|
$robot->onCommand('repository', [commands::class, 'repository']);
|
||||||
/* $robot->onCommand('projects', [commands::class, 'projects']); */
|
/* $robot->onCommand('projects', [commands::class, 'projects']); */
|
||||||
$robot->onCommand('author', [commands::class, 'author']);
|
$robot->onCommand('author', [commands::class, 'author']);
|
||||||
$robot->onCommand('society', [commands::class, 'society']);
|
$robot->onCommand('society', [commands::class, 'society']);
|
||||||
// $robot->onCommand('system_settings', [commands::class, 'system_settings'])->middleware([middlewares::class, 'system']);
|
|
||||||
|
|
||||||
// Initializing the robot settings language buttons handlers
|
// Initializing the robot settings language buttons handlers
|
||||||
foreach (language::cases() as $language) {
|
foreach (language::cases() as $language) {
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
return [];
|
|
@ -23,12 +23,7 @@ $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),
|
||||||
* FIXME: waiting on https://git.svoboda.works/mirzaev/baza/issues/25
|
|
||||||
* baza is writing only the first half of 64bit integer/integer_unsigned
|
|
||||||
* to the database file. type::integer_unsigned should be used here.
|
|
||||||
*/
|
|
||||||
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]),
|
||||||
|
|
Loading…
Reference in New Issue