aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhuker667 <huker@tuta.io>2026-08-10 12:39:18 +0300
committerhuker667 <huker@tuta.io>2026-08-10 12:39:18 +0300
commite2ed0f36345c9669b3d8c5ca180878bc35e44c6c (patch)
treed75936dd75d1da4dd209f075f69328bb04732527
parent4fa373742fa930d875b458913f1a2d69b7a8ac65 (diff)
downloaduzbekgpt-e2ed0f36345c9669b3d8c5ca180878bc35e44c6c.tar.gz
uzbekgpt-e2ed0f36345c9669b3d8c5ca180878bc35e44c6c.tar.bz2
uzbekgpt-e2ed0f36345c9669b3d8c5ca180878bc35e44c6c.zip
удалит опросы
-rw-r--r--config_def.py3
-rw-r--r--main.py133
2 files changed, 70 insertions, 66 deletions
diff --git a/config_def.py b/config_def.py
index 4702c57..f64c6b5 100644
--- a/config_def.py
+++ b/config_def.py
@@ -54,6 +54,9 @@ CLEAR_COMMAND = True
PROMPT_COMMAND = True
CONFIG_COMMAND = True
+# хочешь ли ты чтобы узбекгпт отвечал ещё и опросами
+POLLS = True
+
# /settings -> о боте
ABOUT_BOT = (
"✅ *об узбекгпт* ✅\n"
diff --git a/main.py b/main.py
index 4c16764..bad8776 100644
--- a/main.py
+++ b/main.py
@@ -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"
+ 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:
+ options = ["варианты не указаны"]
+ correct_option = options[0]
+ correct_option_id = None
+ is_anon = True
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, "гостевой режим не работает с опросами. либо добавь меня " \
- "в группу, либо напиши мне в личку чтобы я выдал тебе опрос. ✅"
- )
+ mid = user_id
+ elif message.chat.type == "private":
+ mid = user_id
+ elif message.chat.type in ("group", "supergroup"):
+ mid = message.chat.id
else:
- print(f"{RED} -- err poll {e} {RESET}")
- return
+ return
- if result and event.guest_message:
- await g_answer(message, "отправил опрос в личку, так как гостевой режим не работает с " \
- "опросами✅✅"
- )
- except Exception as e:
- print(f"{YELLOW} -- poll parsing - {e}{RESET}")
+ 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)}