diff --git a/pyrogram/__init__.py b/pyrogram/__init__.py index 94b6c951..6400abc1 100644 --- a/pyrogram/__init__.py +++ b/pyrogram/__init__.py @@ -32,7 +32,7 @@ from .client.types import ( Location, Message, MessageEntity, Dialog, Dialogs, Photo, PhotoSize, Sticker, User, UserStatus, UserProfilePhotos, Venue, Animation, Video, VideoNote, Voice, CallbackQuery, Messages, ForceReply, InlineKeyboardButton, InlineKeyboardMarkup, KeyboardButton, ReplyKeyboardMarkup, ReplyKeyboardRemove, - Poll + Poll, PollOption ) from .client import ( Client, ChatAction, ParseMode, Emoji, diff --git a/pyrogram/client/types/__init__.py b/pyrogram/client/types/__init__.py index 983c3804..24de120f 100644 --- a/pyrogram/client/types/__init__.py +++ b/pyrogram/client/types/__init__.py @@ -31,7 +31,7 @@ from .input_media import ( from .messages_and_media import ( Audio, Contact, Document, Animation, Location, Photo, PhotoSize, Sticker, Venue, Video, VideoNote, Voice, UserProfilePhotos, - Message, Messages, MessageEntity, Poll + Message, Messages, MessageEntity, Poll, PollOption ) from .user_and_chats import ( Chat, ChatMember, ChatMembers, ChatPhoto, diff --git a/pyrogram/client/types/messages_and_media/__init__.py b/pyrogram/client/types/messages_and_media/__init__.py index d77b3494..d402ae48 100644 --- a/pyrogram/client/types/messages_and_media/__init__.py +++ b/pyrogram/client/types/messages_and_media/__init__.py @@ -27,6 +27,7 @@ from .messages import Messages from .photo import Photo from .photo_size import PhotoSize from .poll import Poll +from .poll_option import PollOption from .sticker import Sticker from .user_profile_photos import UserProfilePhotos from .venue import Venue diff --git a/pyrogram/client/types/messages_and_media/poll.py b/pyrogram/client/types/messages_and_media/poll.py index 9e1f481d..ab59b1ad 100644 --- a/pyrogram/client/types/messages_and_media/poll.py +++ b/pyrogram/client/types/messages_and_media/poll.py @@ -20,25 +20,12 @@ from typing import List import pyrogram from pyrogram.api import types +from .poll_option import PollOption from ..pyrogram_type import PyrogramType -class PollOption(PyrogramType): - def __init__(self, - *, - client: "pyrogram.client.ext.BaseClient", - text: str, - voters: int, - data: bytes): - super().__init__(client) - - self.text = text - self.voters = voters - self._data = data - - class Poll(PyrogramType): - """This object represents a Poll + """This object represents a Poll. Args: id (``int``): @@ -48,7 +35,7 @@ class Poll(PyrogramType): Whether the poll is closed or not. question (``str``): - Poll question + Poll question. options (List of :obj:`PollOption`): The available poll options. diff --git a/pyrogram/client/types/messages_and_media/poll_option.py b/pyrogram/client/types/messages_and_media/poll_option.py new file mode 100644 index 00000000..175b3701 --- /dev/null +++ b/pyrogram/client/types/messages_and_media/poll_option.py @@ -0,0 +1,46 @@ +# Pyrogram - Telegram MTProto API Client Library for Python +# Copyright (C) 2017-2018 Dan Tès +# +# This file is part of Pyrogram. +# +# Pyrogram is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published +# by the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Pyrogram is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with Pyrogram. If not, see . + +import pyrogram +from ..pyrogram_type import PyrogramType + + +class PollOption(PyrogramType): + def __init__(self, + *, + client: "pyrogram.client.ext.BaseClient", + text: str, + voters: int, + data: bytes): + """This object represents a Poll Option. + + Args: + text (``str``): + Text of the poll option. + + voters (``int``): + The number of users who voted this option. + + data (``bytes``): + Unique data that identifies this option (among all the other options in a poll). + """ + super().__init__(client) + + self.text = text + self.voters = voters + self.data = data