Большая переработка

This commit is contained in:
Arsen Mirzaev Tatyano-Muradovich 2022-11-10 23:21:15 +10:00
parent dae9b2b5b1
commit 3a448ea83c
6 changed files with 1146 additions and 149 deletions

View File

@ -30,7 +30,8 @@
}
],
"require": {
"php": "^8.1"
"php": "^8.1",
"mirzaev/vk": "^4.5"
},
"autoload": {
"psr-4": {

918
composer.lock generated Normal file
View File

@ -0,0 +1,918 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "a2483383d0001f89636d093e62a404e4",
"packages": [
{
"name": "guzzlehttp/guzzle",
"version": "7.5.0",
"source": {
"type": "git",
"url": "https://github.com/guzzle/guzzle.git",
"reference": "b50a2a1251152e43f6a37f0fa053e730a67d25ba"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/b50a2a1251152e43f6a37f0fa053e730a67d25ba",
"reference": "b50a2a1251152e43f6a37f0fa053e730a67d25ba",
"shasum": ""
},
"require": {
"ext-json": "*",
"guzzlehttp/promises": "^1.5",
"guzzlehttp/psr7": "^1.9 || ^2.4",
"php": "^7.2.5 || ^8.0",
"psr/http-client": "^1.0",
"symfony/deprecation-contracts": "^2.2 || ^3.0"
},
"provide": {
"psr/http-client-implementation": "1.0"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.8.1",
"ext-curl": "*",
"php-http/client-integration-tests": "^3.0",
"phpunit/phpunit": "^8.5.29 || ^9.5.23",
"psr/log": "^1.1 || ^2.0 || ^3.0"
},
"suggest": {
"ext-curl": "Required for CURL handler support",
"ext-intl": "Required for Internationalized Domain Name (IDN) support",
"psr/log": "Required for using the Log middleware"
},
"type": "library",
"extra": {
"bamarni-bin": {
"bin-links": true,
"forward-command": false
},
"branch-alias": {
"dev-master": "7.5-dev"
}
},
"autoload": {
"files": [
"src/functions_include.php"
],
"psr-4": {
"GuzzleHttp\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Graham Campbell",
"email": "hello@gjcampbell.co.uk",
"homepage": "https://github.com/GrahamCampbell"
},
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
},
{
"name": "Jeremy Lindblom",
"email": "jeremeamia@gmail.com",
"homepage": "https://github.com/jeremeamia"
},
{
"name": "George Mponos",
"email": "gmponos@gmail.com",
"homepage": "https://github.com/gmponos"
},
{
"name": "Tobias Nyholm",
"email": "tobias.nyholm@gmail.com",
"homepage": "https://github.com/Nyholm"
},
{
"name": "Márk Sági-Kazár",
"email": "mark.sagikazar@gmail.com",
"homepage": "https://github.com/sagikazarmark"
},
{
"name": "Tobias Schultze",
"email": "webmaster@tubo-world.de",
"homepage": "https://github.com/Tobion"
}
],
"description": "Guzzle is a PHP HTTP client library",
"keywords": [
"client",
"curl",
"framework",
"http",
"http client",
"psr-18",
"psr-7",
"rest",
"web service"
],
"support": {
"issues": "https://github.com/guzzle/guzzle/issues",
"source": "https://github.com/guzzle/guzzle/tree/7.5.0"
},
"funding": [
{
"url": "https://github.com/GrahamCampbell",
"type": "github"
},
{
"url": "https://github.com/Nyholm",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/guzzlehttp/guzzle",
"type": "tidelift"
}
],
"time": "2022-08-28T15:39:27+00:00"
},
{
"name": "guzzlehttp/promises",
"version": "1.5.2",
"source": {
"type": "git",
"url": "https://github.com/guzzle/promises.git",
"reference": "b94b2807d85443f9719887892882d0329d1e2598"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/promises/zipball/b94b2807d85443f9719887892882d0329d1e2598",
"reference": "b94b2807d85443f9719887892882d0329d1e2598",
"shasum": ""
},
"require": {
"php": ">=5.5"
},
"require-dev": {
"symfony/phpunit-bridge": "^4.4 || ^5.1"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.5-dev"
}
},
"autoload": {
"files": [
"src/functions_include.php"
],
"psr-4": {
"GuzzleHttp\\Promise\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Graham Campbell",
"email": "hello@gjcampbell.co.uk",
"homepage": "https://github.com/GrahamCampbell"
},
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
},
{
"name": "Tobias Nyholm",
"email": "tobias.nyholm@gmail.com",
"homepage": "https://github.com/Nyholm"
},
{
"name": "Tobias Schultze",
"email": "webmaster@tubo-world.de",
"homepage": "https://github.com/Tobion"
}
],
"description": "Guzzle promises library",
"keywords": [
"promise"
],
"support": {
"issues": "https://github.com/guzzle/promises/issues",
"source": "https://github.com/guzzle/promises/tree/1.5.2"
},
"funding": [
{
"url": "https://github.com/GrahamCampbell",
"type": "github"
},
{
"url": "https://github.com/Nyholm",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/guzzlehttp/promises",
"type": "tidelift"
}
],
"time": "2022-08-28T14:55:35+00:00"
},
{
"name": "guzzlehttp/psr7",
"version": "2.4.3",
"source": {
"type": "git",
"url": "https://github.com/guzzle/psr7.git",
"reference": "67c26b443f348a51926030c83481b85718457d3d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/psr7/zipball/67c26b443f348a51926030c83481b85718457d3d",
"reference": "67c26b443f348a51926030c83481b85718457d3d",
"shasum": ""
},
"require": {
"php": "^7.2.5 || ^8.0",
"psr/http-factory": "^1.0",
"psr/http-message": "^1.0",
"ralouphie/getallheaders": "^3.0"
},
"provide": {
"psr/http-factory-implementation": "1.0",
"psr/http-message-implementation": "1.0"
},
"require-dev": {
"bamarni/composer-bin-plugin": "^1.8.1",
"http-interop/http-factory-tests": "^0.9",
"phpunit/phpunit": "^8.5.29 || ^9.5.23"
},
"suggest": {
"laminas/laminas-httphandlerrunner": "Emit PSR-7 responses"
},
"type": "library",
"extra": {
"bamarni-bin": {
"bin-links": true,
"forward-command": false
},
"branch-alias": {
"dev-master": "2.4-dev"
}
},
"autoload": {
"psr-4": {
"GuzzleHttp\\Psr7\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Graham Campbell",
"email": "hello@gjcampbell.co.uk",
"homepage": "https://github.com/GrahamCampbell"
},
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
},
{
"name": "George Mponos",
"email": "gmponos@gmail.com",
"homepage": "https://github.com/gmponos"
},
{
"name": "Tobias Nyholm",
"email": "tobias.nyholm@gmail.com",
"homepage": "https://github.com/Nyholm"
},
{
"name": "Márk Sági-Kazár",
"email": "mark.sagikazar@gmail.com",
"homepage": "https://github.com/sagikazarmark"
},
{
"name": "Tobias Schultze",
"email": "webmaster@tubo-world.de",
"homepage": "https://github.com/Tobion"
},
{
"name": "Márk Sági-Kazár",
"email": "mark.sagikazar@gmail.com",
"homepage": "https://sagikazarmark.hu"
}
],
"description": "PSR-7 message implementation that also provides common utility methods",
"keywords": [
"http",
"message",
"psr-7",
"request",
"response",
"stream",
"uri",
"url"
],
"support": {
"issues": "https://github.com/guzzle/psr7/issues",
"source": "https://github.com/guzzle/psr7/tree/2.4.3"
},
"funding": [
{
"url": "https://github.com/GrahamCampbell",
"type": "github"
},
{
"url": "https://github.com/Nyholm",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/guzzlehttp/psr7",
"type": "tidelift"
}
],
"time": "2022-10-26T14:07:24+00:00"
},
{
"name": "jasny/error-handler",
"version": "v0.2.0",
"source": {
"type": "git",
"url": "https://github.com/jasny/error-handler.git",
"reference": "38e076fc36d86689010081bc2eab96f12d97b0d8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/jasny/error-handler/zipball/38e076fc36d86689010081bc2eab96f12d97b0d8",
"reference": "38e076fc36d86689010081bc2eab96f12d97b0d8",
"shasum": ""
},
"require": {
"php": ">=5.6.0",
"psr/http-message": "^1.0",
"psr/log": "^1.0"
},
"require-dev": {
"jasny/http-message": "^1.3",
"jasny/php-code-quality": "^2.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Jasny\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Arnold Daniels",
"email": "arnold@jasny.net",
"homepage": "http://www.jasny.net"
}
],
"description": "Error handler with PSR-7 support",
"keywords": [
"error handler",
"exception handler",
"middleware"
],
"support": {
"issues": "https://github.com/jasny/error-handler/issues",
"source": "https://github.com/jasny/error-handler"
},
"abandoned": true,
"time": "2017-01-25T01:27:18+00:00"
},
{
"name": "mirzaev/accounts",
"version": "1.2.0",
"source": {
"type": "git",
"url": "https://git.mirzaev.sexy/mirzaev/accounts",
"reference": "16d592432021356ee5dbbe7794574a36a48988d1"
},
"require": {
"ext-dom": "20031129",
"ext-libxml": "~8.1.1",
"guzzlehttp/guzzle": "^7.2",
"php": "~8.1"
},
"require-dev": {
"phpdocumentor/phpdocumentor": ">=2.9",
"phpunit/phpunit": "^9"
},
"type": "library",
"autoload": {
"psr-4": {
"mirzaev\\accounts\\": "mirzaev/accounts/system"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"WTFPL"
],
"authors": [
{
"name": "Arsen Mirzaev Tatyano-Muradovich",
"email": "arsen@mirzaev.sexy",
"homepage": "https://mirzaev.sexy",
"role": "Programmer"
}
],
"description": "Simple accounts manager",
"homepage": "https://git.mirzaev.sexy/mirzaev/accounts",
"keywords": [
"accounts"
],
"support": {
"email": "arsen@mirzaev.sexy",
"issues": "https://git.mirzaev.sexy/mirzaev/accounts/issues",
"wiki": "https://git.mirzaev.sexy/mirzaev/accounts/wiki"
},
"funding": [
{
"url": "https://fund.mirzaev.sexy",
"type": "funding"
}
],
"time": "2022-11-05T23:47:32+00:00"
},
{
"name": "mirzaev/vk",
"version": "4.5.0",
"source": {
"type": "git",
"url": "https://git.mirzaev.sexy/mirzaev/vk",
"reference": "39d13d9020c41d03f389254a4c2cda97cb61b8de"
},
"require": {
"guzzlehttp/guzzle": "^7.5",
"jasny/error-handler": "^0.2",
"mirzaev/accounts": "^1.2.0",
"monolog/monolog": "^1.6",
"php": "^8.1",
"psr/log": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "^9.5"
},
"suggest": {
"ext-sodium": "Can be selected in some conditions to increase security"
},
"type": "framework",
"autoload": {
"psr-4": {
"mirzaev\\vk\\": "mirzaev/vk/system"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"WTFPL"
],
"authors": [
{
"name": "Arsen Mirzaev Tatyano-Muradovich",
"email": "arsen@mirzaev.sexy",
"homepage": "https://mirzaev.sexy/mirzaev",
"role": "Programmer"
}
],
"description": "Framework for vk.com API",
"homepage": "https://git.mirzaev.sexy/mirzaev/vk",
"keywords": [
"api",
"vk"
],
"support": {
"docs": "https://git.mirzaev.sexy/mirzaev/vk/wiki",
"issues": "https://git.mirzaev.sexy/mirzaev/vk/issues"
},
"time": "2022-11-10T13:15:06+00:00"
},
{
"name": "monolog/monolog",
"version": "1.27.1",
"source": {
"type": "git",
"url": "https://github.com/Seldaek/monolog.git",
"reference": "904713c5929655dc9b97288b69cfeedad610c9a1"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/904713c5929655dc9b97288b69cfeedad610c9a1",
"reference": "904713c5929655dc9b97288b69cfeedad610c9a1",
"shasum": ""
},
"require": {
"php": ">=5.3.0",
"psr/log": "~1.0"
},
"provide": {
"psr/log-implementation": "1.0.0"
},
"require-dev": {
"aws/aws-sdk-php": "^2.4.9 || ^3.0",
"doctrine/couchdb": "~1.0@dev",
"graylog2/gelf-php": "~1.0",
"php-amqplib/php-amqplib": "~2.4",
"php-console/php-console": "^3.1.3",
"phpstan/phpstan": "^0.12.59",
"phpunit/phpunit": "~4.5",
"ruflin/elastica": ">=0.90 <3.0",
"sentry/sentry": "^0.13",
"swiftmailer/swiftmailer": "^5.3|^6.0"
},
"suggest": {
"aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB",
"doctrine/couchdb": "Allow sending log messages to a CouchDB server",
"ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)",
"ext-mongo": "Allow sending log messages to a MongoDB server",
"graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server",
"mongodb/mongodb": "Allow sending log messages to a MongoDB server via PHP Driver",
"php-amqplib/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib",
"php-console/php-console": "Allow sending log messages to Google Chrome",
"rollbar/rollbar": "Allow sending log messages to Rollbar",
"ruflin/elastica": "Allow sending log messages to an Elastic Search server",
"sentry/sentry": "Allow sending log messages to a Sentry server"
},
"type": "library",
"autoload": {
"psr-4": {
"Monolog\\": "src/Monolog"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jordi Boggiano",
"email": "j.boggiano@seld.be",
"homepage": "http://seld.be"
}
],
"description": "Sends your logs to files, sockets, inboxes, databases and various web services",
"homepage": "http://github.com/Seldaek/monolog",
"keywords": [
"log",
"logging",
"psr-3"
],
"support": {
"issues": "https://github.com/Seldaek/monolog/issues",
"source": "https://github.com/Seldaek/monolog/tree/1.27.1"
},
"funding": [
{
"url": "https://github.com/Seldaek",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/monolog/monolog",
"type": "tidelift"
}
],
"time": "2022-06-09T08:53:42+00:00"
},
{
"name": "psr/http-client",
"version": "1.0.1",
"source": {
"type": "git",
"url": "https://github.com/php-fig/http-client.git",
"reference": "2dfb5f6c5eff0e91e20e913f8c5452ed95b86621"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/http-client/zipball/2dfb5f6c5eff0e91e20e913f8c5452ed95b86621",
"reference": "2dfb5f6c5eff0e91e20e913f8c5452ed95b86621",
"shasum": ""
},
"require": {
"php": "^7.0 || ^8.0",
"psr/http-message": "^1.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Http\\Client\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
}
],
"description": "Common interface for HTTP clients",
"homepage": "https://github.com/php-fig/http-client",
"keywords": [
"http",
"http-client",
"psr",
"psr-18"
],
"support": {
"source": "https://github.com/php-fig/http-client/tree/master"
},
"time": "2020-06-29T06:28:15+00:00"
},
{
"name": "psr/http-factory",
"version": "1.0.1",
"source": {
"type": "git",
"url": "https://github.com/php-fig/http-factory.git",
"reference": "12ac7fcd07e5b077433f5f2bee95b3a771bf61be"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/http-factory/zipball/12ac7fcd07e5b077433f5f2bee95b3a771bf61be",
"reference": "12ac7fcd07e5b077433f5f2bee95b3a771bf61be",
"shasum": ""
},
"require": {
"php": ">=7.0.0",
"psr/http-message": "^1.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Http\\Message\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
}
],
"description": "Common interfaces for PSR-7 HTTP message factories",
"keywords": [
"factory",
"http",
"message",
"psr",
"psr-17",
"psr-7",
"request",
"response"
],
"support": {
"source": "https://github.com/php-fig/http-factory/tree/master"
},
"time": "2019-04-30T12:38:16+00:00"
},
{
"name": "psr/http-message",
"version": "1.0.1",
"source": {
"type": "git",
"url": "https://github.com/php-fig/http-message.git",
"reference": "f6561bf28d520154e4b0ec72be95418abe6d9363"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363",
"reference": "f6561bf28d520154e4b0ec72be95418abe6d9363",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Http\\Message\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
}
],
"description": "Common interface for HTTP messages",
"homepage": "https://github.com/php-fig/http-message",
"keywords": [
"http",
"http-message",
"psr",
"psr-7",
"request",
"response"
],
"support": {
"source": "https://github.com/php-fig/http-message/tree/master"
},
"time": "2016-08-06T14:39:51+00:00"
},
{
"name": "psr/log",
"version": "1.1.4",
"source": {
"type": "git",
"url": "https://github.com/php-fig/log.git",
"reference": "d49695b909c3b7628b6289db5479a1c204601f11"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11",
"reference": "d49695b909c3b7628b6289db5479a1c204601f11",
"shasum": ""
},
"require": {
"php": ">=5.3.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.1.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Log\\": "Psr/Log/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "https://www.php-fig.org/"
}
],
"description": "Common interface for logging libraries",
"homepage": "https://github.com/php-fig/log",
"keywords": [
"log",
"psr",
"psr-3"
],
"support": {
"source": "https://github.com/php-fig/log/tree/1.1.4"
},
"time": "2021-05-03T11:20:27+00:00"
},
{
"name": "ralouphie/getallheaders",
"version": "3.0.3",
"source": {
"type": "git",
"url": "https://github.com/ralouphie/getallheaders.git",
"reference": "120b605dfeb996808c31b6477290a714d356e822"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/120b605dfeb996808c31b6477290a714d356e822",
"reference": "120b605dfeb996808c31b6477290a714d356e822",
"shasum": ""
},
"require": {
"php": ">=5.6"
},
"require-dev": {
"php-coveralls/php-coveralls": "^2.1",
"phpunit/phpunit": "^5 || ^6.5"
},
"type": "library",
"autoload": {
"files": [
"src/getallheaders.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Ralph Khattar",
"email": "ralph.khattar@gmail.com"
}
],
"description": "A polyfill for getallheaders.",
"support": {
"issues": "https://github.com/ralouphie/getallheaders/issues",
"source": "https://github.com/ralouphie/getallheaders/tree/develop"
},
"time": "2019-03-08T08:55:37+00:00"
},
{
"name": "symfony/deprecation-contracts",
"version": "v3.1.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/deprecation-contracts.git",
"reference": "07f1b9cc2ffee6aaafcf4b710fbc38ff736bd918"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/07f1b9cc2ffee6aaafcf4b710fbc38ff736bd918",
"reference": "07f1b9cc2ffee6aaafcf4b710fbc38ff736bd918",
"shasum": ""
},
"require": {
"php": ">=8.1"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "3.1-dev"
},
"thanks": {
"name": "symfony/contracts",
"url": "https://github.com/symfony/contracts"
}
},
"autoload": {
"files": [
"function.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Nicolas Grekas",
"email": "p@tchwork.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "A generic function and convention to trigger deprecation notices",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/deprecation-contracts/tree/v3.1.1"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2022-02-25T11:15:52+00:00"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"prefer-stable": false,
"prefer-lowest": false,
"platform": {
"php": "^8.1"
},
"platform-dev": [],
"plugin-api-version": "2.3.0"
}

View File

@ -4,8 +4,9 @@ declare(strict_types=1);
namespace mirzaev\vk\chat;
// Встроенные библиотеки
use Closure;
// Файлы проекта
use mirzaev\vk\chat\core,
mirzaev\vk\chat\program;
/**
* Команда
@ -15,43 +16,77 @@ use Closure;
*/
class command
{
/**
* @var array $programs Программы
*/
protected array $programs = [];
/**
* Конструктор
*
* @param callable $program Программа выполняемая командой
* @param array $accounts Реестр аккаунтов которым разрешено выполнять команду
* @param string $text Текст
*/
public function __construct(
public Closure $program,
public array $accounts = []
) {
public function __construct(public string $text)
{
}
/**
* Проверить наличие доступа к команде
* Записать программу в реестр
*
* @param int $id Идентификатор аккаунта
* @param program $program Инстанция программы
*
* @return bool Имеет ли аккаунт доступ к команде?
* @return static
*/
public function access(int $id): bool
public function program(program $program): static
{
// Перебор реестра аккаунтов
foreach ($this->accounts as $account) if ($account === $id) return true;
// Запись в реестр
$this->programs[] = $program;
return false;
return $this;
}
/**
* Выполнить команду
* Проверить текст на совпадение с шаблоном
*
* @param array $update Событие
* @param string ...$parameters Параметры команды
* @param string $text Текст
* @param array &$parameters Буфер параметров для программы
*
* @return bool
* @return bool Текст совпадает с шаблоном?
*/
public function execute(array $update, string ...$parameters): mixed
public function check(string $text, array &$parameters = []): bool
{
return call_user_func($this->program, $update, ...$parameters);
// Проверка на совпадение с шаблоном
preg_match_all($this->text, $text, $matches, PREG_PATTERN_ORDER);
// Проверка на нахождение
if (empty($matches[0])) return false;
// Генерация параметров
for ($i = 0, $count = count($matches) + 1; $i <= $count; $i++) foreach ($matches ?? [] as $match) if (!empty($match[$i])) $parameters[] = $match[$i];
return true;
}
/**
* Обработать подключенные программы
*
* @param core $core Ядро модуля
* @param int $id Идентификатор аккаунта вызывающего выполнение
* @param array &$update Событие
* @param string ...$parameters Параметры программы
*
* @return void
*/
public function handle(core $core, int $id, array &$update, string ...$parameters): void
{
foreach ($this->programs as $program) {
// Перебор программ
// Авторизация
if (!empty($program->accounts) && !$program->access($id)) return;
// Выполнение программы
$program->execute($core, $update, ...$parameters);
}
}
}

View File

@ -5,8 +5,11 @@ declare(strict_types=1);
namespace mirzaev\vk\chat;
// Файлы проекта
use mirzaev\vk\chat\pattern,
mirzaev\vk\chat\command;
use mirzaev\vk\chat\command,
mirzaev\vk\chat\program;
// Фреймворк ВКонтакте
use mirzaev\vk\api\methods\messages;
/**
* Ядро
@ -22,70 +25,140 @@ class core
protected ?string $prefix;
/**
* @var array $patterns Реестр шаблонов
* @var array $commands Реестр команд
*/
protected array $patterns = [];
protected array $commands = [];
/**
* Записать шаблон в реестр
*
* @param string|pattern $pattern Текст или инстанция шаблона
* @param command ...$commands Команды
*
* @return pattern Инстанция шаблона
* @var array $commands Реестр сообщений для отправки
*/
public function pattern(string|pattern $pattern, command ...$commands): pattern
protected array $messages = [];
/**
* @var bool $break Завершить выполнение?
*/
protected bool $break = false;
/**
* Записать команду в реестр
*
* @param string|command $command Текст или инстанция команды
* @param program ...$programs Программы
*
* @return command Инстанция команда
*/
public function command(string|command $command, program ...$programs): command
{
// Инициализация шаблона
if (is_string($pattern)) $pattern = new pattern($pattern);
// Инициализация команды
if (is_string($command)) $command = new command($command);
foreach ($commands as $command) {
// Перебор команд
foreach ($programs as $program) {
// Перебор программ
// Подключение команд к шаблону
$pattern->command($command);
// Подключение программ к команде
$command->program($program);
}
// Запись в реестр
$this->patterns []= $pattern;
$this->commands[] = $command;
return $pattern;
return $command;
}
/**
* Обработать сообщение
*
* Проверяет наличие совпадений с шаблонами, после чего проверяет
* все связанные с шаблоном команды и выполняет при совпадении
* Проверяет наличие совпадений с командами, после чего проверяет
* все связанные с командой программы и выполняет при совпадении
*
* @param array $update Событие
* @param array &$update Событие
*
* @return bool Статус сохранения
* @return bool Работа выполнена без ошибок?
*/
public function handle(array $update): bool
public function handle(array &$update): bool
{
// Инициализация текста
$text = $update['object']['message']['text'];
$text = &$update['object']['message']['text'];
// Проверка на наличие текста и на использование префикса
if (empty($text) or isset($this->prefix) && !str_starts_with($text, $this->prefix)) return false;
foreach ($this->patterns as $pattern) {
// Перебор шаблонов
foreach ($this->commands as $command) {
// Перебор команд
// Проверка на запрос завершения выполнения
if ($this->break) break;
// Инициализация буфера параметров
$parameters = [];
if($pattern->check($text, $parameters)) {
// Пройдена проверка на совпадение с шаблоном
if ($command->check($text, $parameters)) {
// Пройдена проверка на совпадение с командой
// Выполнение команд связанных с шаблоном
$pattern->handle($update['object']['message']['from_id'], $update, ...$parameters);
return true;
// Выполнение программ связанных с командой
$command->handle($this, $update['object']['message']['from_id'], $update, ...$parameters);
}
}
return false;
// Отправка сообщений
foreach ($this->messages as $key => $message) {
// Перебор сообщений
if (is_array($message)) {
// Группа сообщений
foreach ($message as $_key => $_message) {
// Перебор сообщений в группе
// Отправка сообщения
$_message->send();
// Удаление сообщения из реестра
unset($this->messages[$key][$_key]);
}
} else {
// Сообщение (подрзумевается)
// Отправка сообщения
$message->send();
// Удаление сообщения из реестра
unset($this->messages[$key]);
}
}
// Реинициализация блокировщика
$this->break = false;
return true;
}
/**
* Инициализировать сообщение
*
* Сообщение будет передано в последующие программы для обработки, а
* после завершения работы всех команд выполнится отправка
*
* @param messages $message Инстанция сообщения
* @param ?string $category Категория
*
* @return void
*/
public function message(messages $message, ?string $category = null): void
{
if (isset($category) && $this->messages[$category] = []) $this->messages[$category][] = $message;
else $this->messages[] = $message;
}
/**
* Завершить работу ядра
*
* Вместо обработки следующей команды работы ядра будет завершена
*
* @return void
*/
public function break(): void
{
$this->break = true;
}
}

View File

@ -1,93 +0,0 @@
<?php
declare(strict_types=1);
namespace mirzaev\vk\chat;
// Файлы проекта
use mirzaev\vk\chat\command;
/**
* Шаблон
*
* @package mirzaev\vk\chat
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/
class pattern
{
/**
* @var array $commands Команды
*/
protected array $commands = [];
/**
* Конструктор
*
* @param string $text Текст
*/
public function __construct(public string $text)
{
}
/**
* Записать команду в реестр
*
* @param command $command Инстанция команды
*
* @return static
*/
public function command(command $command): static
{
// Запись в реестр
$this->commands []= $command;
return $this;
}
/**
* Проверить текст на совпадение с шаблоном
*
* @param string $text Текст
* @param array &$parameters Буфер параметров для команды
*
* @return bool Текст совпадает с шаблоном?
*/
public function check(string $text, array &$parameters = []): bool
{
// Проверка на совпадение с шаблоном
preg_match_all($this->text, $text, $matches, PREG_PATTERN_ORDER);
// Простой шаблон
if (count($matches) === 1) return !empty($matches[0]);
// Удаление первого значения (текст для проверки)
unset($matches[0]);
// Сложный шаблон
foreach ($matches as $match) if (isset($match[0])) $parameters []= $match[0]; else return false;
return true;
}
/**
* Обработать подключенные команды
*
* @param int $id Идентификатор аккаунта вызывающего выполнение
* @param array $update Событие
* @param string ...$parameters Параметры команды
*
* @return void
*/
public function handle(int $id, array $update, string ...$parameters): void
{
foreach ($this->commands as $command) {
// Перебор команд
// Авторизация
if (!empty($command->accounts) && !$command->access($id)) return;
// Выполнение команды
$command->execute($update, ...$parameters);
}
}
}

View File

@ -0,0 +1,63 @@
<?php
declare(strict_types=1);
namespace mirzaev\vk\chat;
// Фреймворк ВКонтакте
use mirzaev\vk\robots\robot;
// Встроенные библиотеки
use Closure;
/**
* Программа
*
* @package mirzaev\vk\chat
* @author Arsen Mirzaev Tatyano-Muradovich <arsen@mirzaev.sexy>
*/
class program
{
/**
* Конструктор
*
* @param callable $program Программа выполняемая командой
* @param robot $robot Робот, который будет выполнять команду
* @param array $accounts Реестр аккаунтов которым разрешено выполнять команду
*/
public function __construct(
public Closure $program,
public robot $robot,
public array $accounts = []
) {
}
/**
* Проверить наличие доступа к команде
*
* @param int $id Идентификатор аккаунта
*
* @return bool Имеет ли аккаунт доступ к команде?
*/
public function access(int $id): bool
{
// Перебор реестра аккаунтов
foreach ($this->accounts as $account) if ($account === $id) return true;
return false;
}
/**
* Выполнить команду
*
* @param core $core Ядро модуля
* @param array &$update Событие
* @param string ...$parameters Параметры команды
*
* @return mixed
*/
public function execute(core $core, array &$update, string ...$parameters): mixed
{
return call_user_func_array($this->program, [$core, $this->robot, &$update, ...$parameters]);
}
}