* Ultroid 2025 Co-authored-by: New-dev0 <New-dev0@users.noreply.github.com> Co-authored-by: Amit Sharma <buddhhu@users.noreply.github.com> Co-authored-by: TechiError <techierror@users.noreply.github.com> Co-authored-by: Aditya <me@xditya.me> Co-authored-by: 1Danish-00 <danish@ultroid.tech> Co-authored-by: Arnab Paryali <Arnabxd@users.noreply.github.com> Co-authored-by: hellboi_atul <hellboi-atul@users.noreply.github.com> Co-authored-by: sppidy <sppidy@users.noreply.github.com> by Devesh Pal
68 lines
2.3 KiB
Python
68 lines
2.3 KiB
Python
# Ultroid - UserBot
|
|
# Copyright (C) 2021-2025 TeamUltroid
|
|
#
|
|
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
|
|
# PLease read the GNU Affero General Public License in
|
|
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
|
|
"""
|
|
✘ Commands Available -
|
|
|
|
• `{i}poll <question> ; <option> ; <option>`
|
|
Get the Anonymous Poll with Given Options
|
|
|
|
• `{i}poll <question> ; <option> ; <option> | <type>`
|
|
Get the poll specified with desired type!
|
|
type should be any of `public`, `multiple` or `quiz`
|
|
|
|
• `{i}poll <question> ; <option> ; <option> | quiz_<answerno>`
|
|
Get the quiz poll where answerno is the number of option which is correct
|
|
|
|
"""
|
|
from telethon.tl.types import InputMediaPoll, Poll, PollAnswer, TextWithEntities
|
|
|
|
from . import get_string, ultroid_cmd
|
|
|
|
|
|
@ultroid_cmd(
|
|
pattern="poll( (.*)|$)",
|
|
)
|
|
async def uri_poll(e):
|
|
if not e.client._bot and e.is_private:
|
|
return await e.eor("`Use this in Group/Channel.`", time=15)
|
|
match = e.pattern_match.group(1).strip()
|
|
if not match:
|
|
return await e.eor("`Give Proper Input...`", time=5)
|
|
if ";" not in match:
|
|
return await e.eor("`Unable to Determine Options.`.", time=5)
|
|
ques = match.split(";")[0]
|
|
option = match.split(";")[1::]
|
|
publ = None
|
|
quizo = None
|
|
karzo = None
|
|
mpp = None
|
|
if "|" in match:
|
|
ptype = match.split(" | ")[1]
|
|
option = match.split("|")[0].split(";")[1::]
|
|
if "_" in ptype:
|
|
karzo = [str(int(ptype.split("_")[1]) - 1).encode()]
|
|
ptype = ptype.split("_")[0]
|
|
if ptype not in ["public", "quiz", "multiple"]:
|
|
return await e.eor("`Invalid Poll Type...`", time=5)
|
|
if ptype == "multiple":
|
|
mpp = True
|
|
elif ptype == "public":
|
|
publ = True
|
|
elif ptype == "quiz":
|
|
quizo = True
|
|
if len(option) <= 1:
|
|
return await e.eor("`Options Should be More than 1..`", time=5)
|
|
m = await e.eor(get_string("com_1"))
|
|
OUT = [PollAnswer(TextWithEntities(option[on], entities=[]), str(on).encode()) for on in range(len(option))]
|
|
await e.respond(
|
|
file=InputMediaPoll(
|
|
Poll(20, TextWithEntities(ques, entities=[]), OUT, multiple_choice=mpp, public_voters=publ, quiz=quizo),
|
|
correct_answers=karzo,
|
|
),
|
|
)
|
|
await m.delete()
|