Added support for broadsword polls

This commit is contained in:
aymm 2021-03-10 20:10:09 +00:00
parent 3ca95f82a8
commit 45fe5f4156
2 changed files with 10 additions and 2 deletions

View File

@ -10,6 +10,7 @@ use APnutI\Exceptions\NotFoundException;
use APnutI\Exceptions\NotAuthorizedException;
use APnutI\Exceptions\HttpPnutException;
use APnutI\Exceptions\HttpPnutRedirectException;
use APnutI\Exceptions\NotSupportedPollException;
use APnutI\Meta;
use Monolog\Logger;
use Monolog\Handler\RotatingFileHandler;
@ -458,7 +459,13 @@ class APnutI
public function getPoll(int $poll_id): Poll
{
return new Poll($this->get('/polls/' . $poll_id));
$res = $this->get('/polls/' . $poll_id);
try {
return new Poll($res);
} catch (NotSupportedPollException $e) {
$this->logger->error('Poll not supported: '.json_encode($res));
throw $e;
}
}
public function getAuthorizedUser(): User

View File

@ -24,7 +24,8 @@ class Poll
protected static array $poll_types = [
'general.poll',
'net.unsweets.beta',
'io.pnut.core.poll'
'io.pnut.core.poll',
'io.broadsword.poll'
];
public function __construct(array $data)