forked from SpEcHiDe/UniBorg
-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathpolls.py
34 lines (32 loc) · 1.27 KB
/
polls.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"""Get Poll Info on non supported clients
Syntax: .get_poll"""
from telethon import events
import asyncio
from uniborg.util import admin_cmd
@borg.on(admin_cmd("get_poll"))
async def _(event):
reply_message = await event.get_reply_message()
if reply_message.media is None:
await event.edit("Please reply to a media_type == @gPoll to view the questions and answers")
elif reply_message.media.poll is None:
await event.edit("Please reply to a media_type == @gPoll to view the questions and answers")
else:
media = reply_message.media
poll = media.poll
closed_status = poll.closed
answers = poll.answers
question = poll.question
edit_caption = """Poll is Closed: {}
Question: {}
Answers: \n""".format(closed_status, question)
if closed_status:
results = media.results
i = 0
for result in results.results:
edit_caption += "{}> {} {}\n".format(result.option, answers[i].text, result.voters)
i += 1
edit_caption += "Total Voters: {}".format(results.total_voters)
else:
for answer in answers:
edit_caption += "{}> {}\n".format(answer.option, answer.text)
await event.edit(edit_caption)