удалит опросы

This commit is contained in:
huker667 committed 2026-08-10 12:39:18 +03:00
1 parent 4fa373742f
commit e2ed0f3634
2 files changed
+72 -68

No files matched your search

+3
View File
@@ -54,6 +54,9 @@ CLEAR_COMMAND = True
PROMPT_COMMAND = True
CONFIG_COMMAND = True
# хочешь ли ты чтобы узбекгпт отвечал ещё и опросами
POLLS = True
# /settings -> о боте
ABOUT_BOT = (
"✅ *об узбекгпт* ✅\n"
+69 -68
View File
@@ -436,76 +436,77 @@ async def guest_middleware(handler, event, data):
document=file
)
try:
if ":" in result and ("poll" in result or "quiz" in result):
pw = ["[poll]", "poll", "quiz"]
rl = result.split("\n")
for i, line in enumerate(rl):
if any(line.startswith(w) for w in pw):
rl = rl[i:]
break
poll_type = rl[0].split(":")[0].replace("[", "").replace("]", "")
poll_name = rl[0].split(":")[1]
if len(rl) > 1:
options = rl[1].split(" =| ")
else:
options = ["варианты не указаны"]
correct_option = options[0]
correct_option_id = None
is_anon = True
allows_multiple_answers = False
if event.guest_message:
mid = user_id
elif message.chat.type == "private":
mid = user_id
elif message.chat.type in ("group", "supergroup"):
mid = message.chat.id
else:
return
if poll_type == "quiz":
shuffle(options)
correct_option_id = options.index(correct_option)
elif poll_type == "poll":
poll_type = "regular"
allows_multiple_answers = False
elif poll_type == "multipoll":
poll_type = "regular"
allows_multiple_answers = True
else:
poll_type = "regular"
if msg:
await msg.delete()
try:
result = await answer_poll(
data=data,
message=message,
question=poll_name,
options=options,
is_anonymous=is_anon,
poll_type=poll_type,
allows_multiple_answers=allows_multiple_answers,
correct_option_id=correct_option_id,
user_id=mid
)
except Exception as e:
if event.guest_message:
await g_answer(message, "гостевой режим не работает с опросами. либо добавь меня " \
"в группу, либо напиши мне в личку чтобы я выдал тебе опрос. ✅"
)
if POLLS:
try:
if ":" in result and ("poll" in result or "quiz" in result):
pw = ["[poll]", "poll", "quiz"]
rl = result.split("\n")
for i, line in enumerate(rl):
if any(line.startswith(w) for w in pw):
rl = rl[i:]
break
poll_type = rl[0].split(":")[0].replace("[", "").replace("]", "")
poll_name = rl[0].split(":")[1]
if len(rl) > 1:
options = rl[1].split(" =| ")
else:
print(f"{RED} -- err poll {e} {RESET}")
return
options = ["варианты не указаны"]
correct_option = options[0]
correct_option_id = None
is_anon = True
allows_multiple_answers = False
if result and event.guest_message:
await g_answer(message, "отправил опрос в личку, так как гостевой режим не работает с " \
"опросами✅✅"
)
except Exception as e:
print(f"{YELLOW} -- poll parsing - {e}{RESET}")
if event.guest_message:
mid = user_id
elif message.chat.type == "private":
mid = user_id
elif message.chat.type in ("group", "supergroup"):
mid = message.chat.id
else:
return
if poll_type == "quiz":
shuffle(options)
correct_option_id = options.index(correct_option)
elif poll_type == "poll":
poll_type = "regular"
allows_multiple_answers = False
elif poll_type == "multipoll":
poll_type = "regular"
allows_multiple_answers = True
else:
poll_type = "regular"
if msg:
await msg.delete()
try:
result = await answer_poll(
data=data,
message=message,
question=poll_name,
options=options,
is_anonymous=is_anon,
poll_type=poll_type,
allows_multiple_answers=allows_multiple_answers,
correct_option_id=correct_option_id,
user_id=mid
)
except Exception as e:
if event.guest_message:
await g_answer(message, "гостевой режим не работает с опросами. либо добавь меня " \
"в группу, либо напиши мне в личку чтобы я выдал тебе опрос. ✅"
)
else:
print(f"{RED} -- err poll {e} {RESET}")
return
if result and event.guest_message:
await g_answer(message, "отправил опрос в личку, так как гостевой режим не работает с " \
"опросами✅✅"
)
except Exception as e:
print(f"{YELLOW} -- poll parsing - {e}{RESET}")
kwargs = (
{"rich_message": InputRichMessage(markdown=result)}