удалит опросы
This commit is contained in:
1 parent
4fa373742f
commit
e2ed0f3634
2 files changed
+72
-68
No files matched your search
@@ -54,6 +54,9 @@ CLEAR_COMMAND = True
|
|||||||
PROMPT_COMMAND = True
|
PROMPT_COMMAND = True
|
||||||
CONFIG_COMMAND = True
|
CONFIG_COMMAND = True
|
||||||
|
|
||||||
|
# хочешь ли ты чтобы узбекгпт отвечал ещё и опросами
|
||||||
|
POLLS = True
|
||||||
|
|
||||||
# /settings -> о боте
|
# /settings -> о боте
|
||||||
ABOUT_BOT = (
|
ABOUT_BOT = (
|
||||||
"✅ *об узбекгпт* ✅\n"
|
"✅ *об узбекгпт* ✅\n"
|
||||||
|
|||||||
@@ -436,76 +436,77 @@ async def guest_middleware(handler, event, data):
|
|||||||
document=file
|
document=file
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
if POLLS:
|
||||||
if ":" in result and ("poll" in result or "quiz" in result):
|
try:
|
||||||
pw = ["[poll]", "poll", "quiz"]
|
if ":" in result and ("poll" in result or "quiz" in result):
|
||||||
rl = result.split("\n")
|
pw = ["[poll]", "poll", "quiz"]
|
||||||
for i, line in enumerate(rl):
|
rl = result.split("\n")
|
||||||
if any(line.startswith(w) for w in pw):
|
for i, line in enumerate(rl):
|
||||||
rl = rl[i:]
|
if any(line.startswith(w) for w in pw):
|
||||||
break
|
rl = rl[i:]
|
||||||
poll_type = rl[0].split(":")[0].replace("[", "").replace("]", "")
|
break
|
||||||
poll_name = rl[0].split(":")[1]
|
poll_type = rl[0].split(":")[0].replace("[", "").replace("]", "")
|
||||||
if len(rl) > 1:
|
poll_name = rl[0].split(":")[1]
|
||||||
options = rl[1].split(" =| ")
|
if len(rl) > 1:
|
||||||
else:
|
options = rl[1].split(" =| ")
|
||||||
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, "гостевой режим не работает с опросами. либо добавь меня " \
|
|
||||||
"в группу, либо напиши мне в личку чтобы я выдал тебе опрос. ✅"
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
print(f"{RED} -- err poll {e} {RESET}")
|
options = ["варианты не указаны"]
|
||||||
return
|
correct_option = options[0]
|
||||||
|
correct_option_id = None
|
||||||
|
is_anon = True
|
||||||
|
allows_multiple_answers = False
|
||||||
|
|
||||||
if result and event.guest_message:
|
if event.guest_message:
|
||||||
await g_answer(message, "отправил опрос в личку, так как гостевой режим не работает с " \
|
mid = user_id
|
||||||
"опросами✅✅"
|
elif message.chat.type == "private":
|
||||||
)
|
mid = user_id
|
||||||
except Exception as e:
|
elif message.chat.type in ("group", "supergroup"):
|
||||||
print(f"{YELLOW} -- poll parsing - {e}{RESET}")
|
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 = (
|
kwargs = (
|
||||||
{"rich_message": InputRichMessage(markdown=result)}
|
{"rich_message": InputRichMessage(markdown=result)}
|
||||||
|
|||||||
Reference in new issue
Block a user