Put PollOption back in a separate file, its docstrings must be visible

This commit is contained in:
Dan 2018-12-24 14:19:21 +01:00
parent c4280f017e
commit c833b3842a
5 changed files with 52 additions and 18 deletions

View File

@ -32,7 +32,7 @@ from .client.types import (
Location, Message, MessageEntity, Dialog, Dialogs, Photo, PhotoSize, Sticker, User, UserStatus, Location, Message, MessageEntity, Dialog, Dialogs, Photo, PhotoSize, Sticker, User, UserStatus,
UserProfilePhotos, Venue, Animation, Video, VideoNote, Voice, CallbackQuery, Messages, ForceReply, UserProfilePhotos, Venue, Animation, Video, VideoNote, Voice, CallbackQuery, Messages, ForceReply,
InlineKeyboardButton, InlineKeyboardMarkup, KeyboardButton, ReplyKeyboardMarkup, ReplyKeyboardRemove, InlineKeyboardButton, InlineKeyboardMarkup, KeyboardButton, ReplyKeyboardMarkup, ReplyKeyboardRemove,
Poll Poll, PollOption
) )
from .client import ( from .client import (
Client, ChatAction, ParseMode, Emoji, Client, ChatAction, ParseMode, Emoji,

View File

@ -31,7 +31,7 @@ from .input_media import (
from .messages_and_media import ( from .messages_and_media import (
Audio, Contact, Document, Animation, Location, Photo, PhotoSize, Audio, Contact, Document, Animation, Location, Photo, PhotoSize,
Sticker, Venue, Video, VideoNote, Voice, UserProfilePhotos, Sticker, Venue, Video, VideoNote, Voice, UserProfilePhotos,
Message, Messages, MessageEntity, Poll Message, Messages, MessageEntity, Poll, PollOption
) )
from .user_and_chats import ( from .user_and_chats import (
Chat, ChatMember, ChatMembers, ChatPhoto, Chat, ChatMember, ChatMembers, ChatPhoto,

View File

@ -27,6 +27,7 @@ from .messages import Messages
from .photo import Photo from .photo import Photo
from .photo_size import PhotoSize from .photo_size import PhotoSize
from .poll import Poll from .poll import Poll
from .poll_option import PollOption
from .sticker import Sticker from .sticker import Sticker
from .user_profile_photos import UserProfilePhotos from .user_profile_photos import UserProfilePhotos
from .venue import Venue from .venue import Venue

View File

@ -20,25 +20,12 @@ from typing import List
import pyrogram import pyrogram
from pyrogram.api import types from pyrogram.api import types
from .poll_option import PollOption
from ..pyrogram_type import PyrogramType 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): class Poll(PyrogramType):
"""This object represents a Poll """This object represents a Poll.
Args: Args:
id (``int``): id (``int``):
@ -48,7 +35,7 @@ class Poll(PyrogramType):
Whether the poll is closed or not. Whether the poll is closed or not.
question (``str``): question (``str``):
Poll question Poll question.
options (List of :obj:`PollOption`): options (List of :obj:`PollOption`):
The available poll options. The available poll options.

View File

@ -0,0 +1,46 @@
# Pyrogram - Telegram MTProto API Client Library for Python
# Copyright (C) 2017-2018 Dan Tès <https://github.com/delivrance>
#
# 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 <http://www.gnu.org/licenses/>.
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