Skip to content

Commit eb50ef0

Browse files
committed
#15: Bot Api Update December 31, 2019
1 parent 96ab760 commit eb50ef0

19 files changed

+224
-55
lines changed

src/Method/Interfaces/HasParseModeVariableInterface.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,15 @@
1010
interface HasParseModeVariableInterface
1111
{
1212
public const PARSE_MODE_HTML = 'HTML';
13+
14+
/**
15+
* @see https://core.telegram.org/bots/api#markdownv2-style
16+
*/
17+
public const PARSE_MODE_MARKDOWN_V2 = 'MarkdownV2';
18+
19+
/**
20+
* @deprecated
21+
* @see HasParseModeVariableInterface::PARSE_MODE_MARKDOWN_V2
22+
*/
1323
public const PARSE_MODE_MARKDOWN = 'Markdown';
1424
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace TgBotApi\BotApiBase\Method;
6+
7+
use TgBotApi\BotApiBase\Method\Interfaces\SetMethodAliasInterface;
8+
use TgBotApi\BotApiBase\Method\Traits\ChatIdVariableTrait;
9+
use TgBotApi\BotApiBase\Method\Traits\UserIdVariableTrait;
10+
11+
/**
12+
* Use this method to set a custom title
13+
* for an administrator in a supergroup promoted by the bot. Returns True on success.
14+
*
15+
* @see https://core.telegram.org/bots/api#setchatadministratorcustomtitle
16+
*/
17+
class SetChatAdministratorCustomTitleMethod implements SetMethodAliasInterface
18+
{
19+
use ChatIdVariableTrait;
20+
use UserIdVariableTrait;
21+
22+
/**
23+
* @var
24+
*/
25+
public $customTitle;
26+
27+
/**
28+
* @param int|string $chatId
29+
*/
30+
public static function create($chatId, int $userId, string $title): SetChatAdministratorCustomTitleMethod
31+
{
32+
$instance = new static();
33+
$instance->chatId = $chatId;
34+
$instance->userId = $userId;
35+
$instance->customTitle = $title;
36+
37+
return $instance;
38+
}
39+
}

src/Traits/SetMethodTrait.php

Lines changed: 9 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use TgBotApi\BotApiBase\Exception\ResponseException;
88
use TgBotApi\BotApiBase\Method\Interfaces\SetMethodAliasInterface;
9+
use TgBotApi\BotApiBase\Method\SetChatAdministratorCustomTitleMethod;
910
use TgBotApi\BotApiBase\Method\SetChatDescriptionMethod;
1011
use TgBotApi\BotApiBase\Method\SetChatPermissionsMethod;
1112
use TgBotApi\BotApiBase\Method\SetChatPhotoMethod;
@@ -22,116 +23,84 @@
2223
trait SetMethodTrait
2324
{
2425
/**
25-
* @param SetMethodAliasInterface $method
26-
*
2726
* @throws ResponseException
28-
*
29-
* @return bool
3027
*/
3128
abstract public function set(SetMethodAliasInterface $method): bool;
3229

3330
/**
34-
* @param SetChatDescriptionMethod $method
35-
*
3631
* @throws ResponseException
37-
*
38-
* @return bool
3932
*/
4033
public function setChatDescription(SetChatDescriptionMethod $method): bool
4134
{
4235
return $this->set($method);
4336
}
4437

4538
/**
46-
* @param SetChatPhotoMethod $method
47-
*
4839
* @throws ResponseException
49-
*
50-
* @return bool
5140
*/
5241
public function setChatPhoto(SetChatPhotoMethod $method): bool
5342
{
5443
return $this->set($method);
5544
}
5645

5746
/**
58-
* @param SetChatStickerSetMethod $method
59-
*
6047
* @throws ResponseException
61-
*
62-
* @return bool
48+
*/
49+
public function setChatAdministrator(SetChatAdministratorCustomTitleMethod $method): bool
50+
{
51+
return $this->set($method);
52+
}
53+
54+
/**
55+
* @throws ResponseException
6356
*/
6457
public function setChatStickerSet(SetChatStickerSetMethod $method): bool
6558
{
6659
return $this->set($method);
6760
}
6861

6962
/**
70-
* @param SetChatTitleMethod $method
71-
*
7263
* @throws ResponseException
73-
*
74-
* @return bool
7564
*/
7665
public function setChatTitle(SetChatTitleMethod $method): bool
7766
{
7867
return $this->set($method);
7968
}
8069

8170
/**
82-
* @param SetGameScoreMethod $method
83-
*
8471
* @throws ResponseException
85-
*
86-
* @return bool
8772
*/
8873
public function setGameScore(SetGameScoreMethod $method): bool
8974
{
9075
return $this->set($method);
9176
}
9277

9378
/**
94-
* @param SetStickerPositionInSetMethod $method
95-
*
9679
* @throws ResponseException
97-
*
98-
* @return bool
9980
*/
10081
public function setStickerPositionInSet(SetStickerPositionInSetMethod $method): bool
10182
{
10283
return $this->set($method);
10384
}
10485

10586
/**
106-
* @param SetWebhookMethod $method
107-
*
10887
* @throws ResponseException
109-
*
110-
* @return bool
11188
*/
11289
public function setWebhook(SetWebhookMethod $method): bool
11390
{
11491
return $this->set($method);
11592
}
11693

11794
/**
118-
* @param SetPassportDataErrorsMethod $method
119-
*
12095
* @throws ResponseException
121-
*
122-
* @return bool
12396
*/
12497
public function setPassportDataErrors(SetPassportDataErrorsMethod $method): bool
12598
{
12699
return $this->set($method);
127100
}
128101

129102
/**
130-
* @param SetChatPermissionsMethod $method
131-
*
132103
* @throws ResponseException
133-
*
134-
* @return bool
135104
*/
136105
public function setChatPermissions(SetChatPermissionsMethod $method): bool
137106
{

src/Type/AnimationType.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ class AnimationType
1818
*/
1919
public $fileId;
2020

21+
/**
22+
* Unique identifier for this file, which is supposed to be the same over time and for different bots.
23+
* Can't be used to download or reuse the file.
24+
*
25+
* @var string
26+
*/
27+
public $fileUniqueId;
28+
2129
/**
2230
* Video width as defined by sender.
2331
*

src/Type/AudioType.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ class AudioType
1818
*/
1919
public $fileId;
2020

21+
/**
22+
* Unique identifier for this file, which is supposed to be the same over time and for different bots.
23+
* Can't be used to download or reuse the file.
24+
*
25+
* @var string
26+
*/
27+
public $fileUniqueId;
28+
2129
/**
2230
* Duration of the audio in seconds as defined by sender.
2331
*

src/Type/ChatMemberType.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
*/
1212
class ChatMemberType
1313
{
14-
const STATUS_CREATOR = 'creator';
15-
const STATUS_ADMINISTRATOR = 'administrator';
16-
const STATUS_MEMBER = 'member';
17-
const STATUS_RESTRICTED = 'restricted';
18-
const STATUS_LEFT = 'left';
19-
const STATUS_KICKED = 'kicked';
14+
public const STATUS_CREATOR = 'creator';
15+
public const STATUS_ADMINISTRATOR = 'administrator';
16+
public const STATUS_MEMBER = 'member';
17+
public const STATUS_RESTRICTED = 'restricted';
18+
public const STATUS_LEFT = 'left';
19+
public const STATUS_KICKED = 'kicked';
2020

2121
/**
2222
* Information about the user.
@@ -32,6 +32,13 @@ class ChatMemberType
3232
*/
3333
public $status;
3434

35+
/**
36+
* Optional. Owner and administrators only. Custom title for this user.
37+
*
38+
* @var string|null
39+
*/
40+
public $customTitle;
41+
3542
/**
3643
* Optional. Restricted and kicked only. Date when restrictions will be lifted for this user, \DateTimeImmutable.
3744
*

src/Type/ChatPhotoType.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,28 @@ class ChatPhotoType
1818
*/
1919
public $smallFileId;
2020

21+
/**
22+
* Unique file identifier of small (160x160) chat photo,
23+
* which is supposed to be the same over time and for different bots.
24+
* Can't be used to download or reuse the file.
25+
*
26+
* @var string
27+
*/
28+
public $smallFileUniqueId;
29+
2130
/**
2231
* Unique file identifier of big (640x640) chat photo. This file_id can be used only for photo download.
2332
*
2433
* @var string
2534
*/
2635
public $bigFileId;
36+
37+
/**
38+
* Unique file identifier of big (640x640) chat photo,
39+
* which is supposed to be the same over time and for different bots.
40+
* Can't be used to download or reuse the file.
41+
*
42+
* @var string
43+
*/
44+
public $bigFileUniqueId;
2745
}

src/Type/ChatType.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,14 @@ class ChatType
111111
*/
112112
public $stickerSetName;
113113

114+
/**
115+
* Optional. For supergroups, the minimum allowed delay between consecutive messages
116+
* sent by each unpriviledged user. Returned only in getChat.
117+
*
118+
* @var int|null
119+
*/
120+
public $slowModeDelay;
121+
114122
/**
115123
* Optional. True, if the bot can change the group sticker set. Returned only in getChat.
116124
*

src/Type/DocumentType.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ class DocumentType
1818
*/
1919
public $fileId;
2020

21+
/**
22+
* Unique identifier for this file, which is supposed to be the same over time and for different bots.
23+
* Can't be used to download or reuse the file.
24+
*
25+
* @var string
26+
*/
27+
public $fileUniqueId;
28+
2129
/**
2230
* Optional. Document thumbnail as defined by sender.
2331
*

src/Type/FileType.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ class FileType
2323
*/
2424
public $fileId;
2525

26+
/**
27+
* Unique identifier for this file, which is supposed to be the same over time and for different bots.
28+
* Can't be used to download or reuse the file.
29+
*
30+
* @var string
31+
*/
32+
public $fileUniqueId;
33+
2634
/**
2735
* Optional. File size, if known.
2836
*

src/Type/MessageEntityType.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@
1212
class MessageEntityType
1313
{
1414
/**
15-
* Type of the entity. Can be mention (@username), hashtag, cashtag, bot_command, url, email, phone_number,
16-
* bold (bold text), italic (italic text), code (monowidth string), pre (monowidth block),
17-
* text_link (for clickable text URLs), text_mention (for users without usernames).
15+
* Type of the entity. Can be “mention” (@username), “hashtag” (#hashtag), “cashtag” ($USD),
16+
* “bot_command” (/start@jobs_bot), “url” (https://telegram.org), “email” ([email protected]),
17+
* “phone_number” (+1-212-555-0123), “bold” (bold text), “italic” (italic text), “underline” (underlined text),
18+
* “strikethrough” (strikethrough text), “code” (monowidth string), “pre” (monowidth block),
19+
* “text_link” (for clickable text URLs), “text_mention” (for users without usernames).
1820
*
1921
* @var string
2022
*/

src/Type/PassportFileType.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ class PassportFileType
1818
*/
1919
public $fileId;
2020

21+
/**
22+
* Unique identifier for this file, which is supposed to be the same over time and for different bots.
23+
* Can't be used to download or reuse the file.
24+
*
25+
* @var string
26+
*/
27+
public $fileUniqueId;
28+
2129
/**
2230
* File size.
2331
*

src/Type/PhotoSizeType.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ class PhotoSizeType
1818
*/
1919
public $fileId;
2020

21+
/**
22+
* Unique identifier for this file, which is supposed to be the same over time and for different bots.
23+
* Can't be used to download or reuse the file.
24+
*
25+
* @var string
26+
*/
27+
public $fileUniqueId;
28+
2129
/**
2230
* Photo width.
2331
*

src/Type/StickerType.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ class StickerType
1818
*/
1919
public $fileId;
2020

21+
/**
22+
* Unique identifier for this file, which is supposed to be the same over time and for different bots.
23+
* Can't be used to download or reuse the file.
24+
*
25+
* @var string
26+
*/
27+
public $fileUniqueId;
28+
2129
/**
2230
* Sticker width.
2331
*

0 commit comments

Comments
 (0)