generated from mirzaev/pot-php-telegram
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8e8962d22d |
@@ -35,7 +35,8 @@
|
||||
"twig/extra-bundle": "^3.7",
|
||||
"twig/intl-extra": "^3.10",
|
||||
"react/filesystem": "^0.1.2",
|
||||
"nyholm/psr7": "^1.8"
|
||||
"nyholm/psr7": "^1.8",
|
||||
"irazasyed/telegram-bot-sdk": "^3.15"
|
||||
},
|
||||
"suggest": {
|
||||
"mirzaev/files": "Easy working with files",
|
||||
|
||||
1573
composer.lock
generated
1573
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -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!',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ namespace kodorvan\constructor;
|
||||
// Files of the project
|
||||
use kodorvan\constructor\models\account,
|
||||
kodorvan\constructor\models\telegram\middlewares,
|
||||
kodorvan\constructor\models\telegram\commands,
|
||||
kodorvan\constructor\models\telegram\commands\start,
|
||||
kodorvan\constructor\models\telegram\settings;
|
||||
|
||||
// Library for languages support
|
||||
@@ -18,9 +18,7 @@ use mirzaev\minimal\core,
|
||||
mirzaev\minimal\route;
|
||||
|
||||
// Framework for Telegram
|
||||
use Zanzara\Zanzara as zanzara,
|
||||
Zanzara\Context as context,
|
||||
Zanzara\Config as config;
|
||||
use Telegram\Bot\BotsManager as telegram;
|
||||
|
||||
// Enabling debugging
|
||||
/* 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');
|
||||
|
||||
// Initiailizing Telegram chat-robot settings
|
||||
require(SETTINGS . DIRECTORY_SEPARATOR . 'telegram.php');
|
||||
define('TELEGRAM', require(SETTINGS . DIRECTORY_SEPARATOR . 'telegram.php'));
|
||||
|
||||
// Initializing dependencies
|
||||
require ROOT . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
|
||||
|
||||
// Initializing the configuration
|
||||
$config = new config();
|
||||
$config->setParseMode(config::PARSE_MODE_MARKDOWN);
|
||||
$config->useReactFileSystem(true);
|
||||
// Initializing the robots manager settings
|
||||
$settings = [
|
||||
'bots' => [
|
||||
'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
|
||||
$robot = new Zanzara(ROBOT['key'], $config);
|
||||
// Initializing the robots manager
|
||||
$robot = new telegram($settings);
|
||||
|
||||
// Initializing the updates listener
|
||||
var_dump($telegram->bot('constructor')->getWebhookUpdate());
|
||||
|
||||
/* // Initializing the updates listener
|
||||
$robot->onUpdate(function (context $context): void {});
|
||||
|
||||
// Initializing the robot middlewares
|
||||
@@ -95,4 +106,4 @@ foreach (language::cases() as $language) {
|
||||
$robot->onCbQueryData('project_create', ['process_project_create', 'name']);
|
||||
|
||||
// Starting chat-robot
|
||||
$robot->run();
|
||||
$robot->run(); */
|
||||
|
||||
@@ -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(); */
|
||||
@@ -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(); */
|
||||
@@ -1,7 +1,18 @@
|
||||
<?php
|
||||
|
||||
// Robot
|
||||
define('ROBOT', [
|
||||
'identifier' => null,
|
||||
'key' => ''
|
||||
]);
|
||||
// Telegram API chat-robot
|
||||
return [
|
||||
'constructor' => [
|
||||
'identifier' => 0,
|
||||
'domain' => '',
|
||||
'key' => '',
|
||||
'database' => [
|
||||
'host' => '/run/mysqld/mysqld.sock',
|
||||
'port' => 3306,
|
||||
'user' => '',
|
||||
'password' => '',
|
||||
'database' => '',
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user