трудно...

This commit is contained in:
2026-01-19 22:40:39 +05:00
parent a1b5b463c2
commit 8e8962d22d
7 changed files with 1882 additions and 20 deletions

View File

@@ -35,7 +35,8 @@
"twig/extra-bundle": "^3.7", "twig/extra-bundle": "^3.7",
"twig/intl-extra": "^3.10", "twig/intl-extra": "^3.10",
"react/filesystem": "^0.1.2", "react/filesystem": "^0.1.2",
"nyholm/psr7": "^1.8" "nyholm/psr7": "^1.8",
"irazasyed/telegram-bot-sdk": "^3.15"
}, },
"suggest": { "suggest": {
"mirzaev/files": "Easy working with files", "mirzaev/files": "Easy working with files",

1573
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,47 @@
<?php
declare(strict_types=1);
namespace kodorvan\constructor\models\telegram\commands;
// Files of the project
use kodorvan\constructor\models\core,
kodorvan\constructor\models\account,
kodorvan\constructor\models\settings,
kodorvan\constructor\models\telegram\processes\language\select as process_language_select;
// Library for languages support
use mirzaev\languages\language;
// The library for escaping all markdown symbols
use function mirzaev\unmarkdown;
// Framework for Telegram
use Telegram\Bot\Commands\Command as command;
/**
* Command: start
*
* @package kodorvan\constructor\models\telegram\commands
*
* @license http://www.wtfpl.net/ Do What The Fuck You Want To Public License
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/
final class start extends command
{
/**
* Start
*
* @var string $name Name of the command
*/
protected string $name = 'start';
protected string $description = 'Start Command to get you started';
public function handle()
{
$this->replyWithMessage([
'text' => 'Hey, there! Welcome to our bot!',
]);
}
}

View File

@@ -7,7 +7,7 @@ namespace kodorvan\constructor;
// Files of the project // Files of the project
use kodorvan\constructor\models\account, use kodorvan\constructor\models\account,
kodorvan\constructor\models\telegram\middlewares, kodorvan\constructor\models\telegram\middlewares,
kodorvan\constructor\models\telegram\commands, kodorvan\constructor\models\telegram\commands\start,
kodorvan\constructor\models\telegram\settings; kodorvan\constructor\models\telegram\settings;
// Library for languages support // Library for languages support
@@ -18,9 +18,7 @@ use mirzaev\minimal\core,
mirzaev\minimal\route; mirzaev\minimal\route;
// Framework for Telegram // Framework for Telegram
use Zanzara\Zanzara as zanzara, use Telegram\Bot\BotsManager as telegram;
Zanzara\Context as context,
Zanzara\Config as config;
// Enabling debugging // Enabling debugging
/* ini_set('error_reporting', E_ALL); /* ini_set('error_reporting', E_ALL);
@@ -52,20 +50,33 @@ define('DATABASES', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '
define('LOCALIZATIONS', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'localizations'); define('LOCALIZATIONS', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'localizations');
// Initiailizing Telegram chat-robot settings // Initiailizing Telegram chat-robot settings
require(SETTINGS . DIRECTORY_SEPARATOR . 'telegram.php'); define('TELEGRAM', require(SETTINGS . DIRECTORY_SEPARATOR . 'telegram.php'));
// Initializing dependencies // Initializing dependencies
require ROOT . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php'; require ROOT . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
// Initializing the configuration // Initializing the robots manager settings
$config = new config(); $settings = [
$config->setParseMode(config::PARSE_MODE_MARKDOWN); 'bots' => [
$config->useReactFileSystem(true); 'constructor' => [
'token' => TELEGRAM['constructor']['key'],
'certificate_path' => PROJECT_CERTIFICATE,
'webhook_url' => 'https://' . PROJECT_DOMAIN . '/telegram/constructor.php',
'commands' => [
start::class,
]
],
'async_requests' => true,
'base_bot_url' => 'https://' . PROJECT_DOMAIN . '/telegram',
]
];
// Initializing the robot // Initializing the robots manager
$robot = new Zanzara(ROBOT['key'], $config); $robot = new telegram($settings);
// Initializing the updates listener var_dump($telegram->bot('constructor')->getWebhookUpdate());
/* // Initializing the updates listener
$robot->onUpdate(function (context $context): void {}); $robot->onUpdate(function (context $context): void {});
// Initializing the robot middlewares // Initializing the robot middlewares
@@ -95,4 +106,4 @@ foreach (language::cases() as $language) {
$robot->onCbQueryData('project_create', ['process_project_create', 'name']); $robot->onCbQueryData('project_create', ['process_project_create', 'name']);
// Starting chat-robot // Starting chat-robot
$robot->run(); $robot->run(); */

View File

@@ -0,0 +1,112 @@
<?php
declare(strict_types=1);
namespace kodorvan\constructor;
// Files of the project
use kodorvan\constructor\models\account,
kodorvan\constructor\models\telegram\middlewares,
kodorvan\constructor\models\telegram\commands\start,
kodorvan\constructor\models\telegram\settings;
// Library for languages support
use mirzaev\languages\language;
// Framework for PHP
use mirzaev\minimal\core,
mirzaev\minimal\route;
// Framework for Telegram
use Telegram\Bot\BotsManager as telegram;
// Enabling debugging
/* 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__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..');
// Initializing path to the project root directory
define('ROOT', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR);
// Initializing path to the directory of views
define('VIEWS', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'views');
// Initializing path to the directory of settings
define('SETTINGS', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'settings');
// Initializing system settings
require SETTINGS . DIRECTORY_SEPARATOR . 'system.php';
// Initializing path to the directory of the storage
define('STORAGE', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'storage');
// Initializing path to the databases directory
define('DATABASES', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'databases');
// Initializing path to the localizations directory
define('LOCALIZATIONS', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'localizations');
// Initiailizing Telegram chat-robot settings
define('TELEGRAM', require(SETTINGS . DIRECTORY_SEPARATOR . 'telegram.php'));
// Initializing dependencies
require ROOT . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
// Initializing the robots manager settings
$settings = [
'bots' => [
'constructor' => [
'token' => TELEGRAM['constructor']['key'],
'certificate_path' => PROJECT_CERTIFICATE,
'webhook_url' => 'https://' . PROJECT_DOMAIN . '/telegram/constructor/webhook.php',
'commands' => [
start::class,
]
],
'async_requests' => true,
'base_bot_url' => 'https://' . PROJECT_DOMAIN . '/telegram',
]
];
// Initializing the robots manager
$telegram = new telegram($settings);
$updates = $telegram->bot('constructor')->setWebhook([
'url' => 'https://' . PROJECT_DOMAIN . '/telegram/constructor/webhook.php',
'certificate' => PROJECT_CERTIFICATE
]);
/* // Initializing the updates listener
$robot->onUpdate(function (context $context): void {});
// Initializing the robot middlewares
$robot->middleware([middlewares::class, 'account']);
$robot->middleware([middlewares::class, 'language']);
$robot->middleware([middlewares::class, 'localization']);
$robot->middleware([middlewares::class, 'authorizations']);
// Initializing the robot commands handlers
$robot->onCommand('start', [commands::class, 'start']);
$robot->onCommand('start telegram voronka', [commands::class, 'start']);
$robot->onCommand('start parser', [commands::class, 'start']);
$robot->onCommand('start calculator', [commands::class, 'start']);
$robot->onCommand('language', [commands::class, 'language'])->middleware([middlewares::class, 'settings']);
$robot->onCommand('society', [commands::class, 'society']);
// Initializing the robot settings language buttons handlers
foreach (language::cases() as $language) {
// Iterating over languages
// Initializing language buttons
$robot->onCbQueryData(["settings_language_$language->name"], fn(context $context) => settings::language($context, $language));
};
$robot->onCbQueryData('project_create', ['process_project_create', 'name']);
// Starting chat-robot
$robot->run(); */

View File

@@ -0,0 +1,109 @@
<?php
declare(strict_types=1);
namespace kodorvan\constructor;
// Files of the project
use kodorvan\constructor\models\account,
kodorvan\constructor\models\telegram\middlewares,
kodorvan\constructor\models\telegram\commands\start,
kodorvan\constructor\models\telegram\settings;
// Library for languages support
use mirzaev\languages\language;
// Framework for PHP
use mirzaev\minimal\core,
mirzaev\minimal\route;
// Framework for Telegram
use Telegram\Bot\BotsManager as telegram;
// Enabling debugging
/* 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__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..');
// Initializing path to the project root directory
define('ROOT', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR);
// Initializing path to the directory of views
define('VIEWS', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'views');
// Initializing path to the directory of settings
define('SETTINGS', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'settings');
// Initializing system settings
require SETTINGS . DIRECTORY_SEPARATOR . 'system.php';
// Initializing path to the directory of the storage
define('STORAGE', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'storage');
// Initializing path to the databases directory
define('DATABASES', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'databases');
// Initializing path to the localizations directory
define('LOCALIZATIONS', INDEX . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'localizations');
// Initiailizing Telegram chat-robot settings
define('TELEGRAM', require(SETTINGS . DIRECTORY_SEPARATOR . 'telegram.php'));
// Initializing dependencies
require ROOT . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
// Initializing the robots manager settings
$settings = [
'bots' => [
'constructor' => [
'token' => TELEGRAM['constructor']['key'],
'certificate_path' => PROJECT_CERTIFICATE,
'webhook_url' => 'https://' . PROJECT_DOMAIN . ':443/telegram/constructor.php',
'commands' => [
start::class,
]
],
'async_requests' => true,
'base_bot_url' => 'https://' . PROJECT_DOMAIN . '/telegram',
]
];
// Initializing the robots manager
$telegram = new telegram($settings);
var_dump($updates = $telegram->bot('constructor')->getWebhookUpdate());
/* // Initializing the updates listener
$robot->onUpdate(function (context $context): void {});
// Initializing the robot middlewares
$robot->middleware([middlewares::class, 'account']);
$robot->middleware([middlewares::class, 'language']);
$robot->middleware([middlewares::class, 'localization']);
$robot->middleware([middlewares::class, 'authorizations']);
// Initializing the robot commands handlers
$robot->onCommand('start', [commands::class, 'start']);
$robot->onCommand('start telegram voronka', [commands::class, 'start']);
$robot->onCommand('start parser', [commands::class, 'start']);
$robot->onCommand('start calculator', [commands::class, 'start']);
$robot->onCommand('language', [commands::class, 'language'])->middleware([middlewares::class, 'settings']);
$robot->onCommand('society', [commands::class, 'society']);
// Initializing the robot settings language buttons handlers
foreach (language::cases() as $language) {
// Iterating over languages
// Initializing language buttons
$robot->onCbQueryData(["settings_language_$language->name"], fn(context $context) => settings::language($context, $language));
};
$robot->onCbQueryData('project_create', ['process_project_create', 'name']);
// Starting chat-robot
$robot->run(); */

View File

@@ -1,7 +1,18 @@
<?php <?php
// Robot // Telegram API chat-robot
define('ROBOT', [ return [
'identifier' => null, 'constructor' => [
'key' => '' 'identifier' => 0,
]); 'domain' => '',
'key' => '',
'database' => [
'host' => '/run/mysqld/mysqld.sock',
'port' => 3306,
'user' => '',
'password' => '',
'database' => '',
]
]
];