From c3dec4417d03a309d92f32ab1b0c63db15a2ef09 Mon Sep 17 00:00:00 2001 From: Arsen Mirzaev Tatyano-Muradovich Date: Thu, 5 Sep 2024 22:00:04 +0700 Subject: [PATCH] =?UTF-8?q?=D0=BF=D0=B5=D1=80=D0=B2=D0=B0=D1=8F=20=D0=B8?= =?UTF-8?q?=D0=BD=D0=B8=D1=86=D0=B8=D0=B0=D0=BB=D0=B8=D0=B7=D0=B0=D1=86?= =?UTF-8?q?=D0=B8=D1=8F=20=D0=B8=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BD=D0=BE?= =?UTF-8?q?=D1=81=20=D0=BD=D0=B0=20=D1=81=D0=B5=D1=80=D0=B2=D0=B5=D1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.json | 16 +- composer.lock | 1398 ++++++++++++++++- .../requests => arming_bot}/system/emojis.txt | 0 mirzaev/arming_bot/system/public/robot.php | 615 ++++++++ .../system/settings/.gitignore | 0 .../system/settings/arangodb.php.sample | 0 .../system/settings/key.php.sample | 0 .../arming_bot/system/storage/example.xlsx | Bin 0 -> 4965 bytes mirzaev/arming_bot/system/storage/import.xlsx | Bin 0 -> 4965 bytes .../registry/requests/system/public/robot.php | 675 -------- 10 files changed, 2024 insertions(+), 680 deletions(-) rename mirzaev/{spetsresurs/telegram/registry/requests => arming_bot}/system/emojis.txt (100%) create mode 100755 mirzaev/arming_bot/system/public/robot.php rename mirzaev/{spetsresurs/telegram/registry/requests => arming_bot}/system/settings/.gitignore (100%) rename mirzaev/{spetsresurs/telegram/registry/requests => arming_bot}/system/settings/arangodb.php.sample (100%) rename mirzaev/{spetsresurs/telegram/registry/requests => arming_bot}/system/settings/key.php.sample (100%) create mode 100644 mirzaev/arming_bot/system/storage/example.xlsx create mode 100644 mirzaev/arming_bot/system/storage/import.xlsx delete mode 100755 mirzaev/spetsresurs/telegram/registry/requests/system/public/robot.php diff --git a/composer.json b/composer.json index 41fcf2b..8f776a5 100755 --- a/composer.json +++ b/composer.json @@ -1,16 +1,23 @@ { - "name": "mirzaev/spetsresurs-telegram-registry-requests", + "name": "mirzaev/arming_bot", "type": "robot", + "tags": [ + "telegram", + "chat-robot", + "military", + "shop" + ], "require": { "triagens/arangodb": "^3.8", "mirzaev/arangodb": "^1.0", "badfarm/zanzara": "^0.9.1", - "nyholm/psr7": "^1.8" + "nyholm/psr7": "^1.8", + "react/filesystem": "^0.1.2" }, "license": "WTFPL", "autoload": { "psr-4": { - "mirzaev\\spetsresurs\\telegram\\registry\\requests\\": "mirzaev/spetsresurs/telegram/registry/requests/system/" + "mirzaev\\arming_bot\\": "mirzaev/arming_bot/system/" } }, "authors": [ @@ -22,7 +29,8 @@ "minimum-stability": "stable", "config": { "allow-plugins": { - "php-http/discovery": true + "php-http/discovery": true, + "wyrihaximus/composer-update-bin-autoload-path": true } } } diff --git a/composer.lock b/composer.lock index 61e9cde..423e4eb 100755 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "24836ff235617e61113ffdb67c6cf37d", + "content-hash": "7bbb4679029cfe777db1bfa0bebac18e", "packages": [ { "name": "badfarm/zanzara", @@ -72,6 +72,125 @@ }, "time": "2023-04-25T18:44:20+00:00" }, + { + "name": "cakephp/core", + "version": "4.5.6", + "source": { + "type": "git", + "url": "https://github.com/cakephp/core.git", + "reference": "c2f4dff110d41e475d1041f2abe236f1c62d0cd0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/cakephp/core/zipball/c2f4dff110d41e475d1041f2abe236f1c62d0cd0", + "reference": "c2f4dff110d41e475d1041f2abe236f1c62d0cd0", + "shasum": "" + }, + "require": { + "cakephp/utility": "^4.0", + "php": ">=7.4.0" + }, + "provide": { + "psr/container-implementation": "^1.0 || ^2.0" + }, + "suggest": { + "cakephp/cache": "To use Configure::store() and restore().", + "cakephp/event": "To use PluginApplicationInterface or plugin applications.", + "league/container": "To use Container and ServiceProvider classes" + }, + "type": "library", + "autoload": { + "files": [ + "functions.php" + ], + "psr-4": { + "Cake\\Core\\": "." + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "CakePHP Community", + "homepage": "https://github.com/cakephp/core/graphs/contributors" + } + ], + "description": "CakePHP Framework Core classes", + "homepage": "https://cakephp.org", + "keywords": [ + "cakephp", + "core", + "framework" + ], + "support": { + "forum": "https://stackoverflow.com/tags/cakephp", + "irc": "irc://irc.freenode.org/cakephp", + "issues": "https://github.com/cakephp/cakephp/issues", + "source": "https://github.com/cakephp/core" + }, + "time": "2023-10-21T13:30:46+00:00" + }, + { + "name": "cakephp/utility", + "version": "4.5.6", + "source": { + "type": "git", + "url": "https://github.com/cakephp/utility.git", + "reference": "708929115e5b400e1b5b76d8120ca2e51e2de199" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/cakephp/utility/zipball/708929115e5b400e1b5b76d8120ca2e51e2de199", + "reference": "708929115e5b400e1b5b76d8120ca2e51e2de199", + "shasum": "" + }, + "require": { + "cakephp/core": "^4.0", + "php": ">=7.4.0" + }, + "suggest": { + "ext-intl": "To use Text::transliterate() or Text::slug()", + "lib-ICU": "To use Text::transliterate() or Text::slug()" + }, + "type": "library", + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Cake\\Utility\\": "." + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "CakePHP Community", + "homepage": "https://github.com/cakephp/utility/graphs/contributors" + } + ], + "description": "CakePHP Utility classes such as Inflector, String, Hash, and Security", + "homepage": "https://cakephp.org", + "keywords": [ + "cakephp", + "hash", + "inflector", + "security", + "string", + "utility" + ], + "support": { + "forum": "https://stackoverflow.com/tags/cakephp", + "irc": "irc://irc.freenode.org/cakephp", + "issues": "https://github.com/cakephp/cakephp/issues", + "source": "https://github.com/cakephp/utility" + }, + "time": "2024-06-23T00:11:14+00:00" + }, { "name": "clue/http-proxy-react", "version": "v1.8.0", @@ -139,6 +258,167 @@ ], "time": "2022-09-01T14:36:49+00:00" }, + { + "name": "doctrine/inflector", + "version": "2.0.10", + "source": { + "type": "git", + "url": "https://github.com/doctrine/inflector.git", + "reference": "5817d0659c5b50c9b950feb9af7b9668e2c436bc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/inflector/zipball/5817d0659c5b50c9b950feb9af7b9668e2c436bc", + "reference": "5817d0659c5b50c9b950feb9af7b9668e2c436bc", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "require-dev": { + "doctrine/coding-standard": "^11.0", + "phpstan/phpstan": "^1.8", + "phpstan/phpstan-phpunit": "^1.1", + "phpstan/phpstan-strict-rules": "^1.3", + "phpunit/phpunit": "^8.5 || ^9.5", + "vimeo/psalm": "^4.25 || ^5.4" + }, + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\Inflector\\": "lib/Doctrine/Inflector" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "PHP Doctrine Inflector is a small library that can perform string manipulations with regard to upper/lowercase and singular/plural forms of words.", + "homepage": "https://www.doctrine-project.org/projects/inflector.html", + "keywords": [ + "inflection", + "inflector", + "lowercase", + "manipulation", + "php", + "plural", + "singular", + "strings", + "uppercase", + "words" + ], + "support": { + "issues": "https://github.com/doctrine/inflector/issues", + "source": "https://github.com/doctrine/inflector/tree/2.0.10" + }, + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finflector", + "type": "tidelift" + } + ], + "time": "2024-02-18T20:23:39+00:00" + }, + { + "name": "doctrine/instantiator", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/instantiator.git", + "reference": "c6222283fa3f4ac679f8b9ced9a4e23f163e80d0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/c6222283fa3f4ac679f8b9ced9a4e23f163e80d0", + "reference": "c6222283fa3f4ac679f8b9ced9a4e23f163e80d0", + "shasum": "" + }, + "require": { + "php": "^8.1" + }, + "require-dev": { + "doctrine/coding-standard": "^11", + "ext-pdo": "*", + "ext-phar": "*", + "phpbench/phpbench": "^1.2", + "phpstan/phpstan": "^1.9.4", + "phpstan/phpstan-phpunit": "^1.3", + "phpunit/phpunit": "^9.5.27", + "vimeo/psalm": "^5.4" + }, + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "https://ocramius.github.io/" + } + ], + "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", + "homepage": "https://www.doctrine-project.org/projects/instantiator.html", + "keywords": [ + "constructor", + "instantiate" + ], + "support": { + "issues": "https://github.com/doctrine/instantiator/issues", + "source": "https://github.com/doctrine/instantiator/tree/2.0.0" + }, + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finstantiator", + "type": "tidelift" + } + ], + "time": "2022-12-30T00:23:10+00:00" + }, { "name": "evenement/evenement", "version": "v3.0.1", @@ -547,6 +827,56 @@ }, "time": "2022-01-27T09:35:39+00:00" }, + { + "name": "paragonie/random_compat", + "version": "v9.99.100", + "source": { + "type": "git", + "url": "https://github.com/paragonie/random_compat.git", + "reference": "996434e5492cb4c3edcb9168db6fbb1359ef965a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/paragonie/random_compat/zipball/996434e5492cb4c3edcb9168db6fbb1359ef965a", + "reference": "996434e5492cb4c3edcb9168db6fbb1359ef965a", + "shasum": "" + }, + "require": { + "php": ">= 7" + }, + "require-dev": { + "phpunit/phpunit": "4.*|5.*", + "vimeo/psalm": "^1" + }, + "suggest": { + "ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes." + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Paragon Initiative Enterprises", + "email": "security@paragonie.com", + "homepage": "https://paragonie.com" + } + ], + "description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7", + "keywords": [ + "csprng", + "polyfill", + "pseudorandom", + "random" + ], + "support": { + "email": "info@paragonie.com", + "issues": "https://github.com/paragonie/random_compat/issues", + "source": "https://github.com/paragonie/random_compat" + }, + "time": "2020-10-15T08:29:30+00:00" + }, { "name": "php-di/invoker", "version": "2.3.3", @@ -1132,6 +1462,85 @@ ], "time": "2022-11-30T15:59:55+00:00" }, + { + "name": "react/child-process", + "version": "v0.6.5", + "source": { + "type": "git", + "url": "https://github.com/reactphp/child-process.git", + "reference": "e71eb1aa55f057c7a4a0d08d06b0b0a484bead43" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/child-process/zipball/e71eb1aa55f057c7a4a0d08d06b0b0a484bead43", + "reference": "e71eb1aa55f057c7a4a0d08d06b0b0a484bead43", + "shasum": "" + }, + "require": { + "evenement/evenement": "^3.0 || ^2.0 || ^1.0", + "php": ">=5.3.0", + "react/event-loop": "^1.2", + "react/stream": "^1.2" + }, + "require-dev": { + "phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.35", + "react/socket": "^1.8", + "sebastian/environment": "^5.0 || ^3.0 || ^2.0 || ^1.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "React\\ChildProcess\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "Event-driven library for executing child processes with ReactPHP.", + "keywords": [ + "event-driven", + "process", + "reactphp" + ], + "support": { + "issues": "https://github.com/reactphp/child-process/issues", + "source": "https://github.com/reactphp/child-process/tree/v0.6.5" + }, + "funding": [ + { + "url": "https://github.com/WyriHaximus", + "type": "github" + }, + { + "url": "https://github.com/clue", + "type": "github" + } + ], + "time": "2022-09-16T13:41:56+00:00" + }, { "name": "react/dns", "version": "v1.11.0", @@ -1280,6 +1689,67 @@ ], "time": "2023-05-05T10:11:24+00:00" }, + { + "name": "react/filesystem", + "version": "v0.1.2", + "source": { + "type": "git", + "url": "https://github.com/reactphp/filesystem.git", + "reference": "766cdef9ba806367114f0c5ba36ea2a6eec8ccd2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/filesystem/zipball/766cdef9ba806367114f0c5ba36ea2a6eec8ccd2", + "reference": "766cdef9ba806367114f0c5ba36ea2a6eec8ccd2", + "shasum": "" + }, + "require": { + "evenement/evenement": "^3.0 || ^2.0", + "php": ">=5.4.0", + "react/event-loop": "^1.0 || ^0.5 || ^0.4", + "react/promise": "~2.2", + "react/promise-stream": "^1.1", + "react/stream": "^1.0 || ^0.7 || ^0.6 || ^0.5 || ^0.4", + "wyrihaximus/react-child-process-pool": "^1.3" + }, + "require-dev": { + "clue/block-react": "^1.1", + "phpunit/phpunit": "^6.0 || ^5.0 || ^4.8" + }, + "suggest": { + "ext-eio": "^1.2" + }, + "type": "library", + "autoload": { + "files": [ + "src/functions_include.php" + ], + "psr-4": { + "React\\Filesystem\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Cees-Jan Kiewiet", + "email": "ceesjank@gmail.com" + } + ], + "description": "Asynchronous filesystem abstraction.", + "keywords": [ + "asynchronous", + "eio", + "filesystem" + ], + "support": { + "issues": "https://github.com/reactphp/filesystem/issues", + "source": "https://github.com/reactphp/filesystem/tree/master" + }, + "time": "2018-10-22T12:10:29+00:00" + }, { "name": "react/http", "version": "v1.9.0", @@ -1444,6 +1914,164 @@ ], "time": "2023-05-02T15:15:43+00:00" }, + { + "name": "react/promise-stream", + "version": "v1.7.0", + "source": { + "type": "git", + "url": "https://github.com/reactphp/promise-stream.git", + "reference": "5c7ec3450f558deb779742e33967d837e2db7871" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/promise-stream/zipball/5c7ec3450f558deb779742e33967d837e2db7871", + "reference": "5c7ec3450f558deb779742e33967d837e2db7871", + "shasum": "" + }, + "require": { + "php": ">=5.3", + "react/promise": "^3 || ^2.1 || ^1.2", + "react/stream": "^1.0 || ^0.7 || ^0.6 || ^0.5 || ^0.4.6" + }, + "require-dev": { + "phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36" + }, + "type": "library", + "autoload": { + "files": [ + "src/functions_include.php" + ], + "psr-4": { + "React\\Promise\\Stream\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "The missing link between Promise-land and Stream-land for ReactPHP", + "homepage": "https://github.com/reactphp/promise-stream", + "keywords": [ + "Buffer", + "async", + "promise", + "reactphp", + "stream", + "unwrap" + ], + "support": { + "issues": "https://github.com/reactphp/promise-stream/issues", + "source": "https://github.com/reactphp/promise-stream/tree/v1.7.0" + }, + "funding": [ + { + "url": "https://opencollective.com/reactphp", + "type": "open_collective" + } + ], + "time": "2023-12-13T11:32:02+00:00" + }, + { + "name": "react/promise-timer", + "version": "v1.11.0", + "source": { + "type": "git", + "url": "https://github.com/reactphp/promise-timer.git", + "reference": "4f70306ed66b8b44768941ca7f142092600fafc1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/reactphp/promise-timer/zipball/4f70306ed66b8b44768941ca7f142092600fafc1", + "reference": "4f70306ed66b8b44768941ca7f142092600fafc1", + "shasum": "" + }, + "require": { + "php": ">=5.3", + "react/event-loop": "^1.2", + "react/promise": "^3.2 || ^2.7.0 || ^1.2.1" + }, + "require-dev": { + "phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36" + }, + "type": "library", + "autoload": { + "files": [ + "src/functions_include.php" + ], + "psr-4": { + "React\\Promise\\Timer\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering", + "homepage": "https://clue.engineering/" + }, + { + "name": "Cees-Jan Kiewiet", + "email": "reactphp@ceesjankiewiet.nl", + "homepage": "https://wyrihaximus.net/" + }, + { + "name": "Jan Sorgalla", + "email": "jsorgalla@gmail.com", + "homepage": "https://sorgalla.com/" + }, + { + "name": "Chris Boden", + "email": "cboden@gmail.com", + "homepage": "https://cboden.dev/" + } + ], + "description": "A trivial implementation of timeouts for Promises, built on top of ReactPHP.", + "homepage": "https://github.com/reactphp/promise-timer", + "keywords": [ + "async", + "event-loop", + "promise", + "reactphp", + "timeout", + "timer" + ], + "support": { + "issues": "https://github.com/reactphp/promise-timer/issues", + "source": "https://github.com/reactphp/promise-timer/tree/v1.11.0" + }, + "funding": [ + { + "url": "https://opencollective.com/reactphp", + "type": "open_collective" + } + ], + "time": "2024-06-04T14:27:45+00:00" + }, { "name": "react/socket", "version": "v1.13.0", @@ -1667,6 +2295,197 @@ }, "time": "2018-05-29T20:21:04+00:00" }, + { + "name": "thecodingmachine/safe", + "version": "v1.3.3", + "source": { + "type": "git", + "url": "https://github.com/thecodingmachine/safe.git", + "reference": "a8ab0876305a4cdaef31b2350fcb9811b5608dbc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/thecodingmachine/safe/zipball/a8ab0876305a4cdaef31b2350fcb9811b5608dbc", + "reference": "a8ab0876305a4cdaef31b2350fcb9811b5608dbc", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "require-dev": { + "phpstan/phpstan": "^0.12", + "squizlabs/php_codesniffer": "^3.2", + "thecodingmachine/phpstan-strict-rules": "^0.12" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.1-dev" + } + }, + "autoload": { + "files": [ + "deprecated/apc.php", + "deprecated/libevent.php", + "deprecated/mssql.php", + "deprecated/stats.php", + "lib/special_cases.php", + "generated/apache.php", + "generated/apcu.php", + "generated/array.php", + "generated/bzip2.php", + "generated/calendar.php", + "generated/classobj.php", + "generated/com.php", + "generated/cubrid.php", + "generated/curl.php", + "generated/datetime.php", + "generated/dir.php", + "generated/eio.php", + "generated/errorfunc.php", + "generated/exec.php", + "generated/fileinfo.php", + "generated/filesystem.php", + "generated/filter.php", + "generated/fpm.php", + "generated/ftp.php", + "generated/funchand.php", + "generated/gmp.php", + "generated/gnupg.php", + "generated/hash.php", + "generated/ibase.php", + "generated/ibmDb2.php", + "generated/iconv.php", + "generated/image.php", + "generated/imap.php", + "generated/info.php", + "generated/ingres-ii.php", + "generated/inotify.php", + "generated/json.php", + "generated/ldap.php", + "generated/libxml.php", + "generated/lzf.php", + "generated/mailparse.php", + "generated/mbstring.php", + "generated/misc.php", + "generated/msql.php", + "generated/mysql.php", + "generated/mysqli.php", + "generated/mysqlndMs.php", + "generated/mysqlndQc.php", + "generated/network.php", + "generated/oci8.php", + "generated/opcache.php", + "generated/openssl.php", + "generated/outcontrol.php", + "generated/password.php", + "generated/pcntl.php", + "generated/pcre.php", + "generated/pdf.php", + "generated/pgsql.php", + "generated/posix.php", + "generated/ps.php", + "generated/pspell.php", + "generated/readline.php", + "generated/rpminfo.php", + "generated/rrd.php", + "generated/sem.php", + "generated/session.php", + "generated/shmop.php", + "generated/simplexml.php", + "generated/sockets.php", + "generated/sodium.php", + "generated/solr.php", + "generated/spl.php", + "generated/sqlsrv.php", + "generated/ssdeep.php", + "generated/ssh2.php", + "generated/stream.php", + "generated/strings.php", + "generated/swoole.php", + "generated/uodbc.php", + "generated/uopz.php", + "generated/url.php", + "generated/var.php", + "generated/xdiff.php", + "generated/xml.php", + "generated/xmlrpc.php", + "generated/yaml.php", + "generated/yaz.php", + "generated/zip.php", + "generated/zlib.php" + ], + "psr-4": { + "Safe\\": [ + "lib/", + "deprecated/", + "generated/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PHP core functions that throw exceptions instead of returning FALSE on error", + "support": { + "issues": "https://github.com/thecodingmachine/safe/issues", + "source": "https://github.com/thecodingmachine/safe/tree/v1.3.3" + }, + "time": "2020-10-28T17:51:34+00:00" + }, + { + "name": "tivie/php-os-detector", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/tivie/php-os-detector.git", + "reference": "9461dcd85c00e03842264f2fc8ccdc8d46867321" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/tivie/php-os-detector/zipball/9461dcd85c00e03842264f2fc8ccdc8d46867321", + "reference": "9461dcd85c00e03842264f2fc8ccdc8d46867321", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "require-dev": { + "phpunit/phpunit": "4.3.*" + }, + "type": "library", + "autoload": { + "psr-4": { + "Tivie\\OS\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "APACHE 2.0" + ], + "authors": [ + { + "name": "Estevão Soares dos Santos", + "email": "estevao@soares-dos-santos.com" + } + ], + "description": "A small utility library that detects the OS the server is running on", + "homepage": "http://tivie.github.com/php-os-detector/", + "keywords": [ + "detection", + "detector", + "identification", + "operating system", + "os", + "os detection" + ], + "support": { + "issues": "https://github.com/tivie/php-os-detector/issues", + "source": "https://github.com/tivie/php-os-detector/tree/master" + }, + "time": "2017-10-21T03:33:59+00:00" + }, { "name": "triagens/arangodb", "version": "v3.8.0", @@ -1727,6 +2546,583 @@ "source": "https://github.com/arangodb/arangodb-php/tree/v3.8.0" }, "time": "2021-06-18T12:06:02+00:00" + }, + { + "name": "wyrihaximus/composer-update-bin-autoload-path", + "version": "1.1.1", + "source": { + "type": "git", + "url": "https://github.com/WyriHaximus/php-composer-update-bin-autoload-path.git", + "reference": "33413e3af4f4d7ab4de3653a706aed57f51e84af" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/WyriHaximus/php-composer-update-bin-autoload-path/zipball/33413e3af4f4d7ab4de3653a706aed57f51e84af", + "reference": "33413e3af4f4d7ab4de3653a706aed57f51e84af", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^2", + "php": "^8 || ^7.4" + }, + "require-dev": { + "wyrihaximus/test-utilities": "^3" + }, + "type": "composer-plugin", + "extra": { + "class": "WyriHaximus\\Composer\\BinAutoloadPathUpdater", + "unused": [ + "php" + ] + }, + "autoload": { + "psr-4": { + "WyriHaximus\\Composer\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "🏰 Composer plugin that fills a bin file with the absolute composer autoload path", + "support": { + "issues": "https://github.com/WyriHaximus/php-composer-update-bin-autoload-path/issues", + "source": "https://github.com/WyriHaximus/php-composer-update-bin-autoload-path/tree/1.1.1" + }, + "funding": [ + { + "url": "https://github.com/WyriHaximus", + "type": "github" + } + ], + "time": "2021-03-14T20:55:38+00:00" + }, + { + "name": "wyrihaximus/constants", + "version": "1.6.0", + "source": { + "type": "git", + "url": "https://github.com/WyriHaximus/php-constants.git", + "reference": "32ceffdd881593c7fa24d8fcbf9deb58687484cb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/WyriHaximus/php-constants/zipball/32ceffdd881593c7fa24d8fcbf9deb58687484cb", + "reference": "32ceffdd881593c7fa24d8fcbf9deb58687484cb", + "shasum": "" + }, + "require": { + "php": "^8 || ^7 || ^5.3" + }, + "type": "library", + "autoload": { + "files": [ + "src/Boolean/constants_include.php", + "src/ComposerAutoloader/constants_include.php", + "src/HTTPStatusCodes/constants_include.php", + "src/Numeric/constants_include.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Cees-Jan Kiewiet", + "email": "ceesjank@gmail.com", + "homepage": "https://www.wyrihaximus.net/" + } + ], + "description": "Collection of constants for PHP", + "support": { + "issues": "https://github.com/WyriHaximus/php-constants/issues", + "source": "https://github.com/WyriHaximus/php-constants/tree/1.6.0" + }, + "funding": [ + { + "url": "https://github.com/WyriHaximus", + "type": "github" + } + ], + "time": "2020-11-28T12:04:43+00:00" + }, + { + "name": "wyrihaximus/cpu-core-detector", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/WyriHaximus/php-cpu-core-detector.git", + "reference": "287aa2730d8d3a8f581004bb7b95fab1b4e5708f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/WyriHaximus/php-cpu-core-detector/zipball/287aa2730d8d3a8f581004bb7b95fab1b4e5708f", + "reference": "287aa2730d8d3a8f581004bb7b95fab1b4e5708f", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8", + "react/child-process": "^0.5 || ^0.4 || ^0.6", + "react/event-loop": "^1.1", + "react/promise": "^2.8", + "tivie/php-os-detector": "^1.0", + "wyrihaximus/react-child-process-promise": "^2 || ^3", + "wyrihaximus/ticking-promise": "^1.5 || ^2" + }, + "require-dev": { + "wyrihaximus/async-test-utilities": "^3.3", + "wyrihaximus/test-utilities": "^3" + }, + "type": "library", + "autoload": { + "files": [ + "src/functions_include.php" + ], + "psr-4": { + "WyriHaximus\\CpuCoreDetector\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Cees-Jan Kiewiet", + "email": "ceesjank@gmail.com" + } + ], + "description": "Detect how many CPU cores are available", + "support": { + "issues": "https://github.com/WyriHaximus/php-cpu-core-detector/issues", + "source": "https://github.com/WyriHaximus/php-cpu-core-detector/tree/2.0.0" + }, + "funding": [ + { + "url": "https://github.com/WyriHaximus", + "type": "github" + } + ], + "time": "2021-03-08T07:46:18+00:00" + }, + { + "name": "wyrihaximus/file-descriptors", + "version": "1.1.1", + "source": { + "type": "git", + "url": "https://github.com/WyriHaximus/php-file-descriptors.git", + "reference": "de9c3dceecfab88c3f73aa6c9ea5372e7f635d7a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/WyriHaximus/php-file-descriptors/zipball/de9c3dceecfab88c3f73aa6c9ea5372e7f635d7a", + "reference": "de9c3dceecfab88c3f73aa6c9ea5372e7f635d7a", + "shasum": "" + }, + "require": { + "php": "^8 || ^7.4", + "thecodingmachine/safe": "^2 || ^1", + "tivie/php-os-detector": "^1.1" + }, + "require-dev": { + "wyrihaximus/iterator-or-array-to-array": "^1.1", + "wyrihaximus/test-utilities": "^3.3.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "WyriHaximus\\FileDescriptors\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Cees-Jan Kiewiet", + "email": "ceesjank@gmail.com" + } + ], + "description": "List open file descriptors for the current process cross platform", + "support": { + "issues": "https://github.com/WyriHaximus/php-file-descriptors/issues", + "source": "https://github.com/WyriHaximus/php-file-descriptors/tree/1.1.1" + }, + "funding": [ + { + "url": "https://github.com/WyriHaximus", + "type": "github" + } + ], + "time": "2024-01-22T13:34:53+00:00" + }, + { + "name": "wyrihaximus/json-throwable", + "version": "4.2.0", + "source": { + "type": "git", + "url": "https://github.com/WyriHaximus/php-json-throwable.git", + "reference": "91c35387bc347dd6fcf37e8baf2588f464a76018" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/WyriHaximus/php-json-throwable/zipball/91c35387bc347dd6fcf37e8baf2588f464a76018", + "reference": "91c35387bc347dd6fcf37e8baf2588f464a76018", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "^1.0.5 || ^2.0.0", + "php": "^8 || ^7.4", + "thecodingmachine/safe": "^1.3.3 || ^2.0.0", + "wyrihaximus/json-utilities": "^1.3.1" + }, + "require-dev": { + "wyrihaximus/test-utilities": "^3.3.1 || ^6.0.0" + }, + "type": "library", + "autoload": { + "files": [ + "src/functions_include.php" + ], + "psr-4": { + "WyriHaximus\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Cees-Jan Kiewiet", + "email": "ceesjank@gmail.com" + } + ], + "description": "📠 JSON encode and decode throwables and exceptions", + "support": { + "issues": "https://github.com/WyriHaximus/php-json-throwable/issues", + "source": "https://github.com/WyriHaximus/php-json-throwable/tree/4.2.0" + }, + "funding": [ + { + "url": "https://github.com/WyriHaximus", + "type": "github" + } + ], + "time": "2024-05-09T13:10:29+00:00" + }, + { + "name": "wyrihaximus/json-utilities", + "version": "1.3.1", + "source": { + "type": "git", + "url": "https://github.com/WyriHaximus/php-json-utilities.git", + "reference": "64c27cc44e37075944debd31196349b903b3aea5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/WyriHaximus/php-json-utilities/zipball/64c27cc44e37075944debd31196349b903b3aea5", + "reference": "64c27cc44e37075944debd31196349b903b3aea5", + "shasum": "" + }, + "require": { + "php": "^8 || ^7.4", + "thecodingmachine/safe": "^2 || ^1.1" + }, + "require-dev": { + "wyrihaximus/test-utilities": "^3.3.1" + }, + "type": "library", + "autoload": { + "files": [ + "src/functions_include.php" + ], + "psr-4": { + "WyriHaximus\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Cees-Jan Kiewiet", + "email": "ceesjank@gmail.com" + } + ], + "description": "Utilities for php-json-* packages", + "support": { + "issues": "https://github.com/WyriHaximus/php-json-utilities/issues", + "source": "https://github.com/WyriHaximus/php-json-utilities/tree/1.3.1" + }, + "funding": [ + { + "url": "https://github.com/WyriHaximus", + "type": "github" + } + ], + "time": "2023-01-16T11:00:08+00:00" + }, + { + "name": "wyrihaximus/react-child-process-messenger", + "version": "4.0.3", + "source": { + "type": "git", + "url": "https://github.com/WyriHaximus/reactphp-child-process-messenger.git", + "reference": "4d1bab02ee4ae62e28a7a8a43428ff6ee9532641" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/WyriHaximus/reactphp-child-process-messenger/zipball/4d1bab02ee4ae62e28a7a8a43428ff6ee9532641", + "reference": "4d1bab02ee4ae62e28a7a8a43428ff6ee9532641", + "shasum": "" + }, + "require": { + "cakephp/utility": "^4.2.4", + "doctrine/inflector": "^2.0.3", + "evenement/evenement": "^3.0.1", + "ext-hash": "^8 || ^7.4", + "ext-json": "^8 || ^7.4", + "paragonie/random_compat": "^9.0 || ^2.0", + "php": "^8 || ^7.4", + "react/child-process": "^0.6.2", + "react/event-loop": "^1.1.1", + "react/promise": "^2.8", + "react/promise-stream": "^1.2", + "react/promise-timer": "^1.6", + "react/socket": "^1.6", + "thecodingmachine/safe": "^1.3.3", + "wyrihaximus/composer-update-bin-autoload-path": "^1.1.1", + "wyrihaximus/constants": "^1.6", + "wyrihaximus/file-descriptors": "^1.1", + "wyrihaximus/json-throwable": "^4.1", + "wyrihaximus/ticking-promise": "^2 || ^3" + }, + "require-dev": { + "wyrihaximus/async-test-utilities": "^3.4.18" + }, + "type": "library", + "extra": { + "unused": [ + "php", + "react/promise-stream" + ], + "wyrihaximus": { + "bin-autoload-path-update": [ + "bin/child-process" + ] + } + }, + "autoload": { + "psr-4": { + "WyriHaximus\\React\\ChildProcess\\Messenger\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Cees-Jan Kiewiet", + "email": "ceesjank@gmail.com", + "homepage": "http://wyrihaximus.net/" + } + ], + "description": "Messenger decorator for react/child-process", + "support": { + "issues": "https://github.com/WyriHaximus/reactphp-child-process-messenger/issues", + "source": "https://github.com/WyriHaximus/reactphp-child-process-messenger/tree/4.0.3" + }, + "funding": [ + { + "url": "https://github.com/WyriHaximus", + "type": "github" + } + ], + "time": "2022-03-12T12:34:18+00:00" + }, + { + "name": "wyrihaximus/react-child-process-pool", + "version": "1.9.0", + "source": { + "type": "git", + "url": "https://github.com/WyriHaximus/reactphp-child-process-pool.git", + "reference": "1ad9bc8c00e2dbebdd9559f57175b6f8eb86ce27" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/WyriHaximus/reactphp-child-process-pool/zipball/1ad9bc8c00e2dbebdd9559f57175b6f8eb86ce27", + "reference": "1ad9bc8c00e2dbebdd9559f57175b6f8eb86ce27", + "shasum": "" + }, + "require": { + "evenement/evenement": "^3.0 || ^2.0", + "php": "^8.0 || ^7.0 || ^5.4", + "react/event-loop": "^1.1", + "wyrihaximus/cpu-core-detector": "^2 || ^1.0.2", + "wyrihaximus/file-descriptors": "^2 || ^1.0 || ^0.1", + "wyrihaximus/react-child-process-messenger": "^4 || ^3 || ^2.10.1", + "wyrihaximus/ticking-promise": "^2 || ^1.5" + }, + "require-dev": { + "clue/block-react": "^1.3", + "phake/phake": "^2.2.1", + "phpunit/phpunit": "^4.8.35||^5.0||^9.5", + "squizlabs/php_codesniffer": "^3.3.2", + "vectorface/dunit": "~2.0" + }, + "suggest": { + "wyrihaximus/react-child-process-pool-redis-queue": "Redis RPC queue" + }, + "type": "library", + "autoload": { + "files": [ + "src/functions_include.php" + ], + "psr-4": { + "WyriHaximus\\React\\ChildProcess\\Pool\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Cees-Jan Kiewiet", + "email": "ceesjank@gmail.com" + } + ], + "description": "Pool wyrihaximus/react-child-process-messenger processes", + "support": { + "issues": "https://github.com/WyriHaximus/reactphp-child-process-pool/issues", + "source": "https://github.com/WyriHaximus/reactphp-child-process-pool/tree/1.9.0" + }, + "funding": [ + { + "url": "https://github.com/WyriHaximus", + "type": "github" + } + ], + "time": "2023-03-19T21:56:02+00:00" + }, + { + "name": "wyrihaximus/react-child-process-promise", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/WyriHaximus/reactphp-child-process-promise.git", + "reference": "4eb763563dc382dd03b46f9fab0fd1993af68316" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/WyriHaximus/reactphp-child-process-promise/zipball/4eb763563dc382dd03b46f9fab0fd1993af68316", + "reference": "4eb763563dc382dd03b46f9fab0fd1993af68316", + "shasum": "" + }, + "require": { + "php": "^7.0|^8.0", + "react/child-process": "^0.6 || ^0.5 || ^0.4", + "react/promise": "^2.7", + "wyrihaximus/ticking-promise": "^1.5.2|^2.0" + }, + "require-dev": { + "phpunit/phpunit": "^6.0||^9.0", + "sebastian/comparator": "^1.2.4||^4.0", + "squizlabs/php_codesniffer": "^3.3.2", + "vectorface/dunit": "^2.0" + }, + "type": "library", + "autoload": { + "files": [ + "src/functions_include.php" + ], + "psr-4": { + "WyriHaximus\\React\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Cees-Jan Kiewiet", + "email": "ceesjank@gmail.com", + "homepage": "http://wyrihaximus.net/" + } + ], + "description": "Wrapping ticks into a promise", + "support": { + "issues": "https://github.com/WyriHaximus/reactphp-child-process-promise/issues", + "source": "https://github.com/WyriHaximus/reactphp-child-process-promise/tree/3.0.0" + }, + "funding": [ + { + "url": "https://github.com/WyriHaximus", + "type": "github" + } + ], + "time": "2020-12-04T15:47:08+00:00" + }, + { + "name": "wyrihaximus/ticking-promise", + "version": "2.1.0", + "source": { + "type": "git", + "url": "https://github.com/WyriHaximus/TickingPromise.git", + "reference": "d3903d4bebe8e3c5b11464c0bb81802cdeeb3751" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/WyriHaximus/TickingPromise/zipball/d3903d4bebe8e3c5b11464c0bb81802cdeeb3751", + "reference": "d3903d4bebe8e3c5b11464c0bb81802cdeeb3751", + "shasum": "" + }, + "require": { + "php": "^8 || ^7.4", + "react/event-loop": "^1.0", + "react/promise": "^2.8" + }, + "require-dev": { + "wyrihaximus/async-test-utilities": "^3" + }, + "type": "library", + "autoload": { + "files": [ + "src/functions_include.php" + ], + "psr-4": { + "WyriHaximus\\React\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Cees-Jan Kiewiet", + "email": "ceesjank@gmail.com", + "homepage": "http://wyrihaximus.net/" + } + ], + "description": "Wrapping ticks into a promise", + "support": { + "issues": "https://github.com/WyriHaximus/TickingPromise/issues", + "source": "https://github.com/WyriHaximus/TickingPromise/tree/2.1.0" + }, + "funding": [ + { + "url": "https://github.com/WyriHaximus", + "type": "github" + } + ], + "time": "2020-11-25T12:43:21+00:00" } ], "packages-dev": [], diff --git a/mirzaev/spetsresurs/telegram/registry/requests/system/emojis.txt b/mirzaev/arming_bot/system/emojis.txt similarity index 100% rename from mirzaev/spetsresurs/telegram/registry/requests/system/emojis.txt rename to mirzaev/arming_bot/system/emojis.txt diff --git a/mirzaev/arming_bot/system/public/robot.php b/mirzaev/arming_bot/system/public/robot.php new file mode 100755 index 0000000..cf704e6 --- /dev/null +++ b/mirzaev/arming_bot/system/public/robot.php @@ -0,0 +1,615 @@ +', + '<', + '!', + '`' + ], + $exceptions + ); + + // Инициализация реестра целей для конвертации + $to = []; + foreach ($from as $symbol) $to[] = "\\$symbol"; + + // Конвертация и выход (успех) + return str_replace($from, $to, $text); +} + +/** + * Инициализация запчасти + * + * Проверяет существование запчасти + * + * @param string $spare Запчасть + * + * @return string|bool Запчасть, если найдена, иначе false + */ +function spares(string $spare): string|bool +{ + // Поиск запчастей и выход (успех) + return match (mb_strtolower($spare)) { + 'цевьё' => 'Цевьё', + default => false + }; +} + +/** + * Авторизация + * + * @param string $id Идентификатор Telegram + * @param bool $registration Регистрация, если аккаунт не найден + * + * @return _document|null Инстанция аккаунта, если найден + */ +function authorization(string $id, bool $registration = true): _document|null +{ + global $arangodb; + + if (collection::init($arangodb->session, 'account')) { + if ($account = collection::search($arangodb->session, sprintf("FOR d IN account FILTER d.id == '%s' RETURN d", $id))) { + // Найден аккаунт + + // Возврат (успех) + return $account; + } else if ($registration) { + // Не найден аккаунт и запрошена его регистрация + + // Создание аккаунта + document::write($arangodb->session, 'account', ['id' => $id, 'banned' => false, 'settings' => false, 'version' => VERSION]); + + // Авторизация (без регистрации) + return authorization($id, false); + } else { + // Не найден аккаунт и не запрошена его регистрация + + // Выход (провал) + return null; + } + } else throw new exception('Не удалось инициализировать коллекцию: account'); + + // Выход (провал) + return null; +} + + +/** + * Главное меню + * + * Команда: /start + * + * @param Context $ctx + * + * @return void + */ +function menu(Context $ctx): void +{ + // Инициализация клавиатуры + $keyboard = [ + [ + ['text' => '🛒 Каталог'] + ], + [ + ['text' => '💬 Контакты'], + ['text' => '🏛️ О компании'] + ], + [ + ['text' => '🎯 Сообщество'] + ] + ]; + + if ($ctx->get('account')?->settings) $keyboard[] = [['text' => '⚙️ Настройки']]; + + // Отправка сообщения + $ctx->sendMessage( + unmarkdown(<< [ + 'keyboard' => $keyboard, + 'resize_keyboard' => true + ], + 'disable_notification' => true + ] + ); +} + +/** + * Категории + * + * Команда: /catalog + * + * @param Context $ctx + * + * @return void + */ +function categories(Context $ctx): void +{ + // Отправка сообщения + $ctx->sendMessage(unmarkdown(<< [ + 'inline_keyboard' => [ + [ + ['text' => '🗜️ Тюнинг', 'callback_data' => 'tuning'] + ] + ] + ], + 'link_preview_options' => [ + 'is_disabled' => true + ], + 'disable_notification' => true + ]); +} + +/** + * Тюнинг + * + * @param Context $ctx + * + * @return void + */ +function tuning(Context $ctx): void +{ + // Отправка сообщения + $ctx->sendMessage(<< [ + 'inline_keyboard' => [ + [ + ['text' => 'Цевьё', 'callback_data' => 'brands'] + ] + ] + ], + 'link_preview_options' => [ + 'is_disabled' => true + ], + 'disable_notification' => true + ]); +} + +/** + * Бренды + * + * @param Context $ctx + * + * @return void + */ +function brands(Context $ctx): void +{ + if ($spare = spares($ctx->getMessage()->getText())) { + // Инициализирована запчасть + + // Отправка сообщения + $ctx->sendMessage(<< [ + 'is_disabled' => true + ], + 'disable_notification' => true + ])->then(function ($message) use ($ctx) { + $ctx; + }); + } else { + // Не инициализирована запчасть + + // Отправка сообщения + $ctx->sendMessage('⚠️ *Не найдена запчасть*'); + } +} + +/** + * Контакты + * + * Команда: /contacts + * + * @param Context $ctx + * + * @return void + */ +function contacts(Context $ctx): void +{ + // Отправка сообщения + $ctx->sendMessage(unmarkdown(<< [ + 'inline_keyboard' => [ + [ + ['text' => '⚡ Связь с менеджером', 'url' => 'https://t.me/iarming'], + ], + [ + ['text' => '📨 Почта', 'callback_data' => 'mail'] + ], + [ + ['text' => '🪖 Сайт', 'url' => 'https://arming.ru'], + ['text' => '🛒 Wildberries', 'url' => 'https://arming.ru'] + ] + ] + ], + 'link_preview_options' => [ + 'is_disabled' => true + ], + 'disable_notification' => true + ]); +} + +/** + * Почта + * + * @param Context $ctx + * + * @return void + */ +function _mail(Context $ctx): void +{ + // Отправка сообщения + $ctx->sendMessage(unmarkdown(<< [ + 'is_disabled' => true + ], + 'disable_notification' => true + ]); +} + +/** + * Компания + * + * Команда: /company + * + * @param Context $ctx + * + * @return void + */ +function company(Context $ctx): void +{ + // Отправка сообщения + $ctx->sendMessage( + unmarkdown(<< [ + 'inline_keyboard' => [ + [ + ['text' => '⚡ Связь с менеджером', 'url' => 'https://git.mirzaev.sexy/mirzaev/mashtrash'], + ['text' => '📨 Почта', 'text' => ''], + ], + [ + ['text' => '🪖 Сайт', 'url' => ''] + ['text' => '🛒 Wildberries', 'url' => ''] + ] + ] + ], + 'link_preview_options' => [ + 'is_disabled' => true + ] + ] */ + ); +} + +/** + * Сообщество + * + * Команда: /community + * + * @param Context $ctx + * + * @return void + */ +function community(Context $ctx): void +{ + // Отправка сообщения + $ctx->sendMessage(unmarkdown(<< [ + 'inline_keyboard' => [ + [ + ['text' => '💬 Основной чат', 'url' => 'https://t.me/arming_zone'], + ] + ] + ], + 'link_preview_options' => [ + 'is_disabled' => true + ], + 'disable_notification' => true + ]); +} + +/** + * Настройки (доступ только авторизованным) + * + * Команда: /settings + * + * @param Context $ctx + * + * @return void + */ +function settings(Context $ctx): void +{ + if ($ctx->get('account')?->settings) { + // Авторизован доступ к настройкам + + // Отправка сообщения + $ctx->sendMessage( + unmarkdown(<< [ + 'inline_keyboard' => [ + [ + ['text' => '📦 Импорт товаров', 'callback_data' => 'import_request'], + ] + ] + ], + 'link_preview_options' => [ + 'is_disabled' => true + ], + 'disable_notification' => true + ] + ); + } else { + // Не авторизован доступ к настройкам + + // Отправка сообщения + $ctx->sendMessage('⛔ *Нет доступа*'); + } +} + +/** + * Запросить файл для импорта товаров (доступ только авторизованным) + * + * @param Context $ctx + * + * @return void + */ +function import_request(Context $ctx): void +{ + if ($ctx->get('account')?->settings) { + // Авторизован доступ к настройкам + + // Отправка сообщения + $ctx->sendMessage(unmarkdown('Отправьте документ в формате xlsx со списком товаров')) + ->then(function ($message) use ($ctx) { + // Отправка файла + $ctx->sendDocument(new InputFile(CATALOG_EXAMPLE), ['disable_notification' => true]); + + // Импорт файла + $ctx->nextStep("import"); + }); + } else { + // Не авторизован доступ к настройкам + + // Отправка сообщения + $ctx->sendMessage('⛔ *Нет доступа*'); + } +} + +/** + * Импорт товаров (доступ только авторизованным) + * + * @param Context $ctx + * + * @return void + */ +function import(Context $ctx): void +{ + if ($ctx->get('account')?->settings) { + // Авторизован доступ к настройкам + + // Инициализация документа + $document = $ctx->getMessage()?->getDocument(); + + if ($document instanceof telegram_document) { + // Инициализирован документ + + // Инициализация файла + $ctx->getFile($document->getFileId())->then(function ($file) use ($ctx) { + + if ($file->getFileSize() <= 50000000) { + // Не превышает 50 мегабайт (50000000 байт) размер файла + + if ($file->getFilePath()['extension'] === 'xlsx') { + // Имеет расширение xlsx файл + + // Сохранение файла + file_put_contents(STORAGE . DIRECTORY_SEPARATOR . 'import.xlsx', file_get_contents('https://api.telegram.org/file/bot' . KEY . '/' . $file->getFilePath())); + + // Инициализация счётчика загруженных товаров + $loaded = $created = $updated = $deleted = $old = $new = 0; + + + + // Отправка сообщения + $ctx->sendMessage(<< *$new* + TXT) + ->then(function ($message) use ($ctx) { + // Завершение диалога + $ctx->endConversation(); + }); + } else { + // Не имеет расширение xlsx файл + + // Отправка сообщения + $ctx->sendMessage(unmarkdown('Файл должен иметь расширение xlsx')); + } + } else { + // Превышает 50 мегабайт (50000000 байт) размер файла + + // Отправка сообщения + $ctx->sendMessage(unmarkdown('Размер файла не должен превышать 50 мегабайт')); + } + }); + } else { + // Не инициализирован документ + + // Отправка сообщения + $ctx->sendMessage(unmarkdown('Отправьте документ в формате xlsx со списком товаров')); + } + } else { + // Не авторизован доступ к настройкам + + // Отправка сообщения + $ctx->sendMessage('⛔ *Нет доступа*'); + } +} + +$config = new Config(); +$config->setParseMode(Config::PARSE_MODE_MARKDOWN); +$config->useReactFileSystem(true); + +$bot = new Zanzara(KEY, $config); +$bot->onCommand('start', function (Context $ctx): void { + // Главное меню + menu($ctx); +}); + +/* $bot->onUpdate(function (Context $ctx): void {}); */ + +/** + * Инициализация аккаунта (middleware) + * + * @param Context $ctx + * @param Node $next + * + * @return void + */ +$account = function (Context $ctx, Node $next): void { + // Выполнение заблокировано? + if ($ctx->get('stop')) return; + + // Авторизация аккаунта + $account = authorization($ctx->getEffectiveUser()->getId()); + + if ($account instanceof _document) { + // Инициализирован аккаунт (подразумевается) + + if ($account->banned) { + // Заблокирован аккаунт + + // Отправка сообщения + $ctx->sendMessage('⛔ *Ты заблокирован*'); + + // Завершение диалога + $ctx->endConversation(); + + // Блокировка дальнейшего выполнения + $ctx->set('stop', true); + } else { + // Не заблокирован аккаунт + + // Запись в буфер + $ctx->set('account', $account); + + // Продолжение выполнения + $next($ctx); + } + } else { + // Не инициализирован аккаунт + } +}; + + +$bot->onCommand('catalog', fn($ctx) => categories($ctx)); +$bot->onCommand('contacts', fn($ctx) => contacts($ctx)); +$bot->onCommand('company', fn($ctx) => company($ctx)); +$bot->onCommand('community', fn($ctx) => community($ctx)); +$bot->onCommand('settings', fn($ctx) => settings($ctx)); + +$bot->onText('🛒 Каталог', fn($ctx) => categories($ctx)); +$bot->onText('💬 Контакты', fn($ctx) => contacts($ctx)); +$bot->onText('🏛️ О компании', fn($ctx) => company($ctx)); +$bot->onText('🎯 Сообщество', fn($ctx) => community($ctx)); +$bot->onText('⚙️ Настройки', fn($ctx) => settings($ctx)); + +$bot->onCbQueryData(['mail'], fn($ctx) => _mail($ctx)); +$bot->onCbQueryData(['import_request'], fn($ctx) => import_request($ctx)); +$bot->onCbQueryData(['tuning'], fn($ctx) => tuning($ctx)); +$bot->onCbQueryData(['brands'], fn($ctx) => brands($ctx)); + +$bot->middleware($account)->run(); diff --git a/mirzaev/spetsresurs/telegram/registry/requests/system/settings/.gitignore b/mirzaev/arming_bot/system/settings/.gitignore similarity index 100% rename from mirzaev/spetsresurs/telegram/registry/requests/system/settings/.gitignore rename to mirzaev/arming_bot/system/settings/.gitignore diff --git a/mirzaev/spetsresurs/telegram/registry/requests/system/settings/arangodb.php.sample b/mirzaev/arming_bot/system/settings/arangodb.php.sample similarity index 100% rename from mirzaev/spetsresurs/telegram/registry/requests/system/settings/arangodb.php.sample rename to mirzaev/arming_bot/system/settings/arangodb.php.sample diff --git a/mirzaev/spetsresurs/telegram/registry/requests/system/settings/key.php.sample b/mirzaev/arming_bot/system/settings/key.php.sample similarity index 100% rename from mirzaev/spetsresurs/telegram/registry/requests/system/settings/key.php.sample rename to mirzaev/arming_bot/system/settings/key.php.sample diff --git a/mirzaev/arming_bot/system/storage/example.xlsx b/mirzaev/arming_bot/system/storage/example.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..ddf140c23ae6df4c9ef81ebc74b695d684d49e85 GIT binary patch literal 4965 zcmaJ_XIN9)whcv!l%Ry(g0xUWlOm{CAqgb{(n5zwl@@x3Pz6K~5UENLK|qk+ktRiu zj)>Axq=hEE+~l15o;=^ZXYTLYd;i#Tt-a;y>B8ic^Q<{LW|l%$0{q+)Xp?eo-Y^OWtqKClPsSYKPj{k+LXpODK8& zI4R&@n|pZ0N;Z-SK2G-5RBHs>xold9V^GY%ja8L6>h_YTb@IiNvz0-vUK3_co=Z>A z2hNM@a>qlj8>!INC~84@mM-|jPt-QX{Zt_NLiI|H_1sTu8E~ItoPR5=k=136V1M`d z{q6{^$eSI*^uoyk`>ca|pcXv_NawQHL{n|@IVR<3GL~H0$WaLf6?4RXPl0PDTt0v| zsowpxh9~8DJ$G4Qh=f0D5v!Lo)v5v#K~7=Uhv2? z>=ok+1~|oTT^X~><_bV!)NsF(!k{SRk@gp9_Acp(=1MY88#{o#C0+Q8v~@MIP&qmE z^nL$*zVmv^=2L+!oNa;gDk~2~4SJHI;3}R=Y@41F{@-Z^)N4faN_=yVM?B@B?uRnj zW0Y^I%avkA5BB&@Y0qgY8^XUQvU889AsAe^&t-&H1(@38fC`lR`Zjo{tph$N4BeQr z;V~}1DJB~_pvh0&d!m`doDDf)7h3_futFT{`;i?>c66&s;4v?Xi_E z7DwAw*%8v4wVdqLxfSkUPMI2#phIafz~Br?yCM%5Sr)N{cn-y(CY`*y)ke{GIqqM< zAqrMVv7jpy!Y;7rUPEN_*Jq`-*iB!53ufe|i)Pz0z7YC)&ho`U4kB3Z!WX`i+T5rH zvdA=*$1UPZrZXX2qP1I>1oMB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[ - '\#', - '\*', - '\_', - '\\=', - '\.', - '\[', - '\]', - '\(', - '\)', - '\-', - '\>', - '\<' - ], - $text - ); -} - -/** - * Авторизация - * - * @param string $id Идентификатор Telegram - * - * @return _document|null|false (инстанция аккаунта, если подключен и авторизован; null, если не подключен; false, если подключен но неавторизован) - */ -function authorization(string $id): _document|null|false -{ - global $arangodb; - - if (collection::init($arangodb->session, 'telegram')) { - if ($telegram = collection::search($arangodb->session, sprintf("FOR d IN telegram FILTER d.id == '%s' RETURN d", $id))) { - if ($telegram->number === null) return null; - else if ( - $telegram->active - && collection::init($arangodb->session, 'account') - && $account = collection::search( - $arangodb->session, - sprintf( - "FOR d IN account FILTER d.number == '%s' RETURN d", - $telegram->number, - $telegram->getId() - ) - ) - ) return $account; - else return false; - } - } else throw new exception('Не удалось инициализировать коллекцию'); - - return false; -} - -/** - * Сотрудник - * - * @param string $id Идентификатор аккаунта - * - * @return _document|null|false (инстанция аккаунта, если подключен и авторизован; null, если не подключен; false, если подключен но неавторизован) - */ -function worker(string $id): _document|null|false -{ - global $arangodb; - - return collection::search( - $arangodb->session, - sprintf( - <<<'AQL' - FOR d IN worker - LET e = ( - FOR e IN account_edge_worker - FILTER e._from == '%s' - SORT e.created DESC, e._key DESC - LIMIT 1 - RETURN e - ) - FILTER d._id == e[0]._to - SORT d.created DESC, d._key DESC - LIMIT 1 - RETURN d - AQL, - $id - ) - ); -} - -function registration(string $id, string $number): bool -{ - global $arangodb; - - if (collection::init($arangodb->session, 'telegram')) { - if ($telegram = collection::search($arangodb->session, sprintf("FOR d IN telegram FILTER d.id == '%s' RETURN d", $id))) { - // Найден аккаунт - - // Запись номера - $telegram->number = $number; - if (!document::update($arangodb->session, $telegram)) return false; - } else if ( - $number === null - || !$telegram = collection::search( - $arangodb->session, - sprintf( - "FOR d IN telegram FILTER d._id == '%s' RETURN d", - document::write($arangodb->session, 'telegram', ['id' => $id, 'active' => false, 'number' => $number]) - ) - ) - ) return false; - - // Инициализация ребра: account -> telegram - if ( - collection::init($arangodb->session, 'account') - && ($account = collection::search( - $arangodb->session, - sprintf( - "FOR d IN account FILTER d.number == '%d' RETURN d", - $telegram->number - ) - )) - && collection::init($arangodb->session, 'connection', true) - && (collection::search( - $arangodb->session, - sprintf( - "FOR d IN connection FILTER d._from == '%s' && d._to == '%s' RETURN d", - $account->getId(), - $telegram->getId() - ) - ) - ?? collection::search( - $arangodb->session, - sprintf( - "FOR d IN connection FILTER d._id == '%s' RETURN d", - document::write( - $arangodb->session, - 'connection', - ['_from' => $account->getId(), '_to' => $telegram->getId()] - ) - ) - )) - ) { - // Инициализировано ребро: account -> telegram - - // Активация - $telegram->active = true; - return document::update($arangodb->session, $telegram); - } - } else throw new exception('Не удалось инициализировать коллекцию'); - - return false; -} - -function generateAuthenticationKeyboard(): array -{ - return [ - 'reply_markup' => [ - 'keyboard' => [ - [ - ['text' => '🔐 Аутентификация', 'request_contact' => true] - ] - ], - 'resize_keyboard' => true - ] - ]; -} - -function generateMenu(Context $ctx): void -{ - if ($account = authorization($ctx->getMessage()?->getFrom()?->getId() ?? $ctx->getCallbackQuery()->getFrom()->getId())) { - // Успешная авторизация - - if (!$account->active) $ctx->sendMessage('⚠️ Свяжитесь с оператором'); - else if ($account->banned) $ctx->sendMessage('⚠️ Свяжитесь с оператором'); - else if (!($worker = worker($account->getId()))->active) $ctx->sendMessage('⚠️ Свяжитесь с оператором'); - else if ($worker->fired) $ctx->sendMessage('⚠️ Свяжитесь с оператором'); - else { - // Активен аккаунт - - $ctx->sendMessage('👋 Здравствуйте, ' . preg_replace('/([._\-()!#])/', '\\\$1', $account->name['first']), [ - 'reply_markup' => [ - 'inline_keyboard' => [ - [ - ['text' => '🔍 Активные заявки', 'callback_data' => 'day'] - ] - ], - 'remove_keyboard' => true - ] - ])->then(function ($message) use ($ctx) { - $ctx->setChatDataItem("menu", $message); - }); - } - } -} - -/** - * Прочитать заявки из ArangoDB - * - * @param int $amount Количество - * @param ?string $date За какую дату (unixtime) - * @param int $page Страница - * @param _document $worker Сотрудник - * - * @return Cursor - */ -function requests(int $amount = 5, ?string $date = null, int $page = 1, _document $worker): Cursor -{ - global $arangodb; - - // Инициализация значения даты по умолчанию - $date ??= time(); - - // Фильтрация номера страницы - if ($page < 1) $page = 1; - - // Инициализация номера страницы для вычислний - --$page; - - // Инициализация сдвига - $offset = $page === 0 ? 0 : $page * $amount; - - return (new _statement( - $arangodb->session, - [ - 'query' => sprintf( - // d.date < %s там специально, не менять на <= - "FOR d IN task FILTER ((d.date >= %s && d.date < %s && d.start >= '05:00') || (d.date >= %s && d.date < %s && d.start < '05:00')) && d.worker == null && d.market != null && d.confirmed != true && d.published == true && d.completed != true && (FOR m IN market FILTER m.id == d.market && IS_ARRAY(m.bans) SORT m.created DESC, m._key DESC LIMIT 1 RETURN !POSITION(m.bans, \"%s\"))[0] SORT d.created DESC, d._key DESC LIMIT %d, %d RETURN d", - $from = (new DateTime("@$date"))->setTime(0, 0)->format('U'), - $to = (new DateTime("@$date"))->modify('+1 day')->setTime(0, 0)->format('U'), - $to, - (new DateTime("@$date"))->modify('+2 day')->setTime(0, 0)->format('U'), - $worker->id, - $offset, - $amount + $offset - ($page > 0) - ), - "batchSize" => 1000, - "sanitize" => true - ] - ))->execute(); -} - -function generateEmojis(): string -{ - return '&#' . hexdec(trim(array_rand(file(__DIR__ . '/../emojis.txt')))) . ';'; -} - -function requests_next(Context $ctx): void -{ - $ctx->getChatDataItem('requests_page')->then(function ($page) use ($ctx) { - $ctx->setChatDataItem('requests_page', ($page ?? 1) + 1)->then(function () use ($ctx, $page) { - search($ctx); - }); - }); -} - -function requests_previous(Context $ctx): void -{ - $ctx->getChatDataItem('requests_page')->then(function ($page) use ($ctx) { - $ctx->setChatDataItem('requests_page', ($page ?? 2) - 1)->then(function () use ($ctx) { - search($ctx); - }); - }); -} - -function request_choose(Context $ctx): void -{ - if (($account = authorization($ctx->getCallbackQuery()->getFrom()->getId())) instanceof _document) { - // Авторизован - - if (!$account->active) $ctx->sendMessage('⚠️ Свяжитесь с оператором'); - else if ($account->banned) $ctx->sendMessage('⚠️ Свяжитесь с оператором'); - else if (!($worker = worker($account->getId()))->active) $ctx->sendMessage('⚠️ Свяжитесь с оператором'); - else if ($worker->fired) $ctx->sendMessage('⚠️ Свяжитесь с оператором'); - else { - // Активен аккаунт - - // Инициализация ключа инстанции task в базе данных - preg_match('/\->\s#(\d+)\n/', $ctx->getCallbackQuery()->getMessage()->getText(), $matches); - - // Запись ключа инстанции task (заявка на которую регистрируется сотрудник) - $ctx->setChatDataItem("request_confirmation_target", $matches[1]); - - // Запрос подтверждения - $ctx->sendMessage("⚡ *Подтверждение записи*\n\n" . preg_replace('/(^[^:\s\n\r]+:)/m', '*$1*', preg_replace('/(\\\#\d+)/', '*$1*', escape($ctx->getCallbackQuery()->getMessage()->getText()))) . "\n\n*⚠️ Вы подтверждаете отправку запроса?*", [ - 'reply_markup' => [ - 'inline_keyboard' => [ - [ - ['text' => 'Подтвердить', 'callback_data' => 'request_confirmed'], - ['text' => 'Отменить', 'callback_data' => 'request_rejected'] - ] - ] - ] - ])->then(function ($message) use ($ctx) { - // Запись сообщения в кеш (на случай необходимости его удаления) - $ctx->setChatDataItem("request_confirmation", $message); - }); - } - } -} - -function request_confirmed(Context $ctx): void -{ - global $arangodb; - - if (($account = authorization($ctx->getCallbackQuery()->getFrom()->getId())) instanceof _document) { - // Авторизован - - $ctx->getChatDataItem("request_confirmation_target")->then(function ($_key) use ($ctx, $arangodb, $account) { - // Прочитана запрашиваемая заявка - - // Инициализация инстанции task в базе данных (выбранного задания) - $task = collection::search($arangodb->session, sprintf("FOR d IN task FILTER d._key == '%s' && d.published == true && d.completed != true && worker == null RETURN d", $_key)); - - if ($task instanceof _document) { - // Найдена заявка (подразумевается, что не занята) - - if ($worker ??= worker($account->getId())) { - // Найден сотрудник - - // Запись идентификатора нового сотрудника - $task->worker = $worker->id; - - // Снятие с публикации - $task->published = false; - - if (document::update($arangodb->session, $task)) { - // Записано обновление в базу данных - - $ctx->getChatDataItem("request_all")->then(function ($requests = []) use ($ctx) { - // Удаление сообщений связанных с запросом - foreach ($requests ?? [] as $_message) $ctx->deleteMessage($_message->getChat()->getId(), $_message->getMessageId()); - }); - $ctx->setChatDataItem("request_all", []); - - $ctx->getChatDataItem("request_confirmation")->then(function ($message) use ($ctx) { - $ctx->deleteMessage($message->getChat()->getId(), $message->getMessageId()); - }); - $ctx->setChatDataItem("request_confirmation_target", null); - - $ctx->sendMessage("✅ *Вы зарегистрировались на заявку:* \#$_key", ['reply_markup' => ['remove_keyboard' => true]])->then(function () use ($ctx) { - generateMenu($ctx); - }); - - // End of the process - $ctx->endConversation(); - } else $ctx->sendMessage("❎ *Не удалось принять заявку:* \#$_key", ['reply_markup' => ['remove_keyboard' => true]])->then(function () use ($ctx) { - generateMenu($ctx); - }); - } else $ctx->sendMessage("❎ *Не удалось принять заявку:* \#$_key", ['reply_markup' => ['remove_keyboard' => true]])->then(function () use ($ctx) { - generateMenu($ctx); - }); - } else $ctx->sendMessage("❎ *Не удалось принять заявку:* \#$_key", ['reply_markup' => ['remove_keyboard' => true]])->then(function () use ($ctx) { - generateMenu($ctx); - }); - }); - } -} - -function request_rejected(Context $ctx): void -{ - $ctx->getChatDataItem("request_confirmation_target")->then(function ($_key) use ($ctx) { - // Прочитана запрашиваемая заявка - - $ctx->getChatDataItem("request_confirmation")->then(function ($message) use ($ctx) { - $ctx->deleteMessage($message->getChat()->getId(), $message->getMessageId()); - }); - $ctx->setChatDataItem("request_confirmation_target", null); - - $ctx->sendMessage("✅ *Вы отменили регистрацию на заявку:* \#$_key", ['reply_markup' => ['remove_keyboard' => true]])->then(function () use ($ctx) { - generateMenu($ctx); - }); - - // End of the process - $ctx->endConversation(); - }); -} - -function day(Context $ctx): void -{ - if (($account = authorization($ctx->getMessage()?->getFrom()?->getId() ?? $ctx->getCallbackQuery()->getFrom()->getId())) instanceof _document) { - // Авторизован - - if (!$account->active) $ctx->sendMessage('⚠️ Свяжитесь с оператором'); - else if ($account->banned) $ctx->sendMessage('⚠️ Свяжитесь с оператором'); - else if (!($worker = worker($account->getId()))->active) $ctx->sendMessage('⚠️ Свяжитесь с оператором'); - else if ($worker->fired) $ctx->sendMessage('⚠️ Свяжитесь с оператором'); - else { - // Активен аккаунт - - // Инициализация буфера клавиатуры - $keyboard = []; - - // Генерация кнопок с выбором даты - for ($i = 1, $r = 0; $i < 15; ++$i) $keyboard[$i > 4 * ($r + 1) ? ++$r : $r][] = ['text' => ($date = (new DateTime)->modify("+$i day"))->format('d.m.Y'), 'callback_data' => $date->format('U')]; - - $ctx->setChatDataItem('requests_page', 1)->then(function () use ($ctx, $keyboard) { - // Отправка меню - $ctx->sendMessage('📅 Выберите дату', [ - 'reply_markup' => [ - 'inline_keyboard' => $keyboard - ] - ])->then(function ($message) use ($ctx) { - $ctx->getChatDataItem("menu")->then(function ($message) use ($ctx) { - // Удаление главного меню - if ($message) $ctx->deleteMessage($message->getChat()->getId(), $message->getMessageId()); - $ctx->setChatDataItem("menu", null); - }); - - // Запись сообщения в кеш (на случай необходимости его удаления при смене страницы) - $ctx->setChatDataItem("request_day", $message); - }); - }); - - $ctx->nextStep("search"); - } - } -} - -function search(Context $ctx): void -{ - global $arangodb; - - if (($account = authorization($ctx->getMessage()?->getFrom()?->getId() ?? $ctx->getCallbackQuery()->getFrom()->getId())) instanceof _document) { - // Авторизован - - if (!$account->active) $ctx->sendMessage('⚠️ Свяжитесь с оператором'); - else if ($account->banned) $ctx->sendMessage('⚠️ Свяжитесь с оператором'); - else if (!($worker = worker($account->getId()))->active) $ctx->sendMessage('⚠️ Свяжитесь с оператором'); - else if ($worker->fired) $ctx->sendMessage('⚠️ Свяжитесь с оператором'); - else { - // Активен аккаунт - - $ctx->getChatDataItem('requests_page')->then(function ($page) use ($ctx, $arangodb, $worker) { - // Найдена текущая страница - - // Значение страницы по умолчанию - if (empty($page)) { - $page = 1; - $ctx->setChatDataItem('requests_page', 1); - } - - $generate = function ($date) use ($ctx, $page, $arangodb, $worker) { - // Поиск заявок в ArangoDB - $tasks = requests(4, (string) $date, $page, $worker); - - // Подсчёт количества прочитанных заявок из базы данных - $count = $tasks->getCount(); - - // Проверка существования избытка - $excess = $count > 3; - - // Обрезка заявок до размера страницы (3 заявки на 1 странице) - $tasks = array_slice($tasks->getAll(), 0, 3); - - if ($count === 0) { - $ctx->sendMessage('📦 *Заявок нет*')->then(function ($message) use ($ctx) { - $ctx->getChatDataItem("request_all")->then(function ($requests = []) use ($ctx, $message) { - // Удаление сообщений связанных с запросом - foreach ($requests ?? [] as $_message) $ctx->deleteMessage($_message->getChat()->getId(), $_message->getMessageId()); - $ctx->setChatDataItem("request_all", $requests = [$message]); - }); - }); - } else { - // Найдены заявки - - $ctx->getChatDataItem("request_day")->then(function ($message) use ($ctx, $arangodb, $tasks, $page, $excess) { - // Удаление предыдущего меню с выбором даты - if ($message) $ctx->deleteMessage($message->getChat()->getId(), $message->getMessageId()); - $ctx->setChatDataItem("request_day", null)->then(function () use ($ctx, $arangodb, $tasks, $page, $excess) { - $ctx->getChatDataItem("request_all")->then(function ($requests = []) use ($ctx, $arangodb, $tasks, $excess, $page) { - // Удаление сообщений связанных с запросом - foreach ($requests ?? [] as $_message) $ctx->deleteMessage($_message->getChat()->getId(), $_message->getMessageId()); - $ctx->setChatDataItem("request_all", [])->then(function () use ($ctx, $arangodb, $tasks, $excess, $page) { - foreach ($tasks as $i => $task) { - // Перебор найденных заявок - - if (($market = collection::search( - $arangodb->session, - sprintf( - "FOR d IN market FILTER d.id == '%s' RETURN d", - $task->market - ) - )) instanceof _document) { - // Найден магазин - $ctx->getChatDataItem("request_$i")->then(function ($message) use ($ctx, $task, $market, $tasks, $i, $page, $excess) { - // Удаление предыдущего сообщения на этой позиции - if ($message) $ctx->deleteMessage($message->getChat()->getId(), $message->getMessageId()); - $ctx->setChatDataItem("request_$i", null)->then(function () use ($ctx, $task, $market, $tasks, $i, $page, $excess) { - // Генерация эмодзи - /* $emoji = generateEmojis(); */ - - // Отправка сообщения - $ctx->sendMessage( - preg_replace( - '/([._\-()!#])/', - '\\\$1', - "*#$task->market* -\> *#{$task->getKey()}*\n" . (new DateTime('@' . $task->date))->format('d.m.Y') . " (" . $task->start . " - " . $task->end . ")\n\n*Город:* $market->city\n*Адрес:* $market->address\n*Работа:* $task->work" . (mb_strlen($task->description) > 0 ? "\n\n$task->description" : '') - ), - [ - 'reply_markup' => [ - 'inline_keyboard' => [ - [ - ['text' => '✅ Отправить запрос', 'callback_data' => 'request_choose'] - ] - ] - ] - ] - )->then(function ($message) use ($ctx, $tasks, $i, $page, $excess) { - // Запись сообщения в кеш (на случай необходимости его удаления при смене страницы) - $ctx->setChatDataItem("request_$i", $message)->then(function () use ($ctx, $message, $tasks, $i, $page, $excess) { - $ctx->getChatDataItem("request_all")->then(function ($requests = []) use ($ctx, $message, $tasks, $i, $page, $excess) { - $ctx->setChatDataItem("request_all", $requests = ($requests ?? []) + [count($requests) => $message])->then(function () use ($ctx, $tasks, $i, $page, $excess) { - if ($i === array_key_last($tasks)) { - // End of the process - $ctx->endConversation(); - - // Удаление предыдущего меню - $ctx->getChatDataItem("request_menu")->then(function ($message) use ($ctx, $page, $excess) { - if ($message) $ctx->deleteMessage($message->getChat()->getId(), $message->getMessageId()); - $ctx->setChatDataItem("request_menu", null)->then(function () use ($ctx, $page, $excess) { - // Инициализация буфера для меню поиска - $keyboard = []; - - // Генерация кнопки: "Предыдущая страница" - if ($page > 1) $keyboard[] = ['text' => 'Назад', 'callback_data' => 'requests_previous']; - - // Генерация кнопки: "Отображённая страница" - $keyboard[] = ['text' => $page, 'callback_data' => 'requests_current']; - - // Генерация кнопки: "Следующая страница" - if ($excess) $keyboard[] = ['text' => 'Вперёд', 'callback_data' => 'requests_next']; - - // Отправка меню - $ctx->sendMessage('🔍 Выберите заявку', [ - 'reply_markup' => [ - 'inline_keyboard' => [ - $keyboard - ] - ] - ])->then(function ($message) use ($ctx) { - // Запись сообщения в кеш (на случай необходимости его удаления при смене страницы) - $ctx->setChatDataItem("request_menu", $message); - }); - }); - }); - } - }); - }); - }); - }); - }); - }); - } - } - }); - }); - }); - }); - } - }; - - // Инициализация даты и генерация - $ctx->getChatDataItem('requests_date')->then(function ($old) use ($ctx, $generate) { - $new = $ctx->getCallbackQuery()->getData(); - if ($new === (string) (int) $new && $new <= PHP_INT_MAX && $new >= ~PHP_INT_MAX) $ctx->setChatDataItem('requests_date', $new)->then(fn () => $generate($new)); - else $generate($old); - }); - }); - } - } -} - -$config = new Config(); -$config->setParseMode(Config::PARSE_MODE_MARKDOWN); - -$bot = new Zanzara(require(__DIR__ . '/../settings/key.php'), $config); - -$stop = false; - -$bot->onUpdate(function (Context $ctx) use (&$stop): void { - $message = $ctx->getMessage(); - - if ( - isset($message) - && ($contact = $message->getContact()) - && $contact->getUserId() === $message->getFrom()->getId() - ) { - // Передан контакт со своими данными (подразумевается второй шаг аутентификации и запуск регистрации) - - // Запуск регистрации - if (registration($contact->getUserId(), $contact->getPhoneNumber())) { - // Успешная регистрация - - $ctx->sendMessage('✅ *Аккаунт подключен*', ['reply_markup' => ['remove_keyboard' => true]])->then(function () use ($ctx) { - generateMenu($ctx); - }); - - $stop = true; - } else $ctx->sendMessage('⛔ *Вы не авторизованы*', generateAuthenticationKeyboard()); - } else if ($message?->getText() !== '🔐 Аутентификация' && !authorization($message?->getFrom()?->getId() ?? $ctx->getCallbackQuery()->getFrom()->getId())) { - $ctx->sendMessage('⛔ *Вы не авторизованы*', generateAuthenticationKeyboard()); - - $stop = true; - } -}); - -$bot->onCommand('start', function (Context $ctx) use ($stop): void { - if ($stop) return; - $ctx->getChatDataItem("request_all")->then(function ($requests = []) use ($ctx) { - // Удаление сообщений связанных с запросом - foreach ($requests ?? [] as $_message) $ctx->deleteMessage($_message->getChat()->getId(), $_message->getMessageId()); - $ctx->setChatDataItem("request_all", []); - }); - - $ctx->getChatDataItem("menu")->then(function ($message) use ($ctx) { - // Удаление главного меню - if ($message) $ctx->deleteMessage($message->getChat()->getId(), $message->getMessageId()); - $ctx->setChatDataItem("menu", null); - }); - - $ctx->getChatDataItem("request_day")->then(function ($message) use ($ctx) { - // Удаление меню выбора даты - if ($message) $ctx->deleteMessage($message->getChat()->getId(), $message->getMessageId()); - $ctx->setChatDataItem("request_day", null); - }); - - generateMenu($ctx); -}); - -$bot->onCbQueryData(['requests_next'], fn ($ctx) => requests_next($ctx)); -$bot->onCbQueryData(['requests_previous'], fn ($ctx) => requests_previous($ctx)); -$bot->onCbQueryData(['request_choose'], fn ($ctx) => request_choose($ctx)); -$bot->onCbQueryData(['request_confirmed'], fn ($ctx) => request_confirmed($ctx)); -$bot->onCbQueryData(['request_rejected'], fn ($ctx) => request_rejected($ctx)); -$bot->onCommand('day', fn ($ctx) => day($ctx)); -$bot->onCbQueryData(['day'], fn ($ctx) => day($ctx)); - -$bot->run();