reduce useless code da.

This commit is contained in:
huker667 committed 2026-07-16 12:51:07 +03:00
1 parent b958bddcfb
commit bbad4ff2c3
2 files changed
+78 -79

No files matched your search

+1 -1
View File
@@ -21,7 +21,7 @@ def is_blocked(user_id):
if time_diff < 3: if time_diff < 3:
alo = "🚫 *файл не вошёл.* хватит так быстро слать свои сообщения.\n" \ alo = "🚫 *файл не вошёл.* хватит так быстро слать свои сообщения.\n" \
f"подожди {round(3 - time_diff, 3)} секунд, брат😡😡" f"подожди {round(3 - time_diff, 3)} секунд, брат😡😡"
elif last_command_time[user_id][1] and time_diff < 10: elif last_command_time[user_id][1] and time_diff < 5:
alo = "🚫 *файл не вошёл.* я ещё не сгенерировал прошлое сообщение.\n" \ alo = "🚫 *файл не вошёл.* я ещё не сгенерировал прошлое сообщение.\n" \
f"подожди {round(10 - time_diff, 3)} секунд, чтобы я закрыл глаза " \ f"подожди {round(10 - time_diff, 3)} секунд, чтобы я закрыл глаза " \
"на это da." "на это da."
+77 -78
View File
@@ -153,6 +153,12 @@ async def guest_middleware(handler, event, data):
elif replied and replied.voice: elif replied and replied.voice:
voice = replied.voice voice = replied.voice
location = None
if message.location:
location = message.location
elif replied and replied.voice:
location = replied.location
if voice: if voice:
if voice.duration > 60: if voice.duration > 60:
da = "не врат не пойдёт такой длинный голосовой сообщение" \ da = "не врат не пойдёт такой длинный голосовой сообщение" \
@@ -224,20 +230,11 @@ async def guest_middleware(handler, event, data):
print(f"{RED} -- {e}{RESET}") print(f"{RED} -- {e}{RESET}")
return return
if replied and replied.location: if location:
loc = replied.location
prompt += ( prompt += (
f"<ответ на локацию>\n" f"<геолокация>\n"
f"{loc.latitude}, {loc.longitude}\n" f"{location.latitude}, {location.longitude}\n"
f"</ответ на локацию>\n" f"</геолокация>\n"
)
if message.location:
loc = message.location
prompt += (
f"<локация>\n"
f"{loc.latitude}, {loc.longitude}\n"
f"</локация>\n"
) )
if replied and replied.poll: if replied and replied.poll:
@@ -376,74 +373,76 @@ async def guest_middleware(handler, event, data):
last_command_time[user_id][1] = False last_command_time[user_id][1] = False
last_command_time[user_id][2] = [] last_command_time[user_id][2] = []
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"
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
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"
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}")
else:
return return
kwargs = ( kwargs = (
@@ -491,7 +490,7 @@ async def guest_middleware(handler, event, data):
else: else:
await message.reply(**kwargs) await message.reply(**kwargs)
except Exception as e: except Exception as e:
print(f"{RED} -- send guest - {e}{RESET}") print(f"{RED} -- send msg - {e}{RESET}")
else: else:
print(f"{YELLOW} -- markdown - {e}{RESET}") print(f"{YELLOW} -- markdown - {e}{RESET}")
return return