Skip to content

Commit

Permalink
Update quizgame.py
Browse files Browse the repository at this point in the history
  • Loading branch information
New-dev0 authored May 16, 2024
1 parent 5f4d2a4 commit aff7fdb
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions plugins/quizgame.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
from random import choice, shuffle

from core.decorators._assistant import asst_cmd, callback
from telethon import TelegramClient
from telethon.errors import ChatSendStickersForbiddenError
from telethon.events import Raw
from telethon.events import Raw, NewMessage, CallbackQuery
from telethon.tl.functions.messages import SendMediaRequest
from telethon.tl.types import (InputMediaPoll, Poll, PollAnswer,
UpdateMessagePollVote)
from telethon.tl.types import InputMediaPoll, Poll, PollAnswer, UpdateMessagePollVote

from .. import Button, asst, async_searcher, get_string, inline_mention

Expand Down Expand Up @@ -55,7 +55,7 @@ async def ct_spam(e):


@callback(re.compile("trzia(.*)"), owner=True)
async def choose_cata(event):
async def choose_cata(event: CallbackQuery.Event):
match = event.data_match.group(1).decode("utf-8")
if not match:
if TR_BTS.get("category"):
Expand Down Expand Up @@ -85,14 +85,12 @@ async def choose_cata(event):
text = get_string("games_3")
elif match[0] == "c":
m = match[1:]
buttons = [
[Button.inline(str(i), f"trziat{m}_{i}") for i in range(10, 70, 20)]]
buttons = [[Button.inline(str(i), f"trziat{m}_{i}") for i in range(10, 70, 20)]]
text = get_string("games_4")
elif match[0] == "t":
m_ = match[1:]
buttons = [
[Button.inline(str(i), f"trzias{m_}_{i}")
for i in [10, 30, 60, 120]]
[Button.inline(str(i), f"trzias{m_}_{i}") for i in [10, 30, 60, 120]]
]
text = get_string("games_5")
elif match[0] == "s":
Expand Down Expand Up @@ -122,9 +120,7 @@ async def choose_cata(event):
opts = [PollAnswer(unescape(q["correct_answer"]), ansi)]
[
opts.append(
PollAnswer(
unescape(a), str(
uuid.uuid1()).split("-")[0].encode())
PollAnswer(unescape(a), str(uuid.uuid1()).split("-")[0].encode())
)
for a in q["incorrect_answers"]
]
Expand All @@ -142,9 +138,12 @@ async def choose_cata(event):
solution="Join @TeamUltroid",
solution_entities=[],
)
m_ = await event.client(SendMediaRequest(chat, media=poll))
POLLS.update(
{m_.poll.poll.id: {"chat": m_.chat_id, "answer": ansi}})
m_ = await event.client(SendMediaRequest(chat, media=poll,
message=""))
client: TelegramClient = event.client
input_chat = await event.get_input_chat()
m_ = client._get_response_message(None, m_, input_chat)
POLLS.update({m_.poll.poll.id: {"chat": m_.chat_id, "answer": ansi}})
await asyncio.sleep(int(in_))
if not TRIVIA_CHATS[chat]:
await event.respond(
Expand Down

0 comments on commit aff7fdb

Please sign in to comment.