Skip to content

Commit 82a2e8c

Browse files
committed
update protocol version
1 parent 1970f9a commit 82a2e8c

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

src/Api/Type/Message/MessageEntityType.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ final class MessageEntityType implements Enum
4545

4646
private const MENTION = 'mention';
4747

48+
private const UNDERLINE = 'underline';
49+
50+
private const SPOILER = 'spoiler';
51+
52+
private const STRIKETHROUGH = 'strikethrough';
53+
4854
private const LIST = [
4955
self::HASH_TAG,
5056
self::CASH_TAG,
@@ -59,6 +65,9 @@ final class MessageEntityType implements Enum
5965
self::TEXT_LINK,
6066
self::TEXT_MENTION,
6167
self::MENTION,
68+
self::UNDERLINE,
69+
self::SPOILER,
70+
self::STRIKETHROUGH
6271
];
6372

6473
/**
@@ -141,6 +150,21 @@ public static function mention(): self
141150
return new self(self::MENTION);
142151
}
143152

153+
public static function underline(): self
154+
{
155+
return new self(self::UNDERLINE);
156+
}
157+
158+
public static function spoiler(): self
159+
{
160+
return new self(self::SPOILER);
161+
}
162+
163+
public static function strikethrough(): self
164+
{
165+
return new self(self::STRIKETHROUGH);
166+
}
167+
144168
public function equals(MessageEntityType $type): bool
145169
{
146170
return $this->value === $type->value;

src/Interaction/InteractionsProvider.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,10 @@ function () use ($method, $credentials): \Generator
119119
{
120120
/** @var \GuzzleHttp\Psr7\Response $response */
121121
$response = yield $this->httpClient->execute($httpRequest);
122+
$responseBody = (string) $response->getBody();
122123

123124
if ($response->getStatusCode() === 200)
124125
{
125-
$responseBody = (string) $response->getBody();
126-
127126
if ($responseBody === '')
128127
{
129128
throw new \RuntimeException(
@@ -139,6 +138,17 @@ function () use ($method, $credentials): \Generator
139138
);
140139
}
141140

141+
if ($response->getStatusCode() === 400)
142+
{
143+
/** @psalm-var non-empty-string $responseBody */
144+
$responseDetails = jsonDecode($responseBody);
145+
146+
throw new \RuntimeException(
147+
$responseDetails['description']
148+
?? \sprintf('Method %s has invalid parameters', $method->methodName())
149+
);
150+
}
151+
142152
if ($response->getStatusCode() === 404)
143153
{
144154
throw new \RuntimeException(\sprintf('Method %s not exists', $method->methodName()));

0 commit comments

Comments
 (0)