Избавление от phpdotenv, переработка сборщика
This commit is contained in:
@@ -19,27 +19,6 @@ use VK\API\LongPoll;
|
||||
*/
|
||||
class Group extends RobotAbstract
|
||||
{
|
||||
/**
|
||||
* ВКонтакте: идентификатор
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public int $id;
|
||||
|
||||
/**
|
||||
* ВКонтакте: токен доступа
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public string $token;
|
||||
|
||||
/**
|
||||
* ВКонтакте: версия API
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
public float $version;
|
||||
|
||||
/**
|
||||
* ВКонтакте: тип API
|
||||
*
|
||||
@@ -61,13 +40,6 @@ class Group extends RobotAbstract
|
||||
*/
|
||||
//protected int $captcha;
|
||||
|
||||
public function __construct($name)
|
||||
{
|
||||
if (!isset($this->id)) $this->id = (int) $_ENV['DEFAULT_' . strtoupper($name) . '_ID'];
|
||||
if (!isset($this->token)) $this->token = (string) $_ENV['DEFAULT_' . strtoupper($name) . '_TOKEN'];
|
||||
if (!isset($this->version)) $this->version = (float) $_ENV['DEFAULT_API_VERSION'];
|
||||
}
|
||||
|
||||
public function postMethod($method, $params = []): BrowserAbstract
|
||||
{
|
||||
$browser = __NAMESPACE__ . '\\Browsers\\' . ucfirst($_ENV['BROWSER_TYPE']);
|
||||
|
@@ -4,18 +4,32 @@ declare(strict_types=1);
|
||||
|
||||
namespace VK\Robots;
|
||||
|
||||
use VK\Robots\RobotAbstract;
|
||||
use VK\Browsers\BrowserAbstract;
|
||||
use VK\Proxies\ProxyAbstract;
|
||||
use \VK\Browsers\BrowserAbstract;
|
||||
use \VK\Proxies\ProxyAbstract;
|
||||
use \VK\Proxies\CaptchaAbstract;
|
||||
|
||||
abstract class RobotAbstract
|
||||
{
|
||||
/**
|
||||
* Идентификатор в регистре
|
||||
* Идентификатор
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected int $id;
|
||||
|
||||
/**
|
||||
* Токен
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private int $id_registry;
|
||||
protected string $token;
|
||||
|
||||
/**
|
||||
* Версия API
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
public float $version = 5.103;
|
||||
|
||||
/**
|
||||
* Используемый браузер
|
||||
@@ -39,23 +53,96 @@ abstract class RobotAbstract
|
||||
protected CaptchaAbstract $captcha;
|
||||
|
||||
/**
|
||||
* Установка идентификатора
|
||||
* Магический сеттер
|
||||
*
|
||||
* @return int
|
||||
* @return mixed
|
||||
*/
|
||||
public function setID(int $id): int
|
||||
public function __set($name, $value)
|
||||
{
|
||||
return $this->id_registry = $id;
|
||||
if ($name === 'id' && empty($this->id)) {
|
||||
$this->id = $value;
|
||||
} else if ($name === 'token' && empty($this->token)) {
|
||||
$this->token = $value;
|
||||
} else if ($name === 'version' && empty($this->version)) {
|
||||
$this->version = $value;
|
||||
} else if ($name === 'browser') {
|
||||
$this->browser = $value;
|
||||
} else if ($name === 'proxy') {
|
||||
$this->proxy = $value;
|
||||
} else if ($name === 'captcha') {
|
||||
$this->captcha = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Получение идентификатора
|
||||
* Магический геттер
|
||||
*
|
||||
* @return int
|
||||
* @return mixed
|
||||
*/
|
||||
public function getID(): int
|
||||
public function __get($name)
|
||||
{
|
||||
return $this->id;
|
||||
if ($name === 'id') {
|
||||
return $this->id;
|
||||
} else if ($name === 'token') {
|
||||
return $this->token;
|
||||
} else if ($name === 'version') {
|
||||
return $this->version;
|
||||
} else if ($name === 'browser') {
|
||||
return $this->browser;
|
||||
} else if ($name === 'proxy') {
|
||||
return $this->proxy;
|
||||
} else if ($name === 'captcha') {
|
||||
return $this->captcha;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Установка токена
|
||||
*
|
||||
* @return RobotAbstract
|
||||
*/
|
||||
public function token(string $token): RobotAbstract
|
||||
{
|
||||
$this->token = $token;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Установка браузера
|
||||
*
|
||||
* @return RobotAbstract
|
||||
*/
|
||||
public function browser(BrowserAbstract $browser): RobotAbstract
|
||||
{
|
||||
$this->browser = $browser;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Установка прокси-сервера
|
||||
*
|
||||
* @return RobotAbstract
|
||||
*/
|
||||
public function proxy(ProxyAbstract $proxy): RobotAbstract
|
||||
{
|
||||
$this->proxy = $proxy;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Установка сервиса антикапчи
|
||||
*
|
||||
* @return RobotAbstract
|
||||
*/
|
||||
public function captcha(CaptchaAbstract $captcha): RobotAbstract
|
||||
{
|
||||
$this->captcha = $captcha;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -65,8 +152,8 @@ abstract class RobotAbstract
|
||||
*/
|
||||
public function getBrowser(): BrowserAbstract
|
||||
{
|
||||
// return $this->browser;
|
||||
return new \VK\Browsers\Curl;
|
||||
// return $this->browser;
|
||||
return new \VK\Browsers\Curl;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user