Skip to content

Commit 323590d

Browse files
authored
Merge branch 'v5.1' into custom-emoji-message-entity
2 parents aac4831 + 82a2e8c commit 323590d

File tree

2 files changed

+37
-2
lines changed

2 files changed

+37
-2
lines changed

src/Api/Type/Message/MessageEntityType.php

+25
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,15 @@ final class MessageEntityType implements Enum
4545

4646
private const MENTION = 'mention';
4747

48+
4849
private const CUSTOM_EMOJI = 'custom_emoji';
4950

51+
private const UNDERLINE = 'underline';
52+
53+
private const SPOILER = 'spoiler';
54+
55+
private const STRIKETHROUGH = 'strikethrough';
56+
5057
private const LIST = [
5158
self::HASH_TAG,
5259
self::CASH_TAG,
@@ -62,6 +69,9 @@ final class MessageEntityType implements Enum
6269
self::TEXT_MENTION,
6370
self::MENTION,
6471
self::CUSTOM_EMOJI,
72+
self::UNDERLINE,
73+
self::SPOILER,
74+
self::STRIKETHROUGH
6575
];
6676

6777
/**
@@ -149,6 +159,21 @@ public static function customEmoji(): self
149159
return new self(self::CUSTOM_EMOJI);
150160
}
151161

162+
public static function underline(): self
163+
{
164+
return new self(self::UNDERLINE);
165+
}
166+
167+
public static function spoiler(): self
168+
{
169+
return new self(self::SPOILER);
170+
}
171+
172+
public static function strikethrough(): self
173+
{
174+
return new self(self::STRIKETHROUGH);
175+
}
176+
152177
public function equals(MessageEntityType $type): bool
153178
{
154179
return $this->value === $type->value;

src/Interaction/InteractionsProvider.php

+12-2
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)