diff --git a/pyrogram/__init__.py b/pyrogram/__init__.py index b2f930b3..94b6c951 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, PollAnswer + Poll ) from .client import ( Client, ChatAction, ParseMode, Emoji, diff --git a/pyrogram/client/types/__init__.py b/pyrogram/client/types/__init__.py index 0fdfc685..983c3804 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, PollAnswer + Message, Messages, MessageEntity, Poll ) 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 527fee27..d77b3494 100644 --- a/pyrogram/client/types/messages_and_media/__init__.py +++ b/pyrogram/client/types/messages_and_media/__init__.py @@ -27,7 +27,6 @@ from .messages import Messages from .photo import Photo from .photo_size import PhotoSize from .poll import Poll -from .poll_answer import PollAnswer 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 2e3c3d1a..a7277f49 100644 --- a/pyrogram/client/types/messages_and_media/poll.py +++ b/pyrogram/client/types/messages_and_media/poll.py @@ -20,10 +20,21 @@ from typing import List import pyrogram from pyrogram.api import types -from .poll_answer import PollAnswer from ..pyrogram_type import PyrogramType +class PollOption(PyrogramType): + def __init__(self, + *, + client: "pyrogram.client.ext.BaseClient", + text: str, + voters: int): + super().__init__(client) + + self.text = text + self.voters = voters + + class Poll(PyrogramType): def __init__(self, *, @@ -31,16 +42,16 @@ class Poll(PyrogramType): id: int, closed: bool, question: str, - answers: List[PollAnswer], - answer_chosen: int = None, + options: List[PollOption], + option_chosen: int = None, total_voters: int): super().__init__(client) self.id = id self.closed = closed self.question = question - self.answers = answers - self.answer_chosen = answer_chosen + self.options = options + self.option_chosen = option_chosen self.total_voters = total_voters @staticmethod @@ -48,21 +59,21 @@ class Poll(PyrogramType): poll = media_poll.poll results = media_poll.results.results total_voters = media_poll.results.total_voters - answer_chosen = None + option_chosen = None - answers = [] + options = [] for i, answer in enumerate(poll.answers): - voters = None + voters = 0 if results: result = results[i] voters = result.voters if result.chosen: - answer_chosen = i + option_chosen = i - answers.append(PollAnswer( + options.append(PollOption( text=answer.text, voters=voters, client=client @@ -72,8 +83,8 @@ class Poll(PyrogramType): id=poll.id, closed=poll.closed, question=poll.question, - answers=answers, - answer_chosen=answer_chosen, + options=options, + option_chosen=option_chosen, total_voters=total_voters, client=client ) diff --git a/pyrogram/client/types/messages_and_media/poll_answer.py b/pyrogram/client/types/messages_and_media/poll_answer.py deleted file mode 100644 index a9dbc513..00000000 --- a/pyrogram/client/types/messages_and_media/poll_answer.py +++ /dev/null @@ -1,32 +0,0 @@ -# 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 PollAnswer(PyrogramType): - def __init__(self, - *, - client: "pyrogram.client.ext.BaseClient", - text: str, - voters: int = None): - super().__init__(client) - - self.text = text - self.voters = voters