отклик добавит
This commit is contained in:
1 parent
48df539ee6
commit
80ecdaea02
3 files changed
+65
-31
No files matched your search
+42
-28
@@ -671,7 +671,7 @@ async def edit_prompt_callback(callback: CallbackQuery):
|
|||||||
],
|
],
|
||||||
[
|
[
|
||||||
InlineKeyboardButton(
|
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(
|
set_user_setting(
|
||||||
user_id,
|
user_id,
|
||||||
"prompt": new_status,
|
prompt=new_status,
|
||||||
"prompts": get_user_config(user_id).get("prompts")
|
prompts=get_user_config(user_id).get("prompts")
|
||||||
)
|
)
|
||||||
|
|
||||||
if msg_type == 0:
|
if msg_type == 0:
|
||||||
@@ -863,7 +863,7 @@ async def add_prompt_callback(callback: CallbackQuery, dataalo="", alo=True):
|
|||||||
|
|
||||||
set_user_setting(
|
set_user_setting(
|
||||||
user_id,
|
user_id,
|
||||||
"prompts": new_prompts
|
prompts=new_prompts
|
||||||
)
|
)
|
||||||
|
|
||||||
if alo:
|
if alo:
|
||||||
@@ -917,7 +917,7 @@ async def set_markdown_callback(callback: CallbackQuery, message=None):
|
|||||||
config = get_user_config(user_id)
|
config = get_user_config(user_id)
|
||||||
set_user_setting(
|
set_user_setting(
|
||||||
user_id,
|
user_id,
|
||||||
"markdown": "new"
|
markdown="new"
|
||||||
)
|
)
|
||||||
if message:
|
if message:
|
||||||
await message.delete()
|
await message.delete()
|
||||||
@@ -936,7 +936,7 @@ async def set_markdown_callback(callback: CallbackQuery, message=None):
|
|||||||
config = get_user_config(user_id)
|
config = get_user_config(user_id)
|
||||||
set_user_setting(
|
set_user_setting(
|
||||||
user_id,
|
user_id,
|
||||||
"markdown": "old"
|
markdown="old"
|
||||||
)
|
)
|
||||||
if message:
|
if message:
|
||||||
await message.delete()
|
await message.delete()
|
||||||
@@ -1064,15 +1064,9 @@ async def group_cancel_callback(callback: CallbackQuery):
|
|||||||
await group_settings_handler(callback, dataalo=f"group%{group_id}")
|
await group_settings_handler(callback, dataalo=f"group%{group_id}")
|
||||||
|
|
||||||
|
|
||||||
@router.callback_query(F.data.startswith("call%"))
|
def build_call_menu(user_id):
|
||||||
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
|
|
||||||
|
|
||||||
config = get_user_config(user_id)
|
config = get_user_config(user_id)
|
||||||
|
calling = config.get("calling") or []
|
||||||
calling_dots = ""
|
calling_dots = ""
|
||||||
call_dots = ""
|
call_dots = ""
|
||||||
|
|
||||||
@@ -1090,23 +1084,23 @@ async def call_callback(callback: CallbackQuery):
|
|||||||
# хуй хуй хуй
|
# хуй хуй хуй
|
||||||
# сиськам сись писькам пись
|
# сиськам сись писькам пись
|
||||||
|
|
||||||
if config["calling"] == []:
|
if calling == []:
|
||||||
calling_status = "свои слова отклика ->"
|
calling_status = "свои слова отклика ->"
|
||||||
calling_status2 = ["✅", ""]
|
calling_status2 = ["✅", ""]
|
||||||
else:
|
else:
|
||||||
calling_status = ", ".join(config["calling"])[:35]
|
calling_status = ", ".join(calling)[:35]
|
||||||
calling_status2 = ["", "✅"]
|
calling_status2 = ["", "✅"]
|
||||||
|
|
||||||
if len(", ".join(config["calling"])) > 35:
|
if len(", ".join(calling)) > 35:
|
||||||
calling_dots = "..."
|
calling_dots = "..."
|
||||||
|
|
||||||
if len(", ".join(BOT_CALLS)) > 35:
|
if len(", ".join(BOT_CALLS)) > 35:
|
||||||
call_dots = "..."
|
call_dots = "..."
|
||||||
|
|
||||||
buttons = [
|
buttons = [
|
||||||
[
|
[
|
||||||
InlineKeyboardButton(
|
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}",
|
callback_data=f"set%call%{user_id}%{call_cb}",
|
||||||
style=call_style
|
style=call_style
|
||||||
),
|
),
|
||||||
@@ -1128,23 +1122,36 @@ async def call_callback(callback: CallbackQuery):
|
|||||||
buttons += [
|
buttons += [
|
||||||
[
|
[
|
||||||
InlineKeyboardButton(
|
InlineKeyboardButton(
|
||||||
text=f"⬅️ назад",
|
text="⬅️ назад",
|
||||||
callback_data=f"settings%{user_id}",
|
callback_data=f"settings%{user_id}",
|
||||||
style="primary"
|
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()
|
await callback.answer()
|
||||||
|
|
||||||
|
|
||||||
@router.callback_query(F.data.startswith("scall%"))
|
@router.callback_query(F.data.startswith("scall%"))
|
||||||
async def call_callback(callback: CallbackQuery):
|
async def scall_callback(callback: CallbackQuery):
|
||||||
# чем выше забор, тем ниже плинтус
|
# чем выше забор, тем ниже плинтус
|
||||||
data = callback.data.split("%", 2)
|
data = callback.data.split("%", 2)
|
||||||
user_id = data[1]
|
user_id = data[1]
|
||||||
@@ -1153,16 +1160,23 @@ async def call_callback(callback: CallbackQuery):
|
|||||||
await callback.answer("прости но нет")
|
await callback.answer("прости но нет")
|
||||||
return
|
return
|
||||||
|
|
||||||
config = get_user_config(user_id)
|
|
||||||
|
|
||||||
if call_type == "1":
|
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 = [
|
buttons = [
|
||||||
[
|
[
|
||||||
InlineKeyboardButton(
|
InlineKeyboardButton(
|
||||||
text=f"⬅️ назад",
|
text="⬅️ назад",
|
||||||
callback_data=f"call%{user_id}",
|
callback_data=f"call%{user_id}",
|
||||||
style="primary"
|
style="primary"
|
||||||
)
|
)
|
||||||
|
|||||||
+3
-2
@@ -60,10 +60,11 @@ def is_replied_bot(message, is_channel, user_text, config=None):
|
|||||||
)
|
)
|
||||||
if config:
|
if config:
|
||||||
if config.get("call") == "da":
|
if config.get("call") == "da":
|
||||||
|
calls = config.get("calling") or BOT_CALLS
|
||||||
mentions_bot = any(
|
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.startswith("@"):
|
||||||
if call.lower() in user_text.lower():
|
if call.lower() in user_text.lower():
|
||||||
mentions_bot = True
|
mentions_bot = True
|
||||||
|
|||||||
+20
-1
@@ -164,7 +164,26 @@ async def da(bot, message, user_id):
|
|||||||
inline_keyboard=[
|
inline_keyboard=[
|
||||||
[
|
[
|
||||||
InlineKeyboardButton(
|
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"
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in new issue
Block a user