Исправление ошибок
This commit is contained in:
parent
469838cdcd
commit
f35046339e
|
@ -8,22 +8,22 @@
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "guzzlehttp/guzzle",
|
"name": "guzzlehttp/guzzle",
|
||||||
"version": "7.2.0",
|
"version": "7.3.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/guzzle/guzzle.git",
|
"url": "https://github.com/guzzle/guzzle.git",
|
||||||
"reference": "0aa74dfb41ae110835923ef10a9d803a22d50e79"
|
"reference": "7008573787b430c1c1f650e3722d9bba59967628"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/0aa74dfb41ae110835923ef10a9d803a22d50e79",
|
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/7008573787b430c1c1f650e3722d9bba59967628",
|
||||||
"reference": "0aa74dfb41ae110835923ef10a9d803a22d50e79",
|
"reference": "7008573787b430c1c1f650e3722d9bba59967628",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"ext-json": "*",
|
"ext-json": "*",
|
||||||
"guzzlehttp/promises": "^1.4",
|
"guzzlehttp/promises": "^1.4",
|
||||||
"guzzlehttp/psr7": "^1.7",
|
"guzzlehttp/psr7": "^1.7 || ^2.0",
|
||||||
"php": "^7.2.5 || ^8.0",
|
"php": "^7.2.5 || ^8.0",
|
||||||
"psr/http-client": "^1.0"
|
"psr/http-client": "^1.0"
|
||||||
},
|
},
|
||||||
|
@ -31,6 +31,7 @@
|
||||||
"psr/http-client-implementation": "1.0"
|
"psr/http-client-implementation": "1.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
|
"bamarni/composer-bin-plugin": "^1.4.1",
|
||||||
"ext-curl": "*",
|
"ext-curl": "*",
|
||||||
"php-http/client-integration-tests": "^3.0",
|
"php-http/client-integration-tests": "^3.0",
|
||||||
"phpunit/phpunit": "^8.5.5 || ^9.3.5",
|
"phpunit/phpunit": "^8.5.5 || ^9.3.5",
|
||||||
|
@ -44,7 +45,7 @@
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "7.1-dev"
|
"dev-master": "7.3-dev"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
|
@ -84,6 +85,10 @@
|
||||||
"rest",
|
"rest",
|
||||||
"web service"
|
"web service"
|
||||||
],
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/guzzle/guzzle/issues",
|
||||||
|
"source": "https://github.com/guzzle/guzzle/tree/7.3.0"
|
||||||
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"url": "https://github.com/GrahamCampbell",
|
"url": "https://github.com/GrahamCampbell",
|
||||||
|
@ -102,7 +107,7 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2020-10-10T11:47:56+00:00"
|
"time": "2021-03-23T11:33:13+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "guzzlehttp/promises",
|
"name": "guzzlehttp/promises",
|
||||||
|
@ -153,20 +158,24 @@
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"promise"
|
"promise"
|
||||||
],
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/guzzle/promises/issues",
|
||||||
|
"source": "https://github.com/guzzle/promises/tree/1.4.1"
|
||||||
|
},
|
||||||
"time": "2021-03-07T09:25:29+00:00"
|
"time": "2021-03-07T09:25:29+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "guzzlehttp/psr7",
|
"name": "guzzlehttp/psr7",
|
||||||
"version": "1.7.0",
|
"version": "1.8.1",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/guzzle/psr7.git",
|
"url": "https://github.com/guzzle/psr7.git",
|
||||||
"reference": "53330f47520498c0ae1f61f7e2c90f55690c06a3"
|
"reference": "35ea11d335fd638b5882ff1725228b3d35496ab1"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/guzzle/psr7/zipball/53330f47520498c0ae1f61f7e2c90f55690c06a3",
|
"url": "https://api.github.com/repos/guzzle/psr7/zipball/35ea11d335fd638b5882ff1725228b3d35496ab1",
|
||||||
"reference": "53330f47520498c0ae1f61f7e2c90f55690c06a3",
|
"reference": "35ea11d335fd638b5882ff1725228b3d35496ab1",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -224,7 +233,11 @@
|
||||||
"uri",
|
"uri",
|
||||||
"url"
|
"url"
|
||||||
],
|
],
|
||||||
"time": "2020-09-30T07:37:11+00:00"
|
"support": {
|
||||||
|
"issues": "https://github.com/guzzle/psr7/issues",
|
||||||
|
"source": "https://github.com/guzzle/psr7/tree/1.8.1"
|
||||||
|
},
|
||||||
|
"time": "2021-03-21T16:25:00+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "hood/accounts",
|
"name": "hood/accounts",
|
||||||
|
@ -268,6 +281,11 @@
|
||||||
"hood",
|
"hood",
|
||||||
"vk"
|
"vk"
|
||||||
],
|
],
|
||||||
|
"support": {
|
||||||
|
"chat": "https://vk.me/darkweb228",
|
||||||
|
"docs": "https://git.hood.su/hood/accounts/manual",
|
||||||
|
"issues": "https://git.hood.su/hood/accounts/issues"
|
||||||
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"url": "https://git.hood.su/hood/accounts/thanks",
|
"url": "https://git.hood.su/hood/accounts/thanks",
|
||||||
|
@ -322,6 +340,10 @@
|
||||||
"exception handler",
|
"exception handler",
|
||||||
"middleware"
|
"middleware"
|
||||||
],
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/jasny/error-handler/issues",
|
||||||
|
"source": "https://github.com/jasny/error-handler"
|
||||||
|
},
|
||||||
"abandoned": true,
|
"abandoned": true,
|
||||||
"time": "2017-01-25T01:27:18+00:00"
|
"time": "2017-01-25T01:27:18+00:00"
|
||||||
},
|
},
|
||||||
|
@ -395,6 +417,10 @@
|
||||||
"logging",
|
"logging",
|
||||||
"psr-3"
|
"psr-3"
|
||||||
],
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/Seldaek/monolog/issues",
|
||||||
|
"source": "https://github.com/Seldaek/monolog/tree/1.26.0"
|
||||||
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"url": "https://github.com/Seldaek",
|
"url": "https://github.com/Seldaek",
|
||||||
|
@ -454,6 +480,9 @@
|
||||||
"psr",
|
"psr",
|
||||||
"psr-18"
|
"psr-18"
|
||||||
],
|
],
|
||||||
|
"support": {
|
||||||
|
"source": "https://github.com/php-fig/http-client/tree/master"
|
||||||
|
},
|
||||||
"time": "2020-06-29T06:28:15+00:00"
|
"time": "2020-06-29T06:28:15+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -504,6 +533,9 @@
|
||||||
"request",
|
"request",
|
||||||
"response"
|
"response"
|
||||||
],
|
],
|
||||||
|
"support": {
|
||||||
|
"source": "https://github.com/php-fig/http-message/tree/master"
|
||||||
|
},
|
||||||
"time": "2016-08-06T14:39:51+00:00"
|
"time": "2016-08-06T14:39:51+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -551,6 +583,9 @@
|
||||||
"psr",
|
"psr",
|
||||||
"psr-3"
|
"psr-3"
|
||||||
],
|
],
|
||||||
|
"support": {
|
||||||
|
"source": "https://github.com/php-fig/log/tree/1.1.3"
|
||||||
|
},
|
||||||
"time": "2020-03-23T09:12:05+00:00"
|
"time": "2020-03-23T09:12:05+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -591,6 +626,10 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "A polyfill for getallheaders.",
|
"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"
|
"time": "2019-03-08T08:55:37+00:00"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -644,6 +683,10 @@
|
||||||
"constructor",
|
"constructor",
|
||||||
"instantiate"
|
"instantiate"
|
||||||
],
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/doctrine/instantiator/issues",
|
||||||
|
"source": "https://github.com/doctrine/instantiator/tree/1.4.0"
|
||||||
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"url": "https://www.doctrine-project.org/sponsorship.html",
|
"url": "https://www.doctrine-project.org/sponsorship.html",
|
||||||
|
@ -706,6 +749,10 @@
|
||||||
"object",
|
"object",
|
||||||
"object graph"
|
"object graph"
|
||||||
],
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/myclabs/DeepCopy/issues",
|
||||||
|
"source": "https://github.com/myclabs/DeepCopy/tree/1.10.2"
|
||||||
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy",
|
"url": "https://tidelift.com/funding/github/packagist/myclabs/deep-copy",
|
||||||
|
@ -764,6 +811,10 @@
|
||||||
"parser",
|
"parser",
|
||||||
"php"
|
"php"
|
||||||
],
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/nikic/PHP-Parser/issues",
|
||||||
|
"source": "https://github.com/nikic/PHP-Parser/tree/v4.10.4"
|
||||||
|
},
|
||||||
"time": "2020-12-20T10:01:03+00:00"
|
"time": "2020-12-20T10:01:03+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -820,6 +871,10 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)",
|
"description": "Component for reading phar.io manifest information from a PHP Archive (PHAR)",
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/phar-io/manifest/issues",
|
||||||
|
"source": "https://github.com/phar-io/manifest/tree/master"
|
||||||
|
},
|
||||||
"time": "2020-06-27T14:33:11+00:00"
|
"time": "2020-06-27T14:33:11+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -867,6 +922,10 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "Library for handling version information and constraints",
|
"description": "Library for handling version information and constraints",
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/phar-io/version/issues",
|
||||||
|
"source": "https://github.com/phar-io/version/tree/3.1.0"
|
||||||
|
},
|
||||||
"time": "2021-02-23T14:00:09+00:00"
|
"time": "2021-02-23T14:00:09+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -916,6 +975,10 @@
|
||||||
"reflection",
|
"reflection",
|
||||||
"static analysis"
|
"static analysis"
|
||||||
],
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/phpDocumentor/ReflectionCommon/issues",
|
||||||
|
"source": "https://github.com/phpDocumentor/ReflectionCommon/tree/2.x"
|
||||||
|
},
|
||||||
"time": "2020-06-27T09:03:43+00:00"
|
"time": "2020-06-27T09:03:43+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -968,6 +1031,10 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.",
|
"description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.",
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues",
|
||||||
|
"source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/master"
|
||||||
|
},
|
||||||
"time": "2020-09-03T19:13:55+00:00"
|
"time": "2020-09-03T19:13:55+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -1013,20 +1080,24 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "A PSR-5 based resolver of Class names, Types and Structural Element Names",
|
"description": "A PSR-5 based resolver of Class names, Types and Structural Element Names",
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/phpDocumentor/TypeResolver/issues",
|
||||||
|
"source": "https://github.com/phpDocumentor/TypeResolver/tree/1.4.0"
|
||||||
|
},
|
||||||
"time": "2020-09-17T18:55:26+00:00"
|
"time": "2020-09-17T18:55:26+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phpspec/prophecy",
|
"name": "phpspec/prophecy",
|
||||||
"version": "1.12.2",
|
"version": "1.13.0",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/phpspec/prophecy.git",
|
"url": "https://github.com/phpspec/prophecy.git",
|
||||||
"reference": "245710e971a030f42e08f4912863805570f23d39"
|
"reference": "be1996ed8adc35c3fd795488a653f4b518be70ea"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/245710e971a030f42e08f4912863805570f23d39",
|
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/be1996ed8adc35c3fd795488a653f4b518be70ea",
|
||||||
"reference": "245710e971a030f42e08f4912863805570f23d39",
|
"reference": "be1996ed8adc35c3fd795488a653f4b518be70ea",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -1076,20 +1147,24 @@
|
||||||
"spy",
|
"spy",
|
||||||
"stub"
|
"stub"
|
||||||
],
|
],
|
||||||
"time": "2020-12-19T10:15:11+00:00"
|
"support": {
|
||||||
|
"issues": "https://github.com/phpspec/prophecy/issues",
|
||||||
|
"source": "https://github.com/phpspec/prophecy/tree/1.13.0"
|
||||||
|
},
|
||||||
|
"time": "2021-03-17T13:42:18+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phpunit/php-code-coverage",
|
"name": "phpunit/php-code-coverage",
|
||||||
"version": "9.2.5",
|
"version": "9.2.6",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
|
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
|
||||||
"reference": "f3e026641cc91909d421802dd3ac7827ebfd97e1"
|
"reference": "f6293e1b30a2354e8428e004689671b83871edde"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/f3e026641cc91909d421802dd3ac7827ebfd97e1",
|
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/f6293e1b30a2354e8428e004689671b83871edde",
|
||||||
"reference": "f3e026641cc91909d421802dd3ac7827ebfd97e1",
|
"reference": "f6293e1b30a2354e8428e004689671b83871edde",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -1143,13 +1218,17 @@
|
||||||
"testing",
|
"testing",
|
||||||
"xunit"
|
"xunit"
|
||||||
],
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/sebastianbergmann/php-code-coverage/issues",
|
||||||
|
"source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.6"
|
||||||
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"url": "https://github.com/sebastianbergmann",
|
"url": "https://github.com/sebastianbergmann",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2020-11-28T06:44:49+00:00"
|
"time": "2021-03-28T07:26:59+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phpunit/php-file-iterator",
|
"name": "phpunit/php-file-iterator",
|
||||||
|
@ -1199,6 +1278,10 @@
|
||||||
"filesystem",
|
"filesystem",
|
||||||
"iterator"
|
"iterator"
|
||||||
],
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/sebastianbergmann/php-file-iterator/issues",
|
||||||
|
"source": "https://github.com/sebastianbergmann/php-file-iterator/tree/3.0.5"
|
||||||
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"url": "https://github.com/sebastianbergmann",
|
"url": "https://github.com/sebastianbergmann",
|
||||||
|
@ -1258,6 +1341,10 @@
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"process"
|
"process"
|
||||||
],
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/sebastianbergmann/php-invoker/issues",
|
||||||
|
"source": "https://github.com/sebastianbergmann/php-invoker/tree/3.1.1"
|
||||||
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"url": "https://github.com/sebastianbergmann",
|
"url": "https://github.com/sebastianbergmann",
|
||||||
|
@ -1313,6 +1400,10 @@
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"template"
|
"template"
|
||||||
],
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/sebastianbergmann/php-text-template/issues",
|
||||||
|
"source": "https://github.com/sebastianbergmann/php-text-template/tree/2.0.4"
|
||||||
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"url": "https://github.com/sebastianbergmann",
|
"url": "https://github.com/sebastianbergmann",
|
||||||
|
@ -1368,6 +1459,10 @@
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"timer"
|
"timer"
|
||||||
],
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/sebastianbergmann/php-timer/issues",
|
||||||
|
"source": "https://github.com/sebastianbergmann/php-timer/tree/5.0.3"
|
||||||
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"url": "https://github.com/sebastianbergmann",
|
"url": "https://github.com/sebastianbergmann",
|
||||||
|
@ -1378,16 +1473,16 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "phpunit/phpunit",
|
"name": "phpunit/phpunit",
|
||||||
"version": "9.5.2",
|
"version": "9.5.4",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/sebastianbergmann/phpunit.git",
|
"url": "https://github.com/sebastianbergmann/phpunit.git",
|
||||||
"reference": "f661659747f2f87f9e72095bb207bceb0f151cb4"
|
"reference": "c73c6737305e779771147af66c96ca6a7ed8a741"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/f661659747f2f87f9e72095bb207bceb0f151cb4",
|
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/c73c6737305e779771147af66c96ca6a7ed8a741",
|
||||||
"reference": "f661659747f2f87f9e72095bb207bceb0f151cb4",
|
"reference": "c73c6737305e779771147af66c96ca6a7ed8a741",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -1463,6 +1558,10 @@
|
||||||
"testing",
|
"testing",
|
||||||
"xunit"
|
"xunit"
|
||||||
],
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
|
||||||
|
"source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.4"
|
||||||
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"url": "https://phpunit.de/donate.html",
|
"url": "https://phpunit.de/donate.html",
|
||||||
|
@ -1473,7 +1572,7 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"time": "2021-02-02T14:45:58+00:00"
|
"time": "2021-03-23T07:16:29+00:00"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "sebastian/cli-parser",
|
"name": "sebastian/cli-parser",
|
||||||
|
@ -1519,6 +1618,10 @@
|
||||||
],
|
],
|
||||||
"description": "Library for parsing CLI options",
|
"description": "Library for parsing CLI options",
|
||||||
"homepage": "https://github.com/sebastianbergmann/cli-parser",
|
"homepage": "https://github.com/sebastianbergmann/cli-parser",
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/sebastianbergmann/cli-parser/issues",
|
||||||
|
"source": "https://github.com/sebastianbergmann/cli-parser/tree/1.0.1"
|
||||||
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"url": "https://github.com/sebastianbergmann",
|
"url": "https://github.com/sebastianbergmann",
|
||||||
|
@ -1571,6 +1674,10 @@
|
||||||
],
|
],
|
||||||
"description": "Collection of value objects that represent the PHP code units",
|
"description": "Collection of value objects that represent the PHP code units",
|
||||||
"homepage": "https://github.com/sebastianbergmann/code-unit",
|
"homepage": "https://github.com/sebastianbergmann/code-unit",
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/sebastianbergmann/code-unit/issues",
|
||||||
|
"source": "https://github.com/sebastianbergmann/code-unit/tree/1.0.8"
|
||||||
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"url": "https://github.com/sebastianbergmann",
|
"url": "https://github.com/sebastianbergmann",
|
||||||
|
@ -1622,6 +1729,10 @@
|
||||||
],
|
],
|
||||||
"description": "Looks up which function or method a line of code belongs to",
|
"description": "Looks up which function or method a line of code belongs to",
|
||||||
"homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/",
|
"homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/",
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/issues",
|
||||||
|
"source": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/tree/2.0.3"
|
||||||
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"url": "https://github.com/sebastianbergmann",
|
"url": "https://github.com/sebastianbergmann",
|
||||||
|
@ -1692,6 +1803,10 @@
|
||||||
"compare",
|
"compare",
|
||||||
"equality"
|
"equality"
|
||||||
],
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/sebastianbergmann/comparator/issues",
|
||||||
|
"source": "https://github.com/sebastianbergmann/comparator/tree/4.0.6"
|
||||||
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"url": "https://github.com/sebastianbergmann",
|
"url": "https://github.com/sebastianbergmann",
|
||||||
|
@ -1745,6 +1860,10 @@
|
||||||
],
|
],
|
||||||
"description": "Library for calculating the complexity of PHP code units",
|
"description": "Library for calculating the complexity of PHP code units",
|
||||||
"homepage": "https://github.com/sebastianbergmann/complexity",
|
"homepage": "https://github.com/sebastianbergmann/complexity",
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/sebastianbergmann/complexity/issues",
|
||||||
|
"source": "https://github.com/sebastianbergmann/complexity/tree/2.0.2"
|
||||||
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"url": "https://github.com/sebastianbergmann",
|
"url": "https://github.com/sebastianbergmann",
|
||||||
|
@ -1807,6 +1926,10 @@
|
||||||
"unidiff",
|
"unidiff",
|
||||||
"unified diff"
|
"unified diff"
|
||||||
],
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/sebastianbergmann/diff/issues",
|
||||||
|
"source": "https://github.com/sebastianbergmann/diff/tree/4.0.4"
|
||||||
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"url": "https://github.com/sebastianbergmann",
|
"url": "https://github.com/sebastianbergmann",
|
||||||
|
@ -1866,6 +1989,10 @@
|
||||||
"environment",
|
"environment",
|
||||||
"hhvm"
|
"hhvm"
|
||||||
],
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/sebastianbergmann/environment/issues",
|
||||||
|
"source": "https://github.com/sebastianbergmann/environment/tree/5.1.3"
|
||||||
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"url": "https://github.com/sebastianbergmann",
|
"url": "https://github.com/sebastianbergmann",
|
||||||
|
@ -1939,6 +2066,10 @@
|
||||||
"export",
|
"export",
|
||||||
"exporter"
|
"exporter"
|
||||||
],
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/sebastianbergmann/exporter/issues",
|
||||||
|
"source": "https://github.com/sebastianbergmann/exporter/tree/4.0.3"
|
||||||
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"url": "https://github.com/sebastianbergmann",
|
"url": "https://github.com/sebastianbergmann",
|
||||||
|
@ -1999,6 +2130,10 @@
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"global state"
|
"global state"
|
||||||
],
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/sebastianbergmann/global-state/issues",
|
||||||
|
"source": "https://github.com/sebastianbergmann/global-state/tree/5.0.2"
|
||||||
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"url": "https://github.com/sebastianbergmann",
|
"url": "https://github.com/sebastianbergmann",
|
||||||
|
@ -2052,6 +2187,10 @@
|
||||||
],
|
],
|
||||||
"description": "Library for counting the lines of code in PHP source code",
|
"description": "Library for counting the lines of code in PHP source code",
|
||||||
"homepage": "https://github.com/sebastianbergmann/lines-of-code",
|
"homepage": "https://github.com/sebastianbergmann/lines-of-code",
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/sebastianbergmann/lines-of-code/issues",
|
||||||
|
"source": "https://github.com/sebastianbergmann/lines-of-code/tree/1.0.3"
|
||||||
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"url": "https://github.com/sebastianbergmann",
|
"url": "https://github.com/sebastianbergmann",
|
||||||
|
@ -2105,6 +2244,10 @@
|
||||||
],
|
],
|
||||||
"description": "Traverses array structures and object graphs to enumerate all referenced objects",
|
"description": "Traverses array structures and object graphs to enumerate all referenced objects",
|
||||||
"homepage": "https://github.com/sebastianbergmann/object-enumerator/",
|
"homepage": "https://github.com/sebastianbergmann/object-enumerator/",
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/sebastianbergmann/object-enumerator/issues",
|
||||||
|
"source": "https://github.com/sebastianbergmann/object-enumerator/tree/4.0.4"
|
||||||
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"url": "https://github.com/sebastianbergmann",
|
"url": "https://github.com/sebastianbergmann",
|
||||||
|
@ -2156,6 +2299,10 @@
|
||||||
],
|
],
|
||||||
"description": "Allows reflection of object attributes, including inherited and non-public ones",
|
"description": "Allows reflection of object attributes, including inherited and non-public ones",
|
||||||
"homepage": "https://github.com/sebastianbergmann/object-reflector/",
|
"homepage": "https://github.com/sebastianbergmann/object-reflector/",
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/sebastianbergmann/object-reflector/issues",
|
||||||
|
"source": "https://github.com/sebastianbergmann/object-reflector/tree/2.0.4"
|
||||||
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"url": "https://github.com/sebastianbergmann",
|
"url": "https://github.com/sebastianbergmann",
|
||||||
|
@ -2215,6 +2362,10 @@
|
||||||
],
|
],
|
||||||
"description": "Provides functionality to recursively process PHP variables",
|
"description": "Provides functionality to recursively process PHP variables",
|
||||||
"homepage": "http://www.github.com/sebastianbergmann/recursion-context",
|
"homepage": "http://www.github.com/sebastianbergmann/recursion-context",
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/sebastianbergmann/recursion-context/issues",
|
||||||
|
"source": "https://github.com/sebastianbergmann/recursion-context/tree/4.0.4"
|
||||||
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"url": "https://github.com/sebastianbergmann",
|
"url": "https://github.com/sebastianbergmann",
|
||||||
|
@ -2266,6 +2417,10 @@
|
||||||
],
|
],
|
||||||
"description": "Provides a list of PHP built-in functions that operate on resources",
|
"description": "Provides a list of PHP built-in functions that operate on resources",
|
||||||
"homepage": "https://www.github.com/sebastianbergmann/resource-operations",
|
"homepage": "https://www.github.com/sebastianbergmann/resource-operations",
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/sebastianbergmann/resource-operations/issues",
|
||||||
|
"source": "https://github.com/sebastianbergmann/resource-operations/tree/3.0.3"
|
||||||
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"url": "https://github.com/sebastianbergmann",
|
"url": "https://github.com/sebastianbergmann",
|
||||||
|
@ -2318,6 +2473,10 @@
|
||||||
],
|
],
|
||||||
"description": "Collection of value objects that represent the types of the PHP type system",
|
"description": "Collection of value objects that represent the types of the PHP type system",
|
||||||
"homepage": "https://github.com/sebastianbergmann/type",
|
"homepage": "https://github.com/sebastianbergmann/type",
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/sebastianbergmann/type/issues",
|
||||||
|
"source": "https://github.com/sebastianbergmann/type/tree/2.3.1"
|
||||||
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"url": "https://github.com/sebastianbergmann",
|
"url": "https://github.com/sebastianbergmann",
|
||||||
|
@ -2367,6 +2526,10 @@
|
||||||
],
|
],
|
||||||
"description": "Library that helps with managing the version number of Git-hosted PHP projects",
|
"description": "Library that helps with managing the version number of Git-hosted PHP projects",
|
||||||
"homepage": "https://github.com/sebastianbergmann/version",
|
"homepage": "https://github.com/sebastianbergmann/version",
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/sebastianbergmann/version/issues",
|
||||||
|
"source": "https://github.com/sebastianbergmann/version/tree/3.0.2"
|
||||||
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"url": "https://github.com/sebastianbergmann",
|
"url": "https://github.com/sebastianbergmann",
|
||||||
|
@ -2435,6 +2598,9 @@
|
||||||
"polyfill",
|
"polyfill",
|
||||||
"portable"
|
"portable"
|
||||||
],
|
],
|
||||||
|
"support": {
|
||||||
|
"source": "https://github.com/symfony/polyfill-ctype/tree/v1.22.1"
|
||||||
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"url": "https://symfony.com/sponsor",
|
"url": "https://symfony.com/sponsor",
|
||||||
|
@ -2489,6 +2655,10 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "A small library for converting tokenized PHP source code into XML and potentially other formats",
|
"description": "A small library for converting tokenized PHP source code into XML and potentially other formats",
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/theseer/tokenizer/issues",
|
||||||
|
"source": "https://github.com/theseer/tokenizer/tree/master"
|
||||||
|
},
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"url": "https://github.com/theseer",
|
"url": "https://github.com/theseer",
|
||||||
|
@ -2549,6 +2719,10 @@
|
||||||
"check",
|
"check",
|
||||||
"validate"
|
"validate"
|
||||||
],
|
],
|
||||||
|
"support": {
|
||||||
|
"issues": "https://github.com/webmozarts/assert/issues",
|
||||||
|
"source": "https://github.com/webmozarts/assert/tree/1.10.0"
|
||||||
|
},
|
||||||
"time": "2021-03-09T10:59:23+00:00"
|
"time": "2021-03-09T10:59:23+00:00"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
@ -2563,5 +2737,5 @@
|
||||||
"php": "~8.0"
|
"php": "~8.0"
|
||||||
},
|
},
|
||||||
"platform-dev": [],
|
"platform-dev": [],
|
||||||
"plugin-api-version": "1.1.0"
|
"plugin-api-version": "2.0.0"
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,202 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace hood\vk\api;
|
|
||||||
|
|
||||||
use hood\vk\robots\robot;
|
|
||||||
|
|
||||||
use Throwable;
|
|
||||||
use Exception;
|
|
||||||
use ArrayAccess;
|
|
||||||
use GuzzleHttp\Promise\Each;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* API ВКонтакте
|
|
||||||
*
|
|
||||||
* @var robot $robot Робот
|
|
||||||
* @var array $settings Настройки
|
|
||||||
* @var float $version Версия API
|
|
||||||
*/
|
|
||||||
class api implements ArrayAccess
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Конструктор
|
|
||||||
*/
|
|
||||||
public function __construct(
|
|
||||||
protected robot $robot,
|
|
||||||
protected array $settings = [],
|
|
||||||
protected float $version = 5.124
|
|
||||||
) {
|
|
||||||
if (empty($settings)) {
|
|
||||||
// Настройки не получены
|
|
||||||
|
|
||||||
// Инициализация
|
|
||||||
$this->_init();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Инициализация (безопасная)
|
|
||||||
*/
|
|
||||||
public function init(): array
|
|
||||||
{
|
|
||||||
if (!isset($blocked)) {
|
|
||||||
// Нет блокировки (запуск в первый раз)
|
|
||||||
|
|
||||||
// Блокировка
|
|
||||||
static $blocked = true;
|
|
||||||
|
|
||||||
try {
|
|
||||||
$this->_init();
|
|
||||||
} catch (Throwable $t) {
|
|
||||||
throw new Exception('Не удалось инициализировать API', $t->getCode(), $t->getPrevious());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->settings;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Реинициализация
|
|
||||||
*/
|
|
||||||
public function reinit(): array
|
|
||||||
{
|
|
||||||
// Реинициализация
|
|
||||||
//unset($this->settings);
|
|
||||||
$this->settings = [];
|
|
||||||
|
|
||||||
try {
|
|
||||||
$this->_init();
|
|
||||||
} catch (Throwable $t) {
|
|
||||||
throw new Exception('Не удалось инициализировать API', $t->getCode(), $t->getPrevious());
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->settings;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Инициализация
|
|
||||||
*/
|
|
||||||
protected function _init(): void
|
|
||||||
{
|
|
||||||
// Ключ
|
|
||||||
$this->settings['access_token'] = $this->robot->key;
|
|
||||||
|
|
||||||
// Версия API
|
|
||||||
$this->settings['v'] = $this->version;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Выбрать получателя
|
|
||||||
*
|
|
||||||
* Определяет получателей по входным параметрам
|
|
||||||
*
|
|
||||||
* @see hood\vk\api\methods\messages Сообщения
|
|
||||||
*/
|
|
||||||
public function chooseDestination(string|array|int $destination): void
|
|
||||||
{
|
|
||||||
if (is_int($destination)) {
|
|
||||||
// Идентификатор
|
|
||||||
|
|
||||||
$this->settings['peer_id'] = $destination;
|
|
||||||
} else if (is_array($destination)) {
|
|
||||||
// Идентификаторы
|
|
||||||
|
|
||||||
$this->settings['user_ids'] = $destination;
|
|
||||||
} else {
|
|
||||||
// Домен
|
|
||||||
|
|
||||||
$this->settings['domain'] = $destination;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Записать свойство
|
|
||||||
*
|
|
||||||
* @param string $name Название
|
|
||||||
* @param mixed $value Значение
|
|
||||||
*/
|
|
||||||
public function __set(string $name, mixed $value): void
|
|
||||||
{
|
|
||||||
match ($name) {
|
|
||||||
'settings' => !isset($this->settings) ? $this->settings = $value : throw new Exception('Запрещено перезаписывать настройки'),
|
|
||||||
'robot' => !isset($this->robot) ? $this->robot = $value : throw new Exception('Запрещено перезаписывать Робота'),
|
|
||||||
default => $this->settings[$name] = $value
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Прочитать свойство
|
|
||||||
*
|
|
||||||
* @param string $name Название
|
|
||||||
*/
|
|
||||||
public function __get(string $name): mixed
|
|
||||||
{
|
|
||||||
return match ($name) {
|
|
||||||
'settings' => $this->settings ?? throw new Exception('Настройки не инициализированы'),
|
|
||||||
'robot' => $this->robot,
|
|
||||||
default => $this->settings[$name] ?? throw new Exception('Параметр не найден: settings[\'' . $name . '\']')
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Записать по смещению
|
|
||||||
*/
|
|
||||||
public function offsetSet(mixed $offset, mixed $value): void
|
|
||||||
{
|
|
||||||
if ($offset == 'settings') {
|
|
||||||
!isset($this->settings) ? $this->settings = $value : throw new Exception('Запрещено перезаписывать настройки');
|
|
||||||
} else if (isset($this->settings)) {
|
|
||||||
$this->settings[$offset] = $value;
|
|
||||||
} else {
|
|
||||||
throw new Exception('Настройки не инициализированы');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Прочитать по смещению
|
|
||||||
*/
|
|
||||||
public function offsetGet(mixed $offset): mixed
|
|
||||||
{
|
|
||||||
if ($offset == 'settings' && isset($this->settings)) {
|
|
||||||
return $this->settings;
|
|
||||||
} else if (isset($this->settings)) {
|
|
||||||
if (isset($this->settings[$offset])) {
|
|
||||||
return $this->settings[$offset];
|
|
||||||
} else {
|
|
||||||
throw new Exception('Не найдено: settings[\'' . $offset . '\']');
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
throw new Exception('Настройки не инициализированы');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Проверка существования смещения
|
|
||||||
*/
|
|
||||||
public function offsetExists(mixed $offset): bool
|
|
||||||
{
|
|
||||||
if ($offset == 'settings' && isset($this->settings)) {
|
|
||||||
return isset($this->settings);
|
|
||||||
} else if (isset($this->settings)) {
|
|
||||||
return isset($this->settings[$offset]);
|
|
||||||
} else {
|
|
||||||
throw new Exception('Настройки не инициализированы');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Удалить по смещению
|
|
||||||
*/
|
|
||||||
public function offsetUnset(mixed $offset): void
|
|
||||||
{
|
|
||||||
if ($offset == 'settings' && isset($this->settings)) {
|
|
||||||
unset($this->settings);
|
|
||||||
} else if (isset($this->settings)) {
|
|
||||||
unset($this->settings[$offset]);
|
|
||||||
} else {
|
|
||||||
throw new Exception('Настройки не инициализированы');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,75 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
declare(strict_types=1);
|
|
||||||
|
|
||||||
namespace hood\vk\api;
|
|
||||||
|
|
||||||
use Exception;
|
|
||||||
use hood\vk\robots\robot;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Вложения
|
|
||||||
*/
|
|
||||||
class data
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* @var array $data Вложения
|
|
||||||
*/
|
|
||||||
protected array $data = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Конструктор
|
|
||||||
*
|
|
||||||
* @var robot $robot Робот
|
|
||||||
*/
|
|
||||||
public function __construct(
|
|
||||||
protected robot $robot
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Записать вложения
|
|
||||||
*
|
|
||||||
* @param string|array $data Вложения
|
|
||||||
*
|
|
||||||
* @return self
|
|
||||||
*/
|
|
||||||
public function addData(...$data): self
|
|
||||||
{
|
|
||||||
// Если вложений больше 10
|
|
||||||
if (count($this->data) + count($data) > 10) {
|
|
||||||
throw new Exception('Превышен лимит вложений (10)');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Запись вложений
|
|
||||||
$this->data = array_merge($this->data, $data);
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Очистить вложения
|
|
||||||
*/
|
|
||||||
public function clear(): self
|
|
||||||
{
|
|
||||||
// Очистка вложений
|
|
||||||
$this->data = [];
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Прочитать свойство
|
|
||||||
*
|
|
||||||
* @param string $name Название
|
|
||||||
*
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function __get(string $name): mixed
|
|
||||||
{
|
|
||||||
return match ($name) {
|
|
||||||
'data' => $this->data,
|
|
||||||
default => throw new Exception('Свойство не найдено: ' . $name)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -27,46 +27,43 @@ use hood\vk\robots\group;
|
||||||
final class messages extends method
|
final class messages extends method
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @param int $mode Режим отправки
|
* @var int $mode Режим отправки
|
||||||
*/
|
*/
|
||||||
protected int $mode = 1;
|
protected int $mode = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string|null $text Текст
|
* @var array[int] Сообщения для пересылки
|
||||||
*/
|
*/
|
||||||
|
protected array $forward;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var data Вложения
|
* @var int Сообщение для ответа
|
||||||
*/
|
*/
|
||||||
protected data $data;
|
protected int $reply;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array Пересылаемые сообщения
|
* Конструктор
|
||||||
*/
|
|
||||||
protected array $forwardMessages = [];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @var int $ReplyMessage Ответное сообщение
|
|
||||||
*/
|
|
||||||
protected int $ReplyMessage;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Создать сообщение
|
|
||||||
*
|
*
|
||||||
* @param robot $robot Робот
|
* @param robot $robot Робот
|
||||||
|
* @param string|null $text Текст
|
||||||
|
* @param int|string|array $destination = null
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
protected robot $robot,
|
protected robot $robot,
|
||||||
protected string|null $text = null
|
protected string|null $text = null,
|
||||||
|
int|string|array $destination = null
|
||||||
) {
|
) {
|
||||||
|
if (isset($this->text, $destination)) {
|
||||||
|
// Быстрая отправка
|
||||||
|
|
||||||
|
$this->send($destination);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Записать текст
|
* Записать текст
|
||||||
*
|
*
|
||||||
* @param string $text Текст
|
* @param string $text Текст
|
||||||
*
|
|
||||||
* @return self
|
|
||||||
*/
|
*/
|
||||||
public function text(string $text): self
|
public function text(string $text): self
|
||||||
{
|
{
|
||||||
|
@ -81,84 +78,27 @@ final class messages extends method
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Записать пересылаемые сообщения
|
* Записать сообщения для пересылки
|
||||||
*
|
*
|
||||||
* @param $messageIds id пересылаемых сообщений
|
* @param $ids Идентификаторы сообщений
|
||||||
*
|
|
||||||
* @return self
|
|
||||||
*/
|
*/
|
||||||
public function forward(...$messageIds): self
|
public function forward(...$ids): self
|
||||||
{
|
{
|
||||||
// Запись пересылаемых сообщений
|
// Запись
|
||||||
$this->forwardMessages = array_merge($this->forwardMessages, $messageIds);
|
$this->forward = array_merge($this->forward ?? [], $ids);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Записать ответное сообщение
|
* Записать сообщение для ответа
|
||||||
*
|
*
|
||||||
* @param $messageId id ответного сообщения
|
* @param $id Идентификатор сообщения
|
||||||
*
|
|
||||||
* @return self
|
|
||||||
*/
|
*/
|
||||||
public function reply(int $messageId): self
|
public function reply(int $id): self
|
||||||
{
|
{
|
||||||
// Запись ответного сообщения
|
// Запись
|
||||||
$this->ReplyMessage = $messageId;
|
$this->reply = $id;
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Записать фото
|
|
||||||
*
|
|
||||||
* @param $img Фото
|
|
||||||
*
|
|
||||||
* @return self
|
|
||||||
*/
|
|
||||||
public function image(...$pathPhoto): self
|
|
||||||
{
|
|
||||||
// Перебор фото
|
|
||||||
foreach ($pathPhoto as $photo) {
|
|
||||||
|
|
||||||
// Загрузить фото
|
|
||||||
$id = $this->robot->photo()->getPhoto($photo);
|
|
||||||
|
|
||||||
// Записать к вложениям
|
|
||||||
$this->attachments($id);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Записать вложение
|
|
||||||
*
|
|
||||||
* @param $attachments Вложения
|
|
||||||
*
|
|
||||||
* @return self
|
|
||||||
*/
|
|
||||||
public function attachments(string ...$attachments): self
|
|
||||||
{
|
|
||||||
if (isset($this->data)) {
|
|
||||||
// Если вложения инициализированны
|
|
||||||
|
|
||||||
// Записать вложение
|
|
||||||
foreach ($attachments as $attachment) {
|
|
||||||
$this->data->addData($attachment);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Если вложения не инициализированны
|
|
||||||
|
|
||||||
// Инициализация вложений
|
|
||||||
$this->data = new data($this->robot);
|
|
||||||
|
|
||||||
// Записать вложение
|
|
||||||
foreach ($attachments as $attachment) {
|
|
||||||
$this->data->addData($attachment);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -171,8 +111,10 @@ final class messages extends method
|
||||||
* @see https://vk.com/dev/messages.send
|
* @see https://vk.com/dev/messages.send
|
||||||
*
|
*
|
||||||
* @return array Ответ сервера
|
* @return array Ответ сервера
|
||||||
|
*
|
||||||
|
* @todo Написать обработчик ошибок возвращаемых ВКонтакте
|
||||||
*/
|
*/
|
||||||
public function send(int|string|array $destination): mixed
|
public function send(int|string|array $destination): array
|
||||||
{
|
{
|
||||||
// Идентификатор
|
// Идентификатор
|
||||||
$random_id = time();
|
$random_id = time();
|
||||||
|
@ -243,10 +185,6 @@ final class messages extends method
|
||||||
$this->send($destination);
|
$this->send($destination);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Что-то придумать :)
|
|
||||||
// наверно throw new exception($request->error->error_msg)
|
|
||||||
// А стоп. Ничего не нужно, просто возвращаем объект с ошибкой, где всё будет написано
|
|
||||||
// Костя ты тупой?
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,8 +202,7 @@ final class messages extends method
|
||||||
public function __set(string $name, mixed $value): void
|
public function __set(string $name, mixed $value): void
|
||||||
{
|
{
|
||||||
match ($name) {
|
match ($name) {
|
||||||
'data' => !isset($this->data) ? $this->data->addData($value) : throw new Exception('Вложения не инициализированны'),
|
default => throw new Exception("Свойство $name не найдено", 404)
|
||||||
default => throw new Exception('Свойство не найдено: ' . $name)
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -280,10 +217,9 @@ final class messages extends method
|
||||||
{
|
{
|
||||||
return match ($name) {
|
return match ($name) {
|
||||||
'text' => $this->text ?? throw new Exception('Текст не инициализирован'),
|
'text' => $this->text ?? throw new Exception('Текст не инициализирован'),
|
||||||
'data' => isset($this->data) ? $this->data->data : throw new Exception('Вложения не инициализированны'),
|
'forward' => empty($this->forward) ? throw new Exception('Сообщения для пересылки не инициализированы') : $this->forward,
|
||||||
'forwardMessages' => !empty($this->forwardMessages) ? $this->forwardMessages : throw new Exception('Пересылаемые сообщения не инициализированны'),
|
'reply' => isset($this->reply) ? $this->reply : throw new Exception('Сообщение для ответа не инициализировано'),
|
||||||
'ReplyMessage' => isset($this->ReplyMessage) ? $this->ReplyMessage : throw new Exception('Ответное сообщение не инициализированно'),
|
default => throw new Exception("Свойство $name не найдено", 404)
|
||||||
default => throw new Exception('Свойство не найдено: ' . $name)
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,278 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace hood\vk\api;
|
||||||
|
|
||||||
|
use hood\vk\robots\robot;
|
||||||
|
|
||||||
|
use Throwable;
|
||||||
|
use Exception;
|
||||||
|
use ArrayAccess;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Настройки соединения с API
|
||||||
|
*
|
||||||
|
* @var robot $robot Робот
|
||||||
|
* @var array $settings Настройки
|
||||||
|
* @var float $version Версия API
|
||||||
|
*
|
||||||
|
* @todo
|
||||||
|
* 1. Создать __isset(), __unset()
|
||||||
|
*/
|
||||||
|
class settings implements ArrayAccess
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Конструктор
|
||||||
|
*/
|
||||||
|
public function __construct(
|
||||||
|
protected robot $robot,
|
||||||
|
protected array $settings = []
|
||||||
|
) {
|
||||||
|
if (empty($settings)) {
|
||||||
|
// Настройки не получены
|
||||||
|
|
||||||
|
// Инициализация
|
||||||
|
$this->_init();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Инициализация (безопасная)
|
||||||
|
*
|
||||||
|
* @var float|null $version Версия API
|
||||||
|
*/
|
||||||
|
public function init(float|null $version = null): self
|
||||||
|
{
|
||||||
|
if (isset($blocked)) {
|
||||||
|
// Блокировка найдена
|
||||||
|
|
||||||
|
throw new Exception('Повторная инициализация запрещена', 500);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Блокировка
|
||||||
|
static $blocked = true;
|
||||||
|
|
||||||
|
// Инициализация
|
||||||
|
try {
|
||||||
|
$this->_init($version);
|
||||||
|
} catch (Throwable $t) {
|
||||||
|
throw new Exception('Не удалось инициализировать API', 500, $t->getPrevious());
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Реинициализация
|
||||||
|
*
|
||||||
|
* @var float|null $version Версия API
|
||||||
|
*/
|
||||||
|
public function reinit(float|null $version = null): self
|
||||||
|
{
|
||||||
|
// Буфер
|
||||||
|
$version = $version ?? $this->settings['v'] ?? null;
|
||||||
|
|
||||||
|
// Деинициализация
|
||||||
|
$this->settings = [];
|
||||||
|
|
||||||
|
// Инициализация
|
||||||
|
try {
|
||||||
|
$this->_init($version);
|
||||||
|
} catch (Throwable $t) {
|
||||||
|
throw new Exception('Не удалось инициализировать API', 500, $t->getPrevious());
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Инициализация
|
||||||
|
*
|
||||||
|
* @var float $version Версия API
|
||||||
|
*/
|
||||||
|
protected function _init(float $version = 5.124): self
|
||||||
|
{
|
||||||
|
// Ключ
|
||||||
|
$this->settings['access_token'] = $this->robot->key;
|
||||||
|
|
||||||
|
// Версия API
|
||||||
|
$this->settings['v'] = $version;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Записать получателя
|
||||||
|
*
|
||||||
|
* Определяет получателей по входным параметрам
|
||||||
|
*
|
||||||
|
* @see hood\vk\api\methods\messages Сообщения
|
||||||
|
*/
|
||||||
|
public function writeDestination(string|array|int $destination): void
|
||||||
|
{
|
||||||
|
if (is_int($destination)) {
|
||||||
|
// Идентификатор
|
||||||
|
|
||||||
|
$this->settings['peer_id'] = $destination;
|
||||||
|
} else if (is_array($destination)) {
|
||||||
|
// Идентификаторы
|
||||||
|
|
||||||
|
$this->settings['user_ids'] = $destination;
|
||||||
|
} else if (is_string($destination)) {
|
||||||
|
// Домен
|
||||||
|
|
||||||
|
$this->settings['domain'] = $destination;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new Exception('Не удалось определить получателя', 500);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Записать свойство
|
||||||
|
*
|
||||||
|
* @param string $name Название
|
||||||
|
* @param mixed $value Значение
|
||||||
|
*/
|
||||||
|
public function __set(string $name, mixed $value): void
|
||||||
|
{
|
||||||
|
match ($name) {
|
||||||
|
'settings' => isset($this->settings) ? throw new Exception('Запрещено перезаписывать настройки', 500) : $this->settings = $value,
|
||||||
|
'robot' => isset($this->robot) ? throw new Exception('Запрещено перезаписывать Робота', 500) : $this->robot = $value,
|
||||||
|
'data' => $this->offsetSet('data', $value),
|
||||||
|
'attachments' => $this->offsetSet('attachments', $value),
|
||||||
|
default => $this->offsetSet($name, $value)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Прочитать свойство
|
||||||
|
*
|
||||||
|
* @param string $name Название
|
||||||
|
*/
|
||||||
|
public function __get(string $name): mixed
|
||||||
|
{
|
||||||
|
return match ($name) {
|
||||||
|
'settings' => $this->settings ?? throw new Exception('Настройки не инициализированы', 500),
|
||||||
|
'robot' => $this->robot ?? throw new Exception('Робот не инициализирован', 500),
|
||||||
|
'data' => $this->offsetGet('data'),
|
||||||
|
'attachments' => $this->offsetGet('attachments'),
|
||||||
|
default => $this->offsetGet($name)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Записать по смещению
|
||||||
|
*/
|
||||||
|
public function offsetSet(mixed $offset, mixed $value): mixed
|
||||||
|
{
|
||||||
|
if (isset($this->settings)) {
|
||||||
|
if (strcasecmp($offset, 'settings') === 0) {
|
||||||
|
// Полная запись
|
||||||
|
|
||||||
|
throw new Exception('Запрещено перезаписывать настройки', 500);
|
||||||
|
} else if (
|
||||||
|
(strcasecmp($offset, 'data') === 0)
|
||||||
|
|| (strcasecmp($offset, 'attachment') === 0)
|
||||||
|
|| (strcasecmp($offset, 'attachments') === 0)
|
||||||
|
) {
|
||||||
|
// Записать вложения
|
||||||
|
|
||||||
|
if (is_array($value)) {
|
||||||
|
// Жесткая запись
|
||||||
|
|
||||||
|
return $this->settings['attachments'] = $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Конкатенация
|
||||||
|
return $this->settings['attachments'][] = $value;
|
||||||
|
} else {
|
||||||
|
// Запись по ключу или смещению
|
||||||
|
|
||||||
|
return $this->settings[$offset] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new Exception('Настройки не инициализированы', 500);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Прочитать по смещению
|
||||||
|
*/
|
||||||
|
public function &offsetGet(mixed $offset): mixed
|
||||||
|
{
|
||||||
|
if (isset($this->settings)) {
|
||||||
|
if (strcasecmp($offset, 'settings') === 0) {
|
||||||
|
// Полное чтение
|
||||||
|
|
||||||
|
return $this->settings;
|
||||||
|
} else if (strcasecmp($offset, 'data') === 0 || strcasecmp($offset, 'attachments') === 0) {
|
||||||
|
// Прочитать вложения
|
||||||
|
|
||||||
|
return $this->settings['attachments'];
|
||||||
|
} else if (array_key_exists($offset, $this->settings)) {
|
||||||
|
// Прочитать по ключу или смещению
|
||||||
|
|
||||||
|
return $this->settings[$offset];
|
||||||
|
}
|
||||||
|
|
||||||
|
is_int($offset) ? throw new Exception("Смещение $offset не найдено", 404) : throw new Exception("Ключ $offset не найден", 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new Exception('Настройки не инициализированы', 500);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Проверка существования смещения
|
||||||
|
*/
|
||||||
|
public function offsetExists(mixed $offset): bool
|
||||||
|
{
|
||||||
|
if (isset($this->settings)) {
|
||||||
|
if (strcasecmp($offset, 'settings') === 0) {
|
||||||
|
// Полная проверка
|
||||||
|
|
||||||
|
return isset($this->settings);
|
||||||
|
} else if (strcasecmp($offset, 'data') === 0 || strcasecmp($offset, 'attachments') === 0) {
|
||||||
|
// Проверка вложений
|
||||||
|
|
||||||
|
return array_key_exists('attachments', $this->settings);
|
||||||
|
} else {
|
||||||
|
// Проверка по ключу или смещению
|
||||||
|
|
||||||
|
return array_key_exists($offset, $this->settings);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new Exception('Настройки не инициализированы', 500);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Удалить по смещению
|
||||||
|
*/
|
||||||
|
public function offsetUnset(mixed $offset): void
|
||||||
|
{
|
||||||
|
if (isset($this->settings)) {
|
||||||
|
if (strcasecmp($offset, 'settings') === 0) {
|
||||||
|
// Полное удаление
|
||||||
|
|
||||||
|
unset($this->settings);
|
||||||
|
|
||||||
|
return;
|
||||||
|
} else if (strcasecmp($offset, 'data') === 0 || strcasecmp($offset, 'attachments') === 0) {
|
||||||
|
// Удаление вложений
|
||||||
|
|
||||||
|
unset($this->settings['attachments']);
|
||||||
|
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
// Удаление по ключу или смещению
|
||||||
|
|
||||||
|
unset($this->settings[$offset]);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new Exception('Настройки не инициализированы', 500);
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,10 +4,11 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace hood\vk;
|
namespace hood\vk;
|
||||||
|
|
||||||
|
use hood\vk\robots\robot;
|
||||||
|
use hood\vk\traits\singleton;
|
||||||
|
use hood\vk\loggers\jasmo;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use hood\vk\loggers\jasmo,
|
|
||||||
hood\vk\traits\singleton,
|
|
||||||
hood\vk\robots\robot;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ядро
|
* Ядро
|
||||||
|
@ -23,7 +24,7 @@ use hood\vk\loggers\jasmo,
|
||||||
* @method public function get($id = null) Чтение из реестра
|
* @method public function get($id = null) Чтение из реестра
|
||||||
*
|
*
|
||||||
* @package VK
|
* @package VK
|
||||||
* @author Арсен Мирзаев <red@hood.su>
|
* @author Арсен Мирзаев Татьяно-Мурадович <red@hood.su>
|
||||||
*/
|
*/
|
||||||
final class core
|
final class core
|
||||||
{
|
{
|
||||||
|
@ -101,15 +102,25 @@ final class core
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function set(int $id, robot $robot): void
|
public function write(int $id, robot $robot): void
|
||||||
{
|
{
|
||||||
// if (empty($this->registry[$id])) {
|
try {
|
||||||
// // Если нет сессий, то инициализировать
|
// Инициализация уникального идентификатора сессии
|
||||||
// $this->registry[$id] = [];
|
|
||||||
// }
|
|
||||||
|
|
||||||
// Создать новую сессию и обновить счётчик роботов
|
$session = count($this->read($id));
|
||||||
$this->registry[$id][++$this->robots] = $robot;
|
} catch (Exception $e) {
|
||||||
|
if ($e->getCode() === 404) {
|
||||||
|
// Робота или сессии не существует
|
||||||
|
|
||||||
|
$session = 0;
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
// Записать новую сессию
|
||||||
|
$this->registry[$id][$session] = $robot;
|
||||||
|
|
||||||
|
// Прединкрементация счётчика роботов
|
||||||
|
++$this->robots;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -122,18 +133,35 @@ final class core
|
||||||
*
|
*
|
||||||
* @see hood\vk\traits\registry Модификация метода
|
* @see hood\vk\traits\registry Модификация метода
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed Весь реестр, робота или сессию робота
|
||||||
*/
|
*/
|
||||||
public function get(int|null $id = null, int|null $session = null): mixed
|
public function read(int|null $id = null, int|null $session = null): mixed
|
||||||
{
|
{
|
||||||
if (isset($id) && array_key_exists($id, $this->registry)) {
|
if (isset($id)) {
|
||||||
// Робот передан и найден
|
// Робот передан
|
||||||
if (isset($session) && array_key_exists($session, $this->registry[$id])) {
|
|
||||||
// Сессия робота передана и найдена
|
if (array_key_exists($id, $this->registry)) {
|
||||||
|
// Робот найден
|
||||||
|
|
||||||
|
if (isset($session)) {
|
||||||
|
// Сессия робота передана
|
||||||
|
|
||||||
|
if (array_key_exists($session, $this->registry[$id])) {
|
||||||
|
// Сессия робота найдена
|
||||||
|
|
||||||
return $this->registry[$id][$session];
|
return $this->registry[$id][$session];
|
||||||
}
|
}
|
||||||
return $this->registry[$id];
|
|
||||||
|
throw new Exception("Сессия $session робота с идентификатором $id не найдена", 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $this->registry[$id];
|
||||||
|
} else {
|
||||||
|
|
||||||
|
throw new Exception("Робот с идентификатором $id не найден", 404);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $this->registry;
|
return $this->registry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,18 +180,16 @@ final class core
|
||||||
if (isset($id)) {
|
if (isset($id)) {
|
||||||
// Робот передан
|
// Робот передан
|
||||||
|
|
||||||
if (!array_key_exists($id, $this->registry)) {
|
if (array_key_exists($id, $this->registry)) {
|
||||||
throw new Exception('Робот не найден');
|
// Робот найден
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($session)) {
|
if (isset($session)) {
|
||||||
// Сессия передана
|
// Сессия передана
|
||||||
|
|
||||||
if (!array_key_exists($session, $this->registry[$id])) {
|
if (array_key_exists($session, $this->registry[$id])) {
|
||||||
throw new Exception('Сессия не найдена');
|
// Сессия найдена
|
||||||
}
|
|
||||||
|
|
||||||
// Счётчик роботов
|
// Постдекрементация счётчика роботов
|
||||||
--$this->robots;
|
--$this->robots;
|
||||||
|
|
||||||
// Удаление сессии
|
// Удаление сессии
|
||||||
|
@ -172,7 +198,10 @@ final class core
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Счётчик роботов
|
throw new Exception("Сессия $session робота с идентификатором $id не найдена", 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Вычитание из счётчика количества сессий робота
|
||||||
$this->robots = $this->robots - count($this->registry[$id]);
|
$this->robots = $this->robots - count($this->registry[$id]);
|
||||||
|
|
||||||
// Удаление робота и всех его сессий
|
// Удаление робота и всех его сессий
|
||||||
|
@ -181,7 +210,10 @@ final class core
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Удаление всех роботов и их сессий
|
throw new Exception("Робот с идентификатором $id не найден", 404);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Полная очистка
|
||||||
$this->registry = [];
|
$this->registry = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,10 +228,10 @@ final class core
|
||||||
public function __set(mixed $name, mixed $value): void
|
public function __set(mixed $name, mixed $value): void
|
||||||
{
|
{
|
||||||
match ($name) {
|
match ($name) {
|
||||||
'timezone' => !isset($this->timezone) ? $this->timezone = $value : throw new Exception('Запрещено переопределять часовой пояс'),
|
'timezone' => !isset($this->timezone) ? $this->timezone = $value : throw new Exception('Запрещено переопределять часовой пояс', 500),
|
||||||
'path_root' => !isset($this->path_root) ? $this->path_root = $value : throw new Exception('Запрещено переопределять корневой каталог'),
|
'path_root' => !isset($this->path_root) ? $this->path_root = $value : throw new Exception('Запрещено переопределять корневой каталог', 500),
|
||||||
'path_logs' => !isset($this->path_logs) ? $this->path_logs = $value : throw new Exception('Запрещено переопределять каталог журналов'),
|
'path_logs' => !isset($this->path_logs) ? $this->path_logs = $value : throw new Exception('Запрещено переопределять каталог журналов', 500),
|
||||||
'path_temp' => !isset($this->path_temp) ? $this->path_temp = $value : throw new Exception('Запрещено переопределять каталог временных файлов')
|
'path_temp' => !isset($this->path_temp) ? $this->path_temp = $value : throw new Exception('Запрещено переопределять каталог временных файлов', 500)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,7 +271,7 @@ final class core
|
||||||
// Если найден класс реализующий запрошенного робота
|
// Если найден класс реализующий запрошенного робота
|
||||||
return new $robot(...$params);
|
return new $robot(...$params);
|
||||||
} else {
|
} else {
|
||||||
throw new Exception('Не найден робот: ' . $method);
|
throw new Exception("Робот $method не найден", 404);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,11 +4,11 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace hood\vk\robots;
|
namespace hood\vk\robots;
|
||||||
|
|
||||||
use hood\vk\robots\robot,
|
use hood\vk\robots\robot;
|
||||||
hood\vk\api\longpoll;
|
use hood\vk\api\longpoll;
|
||||||
|
|
||||||
use Throwable,
|
use Throwable;
|
||||||
Exception;
|
use Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Робот-группа
|
* Робот-группа
|
||||||
|
|
|
@ -11,7 +11,7 @@ use GuzzleHttp\Client as browser;
|
||||||
use hood\vk\core;
|
use hood\vk\core;
|
||||||
use hood\vk\proxies\proxy;
|
use hood\vk\proxies\proxy;
|
||||||
use hood\vk\captcha\captcha;
|
use hood\vk\captcha\captcha;
|
||||||
use hood\vk\api\api;
|
use hood\vk\api\settings as api;
|
||||||
use hood\vk\api\methods\method;
|
use hood\vk\api\methods\method;
|
||||||
|
|
||||||
use hood\accounts\vk as account;
|
use hood\accounts\vk as account;
|
||||||
|
@ -31,7 +31,7 @@ use hood\accounts\vk as account;
|
||||||
*
|
*
|
||||||
* @var int $messages_mode Режим отправки сообщений
|
* @var int $messages_mode Режим отправки сообщений
|
||||||
*
|
*
|
||||||
* @method public function __construct(int $id = null, float $version = null) Конструктор
|
* @method public function __construct(int $id = null) Конструктор
|
||||||
* @method public function key(string $key) Инициализация ключа
|
* @method public function key(string $key) Инициализация ключа
|
||||||
* @method public function account(account $account) Инициализация аккаунта
|
* @method public function account(account $account) Инициализация аккаунта
|
||||||
* @method public function __set($name, $value) Запись свойства
|
* @method public function __set($name, $value) Запись свойства
|
||||||
|
@ -51,11 +51,6 @@ abstract class robot
|
||||||
*/
|
*/
|
||||||
protected int $session;
|
protected int $session;
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string Ключ
|
|
||||||
*/
|
|
||||||
protected string $key;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string Аккаунт
|
* @var string Аккаунт
|
||||||
*/
|
*/
|
||||||
|
@ -84,22 +79,24 @@ abstract class robot
|
||||||
/**
|
/**
|
||||||
* Конструктор
|
* Конструктор
|
||||||
*
|
*
|
||||||
* @param int $id Идентификатор
|
* @param int|null $id Идентификатор
|
||||||
|
* @param string|null $key Ключ
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
protected int|null $id = null,
|
protected int|null $id = null,
|
||||||
|
protected string|null $key = null
|
||||||
) {
|
) {
|
||||||
// Инициализация ядра
|
// Инициализация ядра
|
||||||
$core = core::init();
|
$core = core::init();
|
||||||
|
|
||||||
// Идентификация робота
|
// Идентификация робота
|
||||||
$this->id = empty($id) ? $core->robots + 1 : $id;
|
$this->id = $id ?? $core->robots + 1;
|
||||||
|
|
||||||
// Регистрация робота в ядре
|
// Регистрация робота в ядре
|
||||||
$core->set($this->id, $this);
|
$core->write($this->id, $this);
|
||||||
|
|
||||||
// Идентификация сессии робота
|
// Идентификация сессии робота
|
||||||
$this->session = count($core->get($this->id));
|
$this->session = count($core->read($this->id));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -111,11 +108,7 @@ abstract class robot
|
||||||
*/
|
*/
|
||||||
public function key(string $key): self
|
public function key(string $key): self
|
||||||
{
|
{
|
||||||
if (!isset($this->key)) {
|
$this->__set('key', $key);
|
||||||
$this->key = $key;
|
|
||||||
} else {
|
|
||||||
throw new Exception('Запрещено перезаписывать ключ');
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -129,11 +122,7 @@ abstract class robot
|
||||||
*/
|
*/
|
||||||
public function account(account $account): self
|
public function account(account $account): self
|
||||||
{
|
{
|
||||||
if (!isset($this->account)) {
|
$this->__set('account', $account);
|
||||||
$this->account = $account;
|
|
||||||
} else {
|
|
||||||
throw new Exception('Запрещено перезаписывать аккаунт');
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -147,7 +136,7 @@ abstract class robot
|
||||||
*/
|
*/
|
||||||
public function proxy(proxy $proxy): self
|
public function proxy(proxy $proxy): self
|
||||||
{
|
{
|
||||||
$this->proxy = $proxy;
|
$this->__set('proxy', $proxy);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -161,7 +150,7 @@ abstract class robot
|
||||||
*/
|
*/
|
||||||
public function captcha(captcha $captcha): self
|
public function captcha(captcha $captcha): self
|
||||||
{
|
{
|
||||||
$this->captcha = $captcha;
|
$this->__set('captcha', $captcha);
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -177,16 +166,16 @@ abstract class robot
|
||||||
public function __set(string $name, mixed $value): void
|
public function __set(string $name, mixed $value): void
|
||||||
{
|
{
|
||||||
match ($name) {
|
match ($name) {
|
||||||
'id' => !isset($this->id) ? $this->id = (int) $value : throw new Exception('Запрещено перезаписывать идентификатор'),
|
'id' => isset($this->id) ? throw new Exception('Запрещено перезаписывать идентификатор', 500) : $this->id = (int) $value,
|
||||||
'session' => !isset($this->session) ? $this->session = (int) $value : throw new Exception('Запрещено перезаписывать сессию'),
|
'session' => isset($this->session) ? throw new Exception('Запрещено перезаписывать сессию', 500) : $this->session = (int) $value,
|
||||||
'key' => !isset($this->key) ? $this->key = (string) $value : throw new Exception('Запрещено перезаписывать ключ'),
|
'key' => isset($this->key) ? throw new Exception('Запрещено перезаписывать ключ', 500) : $this->key = (string) $value,
|
||||||
'api' => !isset($this->api) ? $this->api = $value : throw new Exception('Запрещено перезаписывать API'),
|
'api' => isset($this->api) ? throw new Exception('Запрещено перезаписывать API', 500) : $this->api = $value,
|
||||||
'account' => !isset($this->account) && $value instanceof account ? $this->account = $value : throw new Exception('Запрещено перезаписывать аккаунт'),
|
'account' => isset($this->account) ? throw new Exception('Запрещено перезаписывать аккаунт', 500) : $this->account = $value,
|
||||||
'browser' => !isset($this->browser) && $value instanceof browser ? $this->browser = $value : throw new Exception('Запрещено перезаписывать браузер'),
|
'browser' => isset($this->browser) ? throw new Exception('Запрещено перезаписывать браузер', 500) : $this->browser = $value,
|
||||||
'proxy' => $this->proxy = $value,
|
'proxy' => $this->proxy = $value,
|
||||||
'captcha' => $this->captcha = $value,
|
'captcha' => $this->captcha = $value,
|
||||||
'messages_new' => $this->messages_new = (int) $value,
|
'messages_new' => $this->messages_new = (int) $value,
|
||||||
default => throw new Exception('Свойство не найдено: ' . $name)
|
default => throw new Exception("Свойство $name не найдено", 404)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,11 +189,11 @@ abstract class robot
|
||||||
public function __get(string $name): mixed
|
public function __get(string $name): mixed
|
||||||
{
|
{
|
||||||
return match ($name) {
|
return match ($name) {
|
||||||
'id' => $this->id ?? throw new Exception('Идентификатор не инициализирован'),
|
'id' => $this->id ?? throw new Exception('Идентификатор не инициализирован', 500),
|
||||||
'session' => $this->session ?? throw new Exception('Сессия не инициализирована'),
|
'session' => $this->session ?? throw new Exception('Сессия не инициализирована', 500),
|
||||||
'key' => $this->key ?? throw new Exception('Ключ не инициализирован'),
|
'key' => $this->key ?? throw new Exception('Ключ не инициализирован', 500),
|
||||||
'api' => $this->api ?? $this->api = new api($this),
|
'api' => $this->api ?? $this->api = new api($this),
|
||||||
'account' => $this->account ?? throw new Exception('Аккаунт не инициализирован'),
|
'account' => $this->account ?? throw new Exception('Аккаунт не инициализирован', 500),
|
||||||
'browser' => $this->browser ?? $this->browser = new browser([
|
'browser' => $this->browser ?? $this->browser = new browser([
|
||||||
'base_uri' => 'https://api.vk.com/method/',
|
'base_uri' => 'https://api.vk.com/method/',
|
||||||
'cookies' => true
|
'cookies' => true
|
||||||
|
@ -212,7 +201,7 @@ abstract class robot
|
||||||
'proxy' => $this->proxy,
|
'proxy' => $this->proxy,
|
||||||
'captcha' => $this->captcha,
|
'captcha' => $this->captcha,
|
||||||
'messages_new' => $this->messages_new,
|
'messages_new' => $this->messages_new,
|
||||||
default => throw new Exception('Свойство не найдено: ' . $name)
|
default => throw new Exception("Свойство $name не найдено", 404)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,7 +224,7 @@ abstract class robot
|
||||||
'proxy' => isset($this->proxy),
|
'proxy' => isset($this->proxy),
|
||||||
'captcha' => isset($this->captcha),
|
'captcha' => isset($this->captcha),
|
||||||
'messages_new' => isset($this->messages_new),
|
'messages_new' => isset($this->messages_new),
|
||||||
default => throw new Exception('Свойство не найдено: ' . $name)
|
default => throw new Exception("Свойство $name не найдено", 404)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -257,7 +246,7 @@ abstract class robot
|
||||||
return new $class($this, ...$params);
|
return new $class($this, ...$params);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Exception('Метод не найден: ' . $method);
|
throw new Exception("Метод $method не найден", 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -277,7 +266,7 @@ abstract class robot
|
||||||
return $class(self, ...$params);
|
return $class(self, ...$params);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Exception('Метод не найден: ' . $method);
|
throw new Exception("Метод $method не найден", 404);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue