✨ Add Request and validation
This commit is contained in:
12
bot/Bot.php
12
bot/Bot.php
@@ -15,16 +15,18 @@ class Bot
|
||||
return $masters[array_rand($masters)];
|
||||
}
|
||||
|
||||
public function __construct(array $config = [])
|
||||
public function __construct(Request $request, array $config = [])
|
||||
{
|
||||
$this->request = $request;
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
// TODO
|
||||
public function isValid(Request $request): bool
|
||||
public function isRequestValid(): bool
|
||||
{
|
||||
$this->request = $request;
|
||||
return $this->config['token'] === $request->getToken();
|
||||
return hash_equals(
|
||||
hash_hmac('sha256', $this->request->nc_random . $this->request->body, $this->config['secret']),
|
||||
strtolower($this->request->nc_signature)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user