From 80ecdaea02ee9df4aa4c3afb362865d5ab3cbcb9 Mon Sep 17 00:00:00 2001 From: huker Date: Sun, 11 Oct 2026 19:13:20 +0300 Subject: [PATCH] =?UTF-8?q?=D0=BE=D1=82=D0=BA=D0=BB=D0=B8=D0=BA=20=D0=B4?= =?UTF-8?q?=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- callbacks.py | 70 +++++++++++++++++++++++++++++++--------------------- helpers.py | 5 ++-- input_msg.py | 21 +++++++++++++++- 3 files changed, 65 insertions(+), 31 deletions(-) diff --git a/callbacks.py b/callbacks.py index 176cabe..a8cb666 100644 --- a/callbacks.py +++ b/callbacks.py @@ -671,7 +671,7 @@ async def edit_prompt_callback(callback: CallbackQuery): ], [ InlineKeyboardButton( - text="⬅️ назад", callback_data=f"vp%{user_id}%{prompt_id}" + text="⬅️ назад", callback_data=f"vp%{user_id}%{prompt_id}", style="primary" ), ] ] @@ -808,8 +808,8 @@ async def set_prompt_callback(callback: CallbackQuery): set_user_setting( user_id, - "prompt": new_status, - "prompts": get_user_config(user_id).get("prompts") + prompt=new_status, + prompts=get_user_config(user_id).get("prompts") ) if msg_type == 0: @@ -863,7 +863,7 @@ async def add_prompt_callback(callback: CallbackQuery, dataalo="", alo=True): set_user_setting( user_id, - "prompts": new_prompts + prompts=new_prompts ) if alo: @@ -917,7 +917,7 @@ async def set_markdown_callback(callback: CallbackQuery, message=None): config = get_user_config(user_id) set_user_setting( user_id, - "markdown": "new" + markdown="new" ) if message: await message.delete() @@ -936,7 +936,7 @@ async def set_markdown_callback(callback: CallbackQuery, message=None): config = get_user_config(user_id) set_user_setting( user_id, - "markdown": "old" + markdown="old" ) if message: await message.delete() @@ -1064,15 +1064,9 @@ async def group_cancel_callback(callback: CallbackQuery): await group_settings_handler(callback, dataalo=f"group%{group_id}") -@router.callback_query(F.data.startswith("call%")) -async def call_callback(callback: CallbackQuery): - data = callback.data.split("%", 1) - user_id = data[1] - if user_id != str(callback.from_user.id): - await callback.answer("прости но нет") - return - +def build_call_menu(user_id): config = get_user_config(user_id) + calling = config.get("calling") or [] calling_dots = "" call_dots = "" @@ -1090,23 +1084,23 @@ async def call_callback(callback: CallbackQuery): # хуй хуй хуй # сиськам сись писькам пись - if config["calling"] == []: + if calling == []: calling_status = "свои слова отклика ->" calling_status2 = ["✅", ""] else: - calling_status = ", ".join(config["calling"])[:35] + calling_status = ", ".join(calling)[:35] calling_status2 = ["", "✅"] - if len(", ".join(config["calling"])) > 35: + if len(", ".join(calling)) > 35: calling_dots = "..." - + if len(", ".join(BOT_CALLS)) > 35: call_dots = "..." buttons = [ [ InlineKeyboardButton( - text=f"{call_status} отклик на слова: {call_status2} {call_status}", + text=f"{call_status} отклик на слова: {call_status2} {call_status}", callback_data=f"set%call%{user_id}%{call_cb}", style=call_style ), @@ -1128,23 +1122,36 @@ async def call_callback(callback: CallbackQuery): buttons += [ [ InlineKeyboardButton( - text=f"⬅️ назад", + text="⬅️ назад", callback_data=f"settings%{user_id}", style="primary" ) ] ] - await callback.message.edit_text( + return ( "меню выбора на что звать меня дорогой друг", - reply_markup=InlineKeyboardMarkup(inline_keyboard=buttons), + InlineKeyboardMarkup(inline_keyboard=buttons), ) + +@router.callback_query(F.data.startswith("call%")) +async def call_callback(callback: CallbackQuery): + data = callback.data.split("%", 1) + user_id = data[1] + if user_id != str(callback.from_user.id): + await callback.answer("прости но нет") + return + + text, keyboard = build_call_menu(user_id) + + await callback.message.edit_text(text, reply_markup=keyboard) + await callback.answer() @router.callback_query(F.data.startswith("scall%")) -async def call_callback(callback: CallbackQuery): +async def scall_callback(callback: CallbackQuery): # чем выше забор, тем ниже плинтус data = callback.data.split("%", 2) user_id = data[1] @@ -1153,16 +1160,23 @@ async def call_callback(callback: CallbackQuery): await callback.answer("прости но нет") return - config = get_user_config(user_id) - if call_type == "1": - set_user_setting - + set_user_setting(user_id, calling=[]) + text, keyboard = build_call_menu(user_id) + await callback.message.edit_text(text, reply_markup=keyboard) + await callback.answer("✅ слова отклика сброшены на стандартные") + return + + alo_command[int(user_id)] = { + "action": "calling", + "chat_id": callback.message.chat.id, + "message_id": callback.message.message_id, + } buttons = [ [ InlineKeyboardButton( - text=f"⬅️ назад", + text="⬅️ назад", callback_data=f"call%{user_id}", style="primary" ) diff --git a/helpers.py b/helpers.py index 8380d49..fde299b 100644 --- a/helpers.py +++ b/helpers.py @@ -60,10 +60,11 @@ def is_replied_bot(message, is_channel, user_text, config=None): ) if config: if config.get("call") == "da": + calls = config.get("calling") or BOT_CALLS mentions_bot = any( - user_text.lower().split(" ", 1)[0] == call for call in BOT_CALLS + user_text.lower().split(" ", 1)[0] == call.lower() for call in calls ) - for call in BOT_CALLS: + for call in calls: if call.startswith("@"): if call.lower() in user_text.lower(): mentions_bot = True diff --git a/input_msg.py b/input_msg.py index 36e0f5e..9d6e7ad 100644 --- a/input_msg.py +++ b/input_msg.py @@ -164,7 +164,26 @@ async def da(bot, message, user_id): inline_keyboard=[ [ InlineKeyboardButton( - text="⬅️ назад", callback_data=f"gcancel%{alo_command[user_id]['group_id']}%{user_id}" + text="⬅️ назад", callback_data=f"gcancel%{alo_command[user_id]['group_id']}%{user_id}", style="primary" + ), + ], + ] + ) + ) + elif alo_command[user_id]["action"] == "calling": + alo_command[user_id]["action"] = None + words = [w.strip() for w in message.text.split(",") if w.strip()][:10] + set_user_setting(user_id, calling=words) + + return await bot.edit_message_text( + text="свои слова отклика сохранены✅", + chat_id=alo_command[user_id]["chat_id"], + message_id=alo_command[user_id]["message_id"], + reply_markup=InlineKeyboardMarkup( + inline_keyboard=[ + [ + InlineKeyboardButton( + text="⬅️ назад", callback_data=f"call%{user_id}", style="primary" ), ], ]