Skip to content

Commit 2386eee

Browse files
committed
Added Giveaway media support
1 parent 69cbd59 commit 2386eee

4 files changed

Lines changed: 499 additions & 416 deletions

File tree

pyrogram/enums/message_media_type.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,6 @@ class MessageMediaType(AutoName):
7171

7272
STORY = auto()
7373
"Story media"
74+
75+
GIVEAWAY = auto()
76+
"Giveaway media"

pyrogram/types/messages_and_media/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from .dice import Dice
2323
from .document import Document
2424
from .game import Game
25+
from .giveaway import Giveaway
2526
from .location import Location
2627
from .message import Message
2728
from .message_entity import MessageEntity
@@ -44,5 +45,5 @@
4445
__all__ = [
4546
"Animation", "Audio", "Contact", "Document", "Game", "Location", "Message", "MessageEntity", "Photo", "Thumbnail",
4647
"StrippedThumbnail", "Poll", "PollOption", "Sticker", "Venue", "Video", "VideoNote", "Voice", "WebPage", "Dice",
47-
"Reaction", "WebAppData", "MessageReactions", "Story"
48+
"Reaction", "WebAppData", "MessageReactions", "Story", "Giveaway"
4849
]
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Pyrogram - Telegram MTProto API Client Library for Python
2+
# Copyright (C) 2017-present Dan <https://github.com/delivrance>
3+
#
4+
# This file is part of Pyrogram.
5+
#
6+
# Pyrogram is free software: you can redistribute it and/or modify
7+
# it under the terms of the GNU Lesser General Public License as published
8+
# by the Free Software Foundation, either version 3 of the License, or
9+
# (at your option) any later version.
10+
#
11+
# Pyrogram is distributed in the hope that it will be useful,
12+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
# GNU Lesser General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU Lesser General Public License
17+
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
18+
19+
import pyrogram
20+
from pyrogram import raw
21+
from ..object import Object
22+
23+
24+
class Giveaway(Object):
25+
"""A Giveaway.
26+
27+
Parameters:
28+
client (pyrogram.Client): Pyrogram client
29+
channels (List of ``int`` ``64-bit``):
30+
quantity (``int`` ``32-bit``):
31+
months (``int`` ``32-bit``):
32+
until_date (``int`` ``32-bit``):
33+
only_new_subscribers (``bool``, *optional*):
34+
countries_iso2 (List of ``str``, *optional*):
35+
36+
"""
37+
38+
def __init__(
39+
self,
40+
*,
41+
client: "pyrogram.Client" = None,
42+
channels,
43+
quantity,
44+
months,
45+
until_date,
46+
only_new_subscribers,
47+
countries_iso2,
48+
):
49+
super().__init__(client)
50+
51+
self.channels = channels
52+
self.quantity = quantity
53+
self.months = months
54+
self.until_date = until_date
55+
self.only_new_subscribers = only_new_subscribers
56+
self.countries_iso2 = countries_iso2
57+
58+
@staticmethod
59+
def _parse(client, giveaway: "raw.types.MessageMediaGiveaway"):
60+
return Giveaway(
61+
client=client,
62+
channels=giveaway.channels,
63+
quantity=giveaway.quantity,
64+
months=giveaway.months,
65+
until_date=giveaway.until_date,
66+
only_new_subscribers=giveaway.only_new_subscribers,
67+
countries_iso2=giveaway.countries_iso2
68+
)

0 commit comments

Comments
 (0)