diff options
| author | huker667 <huker@tuta.io> | 2026-05-24 22:26:14 +0300 |
|---|---|---|
| committer | huker667 <huker@tuta.io> | 2026-05-24 22:26:14 +0300 |
| commit | e0a29460aad1824b2582450462063054a0f37ece (patch) | |
| tree | ac8d154bbe8c16b65b42e60c0697286cf881d030 /helpers.py | |
| parent | 9733c264e9c2d44a19b8b3d87a9b070311926771 (diff) | |
| download | uzbekgpt-e0a29460aad1824b2582450462063054a0f37ece.tar.gz uzbekgpt-e0a29460aad1824b2582450462063054a0f37ece.tar.bz2 uzbekgpt-e0a29460aad1824b2582450462063054a0f37ece.zip | |
da mensh code
Diffstat (limited to 'helpers.py')
| -rw-r--r-- | helpers.py | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/helpers.py b/helpers.py new file mode 100644 index 0000000..f4ea3cd --- /dev/null +++ b/helpers.py @@ -0,0 +1,59 @@ +import time + +from aiogram.methods import AnswerGuestQuery +from aiogram.types import InlineQueryResultArticle, InputTextMessageContent, Message +from aiogram.enums import ChatType + +from supergenerator import * + + +def is_blocked(user_id): + current_time = time.time() + if user_id: + if user_id in last_command_time: + time_diff = current_time - last_command_time[user_id] + if time_diff < 3: + alo = "🚫 *файл не вошёл.* хватит так быстро слать свои сообщения.\n" \ + f"подожди {round(3 - time_diff, 3)} секунд, брат😡😡" + return alo, True + return "", False + + +def is_replied_bot(message, is_channel, user_text, config=None): + if message.chat.type in [ChatType.GROUP, ChatType.SUPERGROUP, ChatType.CHANNEL]: + if not is_channel: + is_reply_to_bot = ( + message.reply_to_message + and message.reply_to_message.from_user + and message.reply_to_message.from_user.is_bot + and message.reply_to_message.from_user.username == BOT_USERNAME + ) + if config: + if config.get("call") == "da": + mentions_bot = any( + user_text.lower().startswith(call.lower()) for call in BOT_CALLS + ) + else: + mentions_bot = False + else: + mentions_bot = any( + user_text.lower().startswith(call.lower()) for call in BOT_CALLS + ) + if not (is_reply_to_bot or mentions_bot): + return False + return True + +async def g_answer(data, message, text, title="da", id="1", parse_mode="Markdown"): + return await data["bot"]( + AnswerGuestQuery( + guest_query_id=message.guest_query_id, + result=InlineQueryResultArticle( + id=id, + title=title, + input_message_content=InputTextMessageContent( + message_text=text, + parse_mode=parse_mode, + ), + ), + ) + ) |