Team Ai
Apppublic

azils3/bash

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes
polls.py68 linesDownload Raw Back to plugins
1# Ultroid - UserBot2# Copyright (C) 2021-2025 TeamUltroid3#4# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >5# PLease read the GNU Affero General Public License in6# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.7"""8✘ Commands Available -9 10• `{i}poll <question> ; <option> ; <option>`11    Get the Anonymous Poll with Given Options12 13• `{i}poll <question> ; <option> ; <option> | <type>`14    Get the poll specified with desired type!15    type should be any of  `public`,  `multiple` or `quiz`16 17• `{i}poll <question> ; <option> ; <option> | quiz_<answerno>`18    Get the quiz poll where answerno is the number of option which is correct19 20"""21from telethon.tl.types import InputMediaPoll, Poll, PollAnswer, TextWithEntities22 23from . import get_string, ultroid_cmd24 25 26@ultroid_cmd(27    pattern="poll( (.*)|$)",28)29async def uri_poll(e):30    if not e.client._bot and e.is_private:31        return await e.eor("`Use this in Group/Channel.`", time=15)32    match = e.pattern_match.group(1).strip()33    if not match:34        return await e.eor("`Give Proper Input...`", time=5)35    if ";" not in match:36        return await e.eor("`Unable to Determine Options.`.", time=5)37    ques = match.split(";")[0]38    option = match.split(";")[1::]39    publ = None40    quizo = None41    karzo = None42    mpp = None43    if "|" in match:44        ptype = match.split(" | ")[1]45        option = match.split("|")[0].split(";")[1::]46        if "_" in ptype:47            karzo = [str(int(ptype.split("_")[1]) - 1).encode()]48            ptype = ptype.split("_")[0]49        if ptype not in ["public", "quiz", "multiple"]:50            return await e.eor("`Invalid Poll Type...`", time=5)51        if ptype == "multiple":52            mpp = True53        elif ptype == "public":54            publ = True55        elif ptype == "quiz":56            quizo = True57    if len(option) <= 1:58        return await e.eor("`Options Should be More than 1..`", time=5)59    m = await e.eor(get_string("com_1"))60    OUT = [PollAnswer(TextWithEntities(option[on], entities=[]), str(on).encode()) for on in range(len(option))]61    await e.respond(62        file=InputMediaPoll(63            Poll(20, TextWithEntities(ques, entities=[]), OUT, multiple_choice=mpp, public_voters=publ, quiz=quizo),64            correct_answers=karzo,65        ),66    )67    await m.delete()68