Skip to content

Commit f3800e9

Browse files
committed
Bot API 7.0 - Giveaway
1 parent c2ec524 commit f3800e9

File tree

5 files changed

+118
-0
lines changed

5 files changed

+118
-0
lines changed

src/Entities/Giveaway/Giveaway.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
namespace Longman\TelegramBot\Entities\Giveaway;
4+
5+
use Longman\TelegramBot\Entities\Chat;
6+
use Longman\TelegramBot\Entities\Entity;
7+
8+
/**
9+
* This object represents a message about a scheduled giveaway.
10+
*
11+
* @link https://core.telegram.org/bots/api#giveaway
12+
*
13+
* @method array<Chat> getChats() The list of chats which the user must join to participate in the giveaway
14+
* @method int getWinnersSelectionDate() Point in time (Unix timestamp) when winners of the giveaway will be selected
15+
* @method int getWinnerCount() The number of users which are supposed to be selected as winners of the giveaway
16+
* @method bool getOnlyNewMembers() Optional. True, if only users who join the chats after the giveaway started should be eligible to win
17+
* @method bool getHasPublicWinners() Optional. True, if the list of giveaway winners will be visible to everyone
18+
* @method string getPrizeDescription() Optional. Description of additional giveaway prize
19+
* @method array<string> getCountryCodes() Optional. A list of two-letter ISO 3166-1 alpha-2 country codes indicating the countries from which eligible users for the giveaway must come. If empty, then all users can participate in the giveaway. Users with a phone number that was bought on Fragment can always participate in giveaways.
20+
* @method int getPremiumSubscriptionMonthCount() Optional. The number of months the Telegram Premium subscription won from the giveaway will be active for
21+
22+
*
23+
*/
24+
class Giveaway extends Entity
25+
{
26+
27+
protected function subEntities(): array
28+
{
29+
return [
30+
'chats' => [Chat::class],
31+
];
32+
}
33+
34+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
namespace Longman\TelegramBot\Entities\Giveaway;
4+
5+
use Longman\TelegramBot\Entities\Entity;
6+
use Longman\TelegramBot\Entities\Message;
7+
8+
/**
9+
* This object represents a service message about the completion of a giveaway without public winners.
10+
*
11+
* @link https://core.telegram.org/bots/api#giveawaycompleted
12+
*
13+
* @method int getWinnerCount() Number of winners in the giveaway
14+
* @method int getUnclaimedPrizeCount() Optional. Number of undistributed prizes
15+
* @method Message getGiveawayMessage() Optional. Message with the giveaway that was completed, if it wasn't deleted
16+
*/
17+
class GiveawayCompleted extends Entity
18+
{
19+
20+
protected function subEntities(): array
21+
{
22+
return [
23+
'giveaway_message' => Message::class,
24+
];
25+
}
26+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace Longman\TelegramBot\Entities\Giveaway;
4+
5+
use Longman\TelegramBot\Entities\Entity;
6+
7+
class GiveawayCreated extends Entity
8+
{
9+
10+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
namespace Longman\TelegramBot\Entities\Giveaway;
4+
5+
use Longman\TelegramBot\Entities\Chat;
6+
use Longman\TelegramBot\Entities\Entity;
7+
use Longman\TelegramBot\Entities\User;
8+
9+
/**
10+
* This object represents a message about the completion of a giveaway with public winners.
11+
*
12+
* @link https://core.telegram.org/bots/api#giveawaywinners
13+
*
14+
* @method Chat getChat() The chat that created the giveaway
15+
* @method int getGiveawayMessageId() Identifier of the message with the giveaway in the chat
16+
* @method int getWinnersSelectionDate() Point in time (Unix timestamp) when winners of the giveaway were selected
17+
* @method int getWinnerCount() Total number of winners in the giveaway
18+
* @method array<User> getWinners() List of up to 100 winners of the giveaway
19+
* @method int getAdditionalChatCount() Optional. The number of other chats the user had to join in order to be eligible for the giveaway
20+
* @method int getPremiumSubscriptionMonthCount() Optional. The number of months the Telegram Premium subscription won from the giveaway will be active for
21+
* @method int getUnclaimedPrizeCount() Optional. Number of undistributed prizes
22+
* @method bool getOnlyNewMembers() Optional. True, if only users who had joined the chats after the giveaway started were eligible to win
23+
* @method bool getWasRefunded() Optional. True, if the giveaway was canceled because the payment for it was refunded
24+
* @method string getPrizeDescription() Optional. Description of additional giveaway prize
25+
*/
26+
class GiveawayWinners extends Entity
27+
{
28+
29+
protected function subEntities(): array
30+
{
31+
return [
32+
'chat' => Chat::class,
33+
'winners' => [User::class],
34+
];
35+
}
36+
}

src/Entities/Message.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
namespace Longman\TelegramBot\Entities;
1313

1414
use Longman\TelegramBot\Entities\Games\Game;
15+
use Longman\TelegramBot\Entities\Giveaway\Giveaway;
16+
use Longman\TelegramBot\Entities\Giveaway\GiveawayCompleted;
17+
use Longman\TelegramBot\Entities\Giveaway\GiveawayCreated;
18+
use Longman\TelegramBot\Entities\Giveaway\GiveawayWinners;
1519
use Longman\TelegramBot\Entities\Message\Factory as MaybeInaccessibleMessageFactory;
1620
use Longman\TelegramBot\Entities\Message\MaybeInaccessibleMessage;
1721
use Longman\TelegramBot\Entities\MessageOrigin\Factory as MessageOriginFactory;
@@ -96,6 +100,10 @@
96100
* @method ForumTopicReopened getForumTopicReopened() Optional. Service message: forum topic reopened
97101
* @method GeneralForumTopicHidden getGeneralForumTopicHidden() Optional. Service message: the 'General' forum topic hidden
98102
* @method GeneralForumTopicUnhidden getGeneralForumTopicUnhidden() Optional. Service message: the 'General' forum topic unhidden
103+
* @method GiveawayCreated getGiveawayCreated() Optional. Service message: a scheduled giveaway was created
104+
* @method Giveaway getGiveaway() Optional. The message is a scheduled giveaway message
105+
* @method GiveawayWinners getGiveawayWinners() Optional. A giveaway with public winners was completed
106+
* @method GiveawayCompleted getGiveawayCompleted() Optional. Service message: a giveaway without public winners was completed
99107
* @method VideoChatScheduled getVideoChatScheduled() Optional. Service message: voice chat scheduled
100108
* @method VideoChatStarted getVideoChatStarted() Optional. Service message: voice chat started
101109
* @method VideoChatEnded getVideoChatEnded() Optional. Service message: voice chat ended
@@ -155,6 +163,10 @@ protected function subEntities(): array
155163
'forum_topic_reopened' => ForumTopicReopened::class,
156164
'general_forum_topic_hidden' => GeneralForumTopicHidden::class,
157165
'general_forum_topic_unhidden' => GeneralForumTopicUnhidden::class,
166+
'giveaway_created' => GiveawayCreated::class,
167+
'giveaway' => Giveaway::class,
168+
'giveaway_winners' => GiveawayWinners::class,
169+
'giveaway_completed' => GiveawayCompleted::class,
158170
'video_chat_scheduled' => VideoChatScheduled::class,
159171
'video_chat_started' => VideoChatStarted::class,
160172
'video_chat_ended' => VideoChatEnded::class,

0 commit comments

Comments
 (0)