пиздец обнова конечно
This commit is contained in:
1 parent
e3116d490e
commit
a14713a286
7 files changed
+962
-65
No files matched your search
+116
-13
@@ -43,7 +43,10 @@ commands = [
|
||||
"/clear",
|
||||
"/stop",
|
||||
"/markpidor",
|
||||
"/aben"
|
||||
"/aben",
|
||||
"/button",
|
||||
"/clean",
|
||||
"/reset"
|
||||
]
|
||||
|
||||
@router.message(Command("stats"))
|
||||
@@ -89,6 +92,63 @@ async def stats_handler(message: Message):
|
||||
await message.reply("\n".join(text))
|
||||
|
||||
|
||||
@router.message(Command("button"))
|
||||
async def button_handler(message: Message):
|
||||
if message.from_user.id != ADMIN_ID:
|
||||
return await message.reply("🚫 pashol naxxuy.")
|
||||
|
||||
text = message.text.removeprefix("/button").strip()
|
||||
if not text:
|
||||
return await message.reply(
|
||||
"крч это типо генератор инлайн кнопки да только для тестов пж использовать\n"
|
||||
"🚫 напиши callback после команды ало."
|
||||
)
|
||||
|
||||
keyboard = InlineKeyboardMarkup(
|
||||
inline_keyboard=[
|
||||
[InlineKeyboardButton(text=text, callback_data=text)],
|
||||
]
|
||||
)
|
||||
|
||||
await message.reply(
|
||||
"✅ кнопка крутая ниже"
|
||||
" кнопка крутая ниже"
|
||||
" кнопка крутая ниже"
|
||||
" кнопка крутая ниже"
|
||||
" кнопка крутая ниже",
|
||||
reply_markup=keyboard
|
||||
)
|
||||
|
||||
|
||||
@router.message(Command("reset"))
|
||||
async def reset_handler(message: Message, command: CommandObject):
|
||||
if message.from_user.id != ADMIN_ID:
|
||||
return
|
||||
args = command.args
|
||||
if not args or len(args.split()) < 2:
|
||||
return await message.answer("dayn eblan suka")
|
||||
users = get_all_user_ids()
|
||||
key, val = args.split()[0], args.split()[1]
|
||||
for user_id in users:
|
||||
reset_user_setting(user_id, key, val)
|
||||
await message.answer(f"✅ сбросил всем {key} на {val}")
|
||||
|
||||
|
||||
@router.message(Command("clean"))
|
||||
async def clean_db_handler(message: Message):
|
||||
if message.from_user.id != ADMIN_ID:
|
||||
return
|
||||
users = get_all_user_ids()
|
||||
success, deleted = 0, 0
|
||||
for user_id in users:
|
||||
try:
|
||||
await message.bot.send_chat_action(user_id, "typing")
|
||||
success += 1
|
||||
except:
|
||||
delete_user_from_db(user_id)
|
||||
deleted += 1
|
||||
await message.answer(f"✅ *готово врат.*\n- сохранено {success}\n- удалено {deleted}")
|
||||
|
||||
|
||||
@router.message(Command("broadcast"))
|
||||
async def broadcast_handler(message: Message):
|
||||
@@ -207,14 +267,14 @@ async def start_handler(message: Message, command: CommandObject):
|
||||
"привет, запусти эту команду в ЛиС (личные сообщения) бота✅"
|
||||
)
|
||||
return
|
||||
|
||||
|
||||
if message.sender_chat:
|
||||
user_id = message.sender_chat.id
|
||||
else:
|
||||
user_id = message.from_user.id
|
||||
|
||||
config = get_user_config(user_id)
|
||||
|
||||
|
||||
payload = command.args
|
||||
if payload == "new_md":
|
||||
set_user_config(
|
||||
@@ -226,7 +286,7 @@ async def start_handler(message: Message, command: CommandObject):
|
||||
config.get("notify"),
|
||||
"new"
|
||||
)
|
||||
await message.answer("✅ установлен *новый* стиль выделения сообщений!")
|
||||
return await message.answer("✅ установлен *новый* стиль выделения сообщений!")
|
||||
elif payload == "old_md":
|
||||
set_user_config(
|
||||
user_id,
|
||||
@@ -237,19 +297,61 @@ async def start_handler(message: Message, command: CommandObject):
|
||||
config.get("notify"),
|
||||
"old"
|
||||
)
|
||||
await message.answer("✅ установлен *старый* стиль выделения сообщений!")
|
||||
return await message.answer("✅ установлен *старый* стиль выделения сообщений!")
|
||||
elif payload and payload.startswith("prompt-"):
|
||||
prompt_spl = payload.split("-", 2)
|
||||
if len(prompt_spl) != 3:
|
||||
return await message.answer("❌ говно твой payload ты читар уйди")
|
||||
prompt_user_id = int(prompt_spl[1])
|
||||
prompt_id = prompt_spl[2]
|
||||
try:
|
||||
if prompt_user_id == 0:
|
||||
prompt = SYSTEM_PROMPTS.get(prompt_id, {})
|
||||
if not prompt:
|
||||
return await message.reply("❌ промпт kal suka либо приватный либо удалён либо его никогда не было")
|
||||
prompt_pub = True
|
||||
else:
|
||||
prompt = get_user_config(prompt_user_id)["prompts"].get(
|
||||
prompt_id, {}
|
||||
)
|
||||
if not prompt:
|
||||
return await message.reply("❌ промпт говно suka либо приватный либо удалён либо его никогда не было")
|
||||
prompt_pub = prompt.get("public", False)
|
||||
if prompt_user_id == user_id:
|
||||
return await message.reply(
|
||||
f"✅ это твой промпт `{prompt.get('name', 'говно')}`:"
|
||||
f"```\n{prompt.get('text')}\n```",
|
||||
reply_markup=InlineKeyboardMarkup(
|
||||
inline_keyboard=[
|
||||
[
|
||||
InlineKeyboardButton(text="✅ установить", callback_data=f"sp%{user_id}%0%{prompt_id}%2"),
|
||||
InlineKeyboardButton(text="⚙️ настроить", callback_data=f"vp%{user_id}%{prompt_id}"),
|
||||
],
|
||||
]
|
||||
)
|
||||
)
|
||||
elif prompt_pub:
|
||||
return await message.reply(
|
||||
f"✅ вот `{prompt.get('name', 'говно')}` промпт крутой da:"
|
||||
f"```\n{prompt.get('text')}\n```",
|
||||
reply_markup=InlineKeyboardMarkup(
|
||||
inline_keyboard=[
|
||||
[InlineKeyboardButton(text="✅ добавить", callback_data=f"ap%{user_id}%{prompt_user_id}%{prompt_id}")],
|
||||
[InlineKeyboardButton(text="✅🔗 доб. + установить", callback_data=f"sp%{user_id}%{prompt_user_id}%{prompt_id}%2")],
|
||||
]
|
||||
)
|
||||
)
|
||||
except Exception as e:
|
||||
print(f"{YELLOW} -- prompt - {e}{RESET}")
|
||||
return await message.reply("❌ промпт говно suka либо приватный либо удалён либо его никогда не было")
|
||||
|
||||
invite_url = f"https://t.me/{BOT_USERNAME}?startgroup=start"
|
||||
|
||||
keyboard = InlineKeyboardMarkup(
|
||||
inline_keyboard=[
|
||||
[InlineKeyboardButton(text="команды", callback_data="start")],
|
||||
[
|
||||
InlineKeyboardButton(
|
||||
text="настройки", callback_data=f"settings%{user_id}"
|
||||
)
|
||||
],
|
||||
[InlineKeyboardButton(text="добавить в группу", url=invite_url)],
|
||||
[InlineKeyboardButton(text="настройки", callback_data=f"settings%{user_id}")],
|
||||
[InlineKeyboardButton(text="добавить в группу", url=invite_url)]
|
||||
]
|
||||
)
|
||||
|
||||
@@ -315,7 +417,8 @@ async def settings_handler(event: Union[Message, CallbackQuery]):
|
||||
|
||||
config = get_user_config(user_id)
|
||||
models_count = sum(len(models) for models in MODELS.values())
|
||||
prompts_count = len(SYSTEM_PROMPTS)
|
||||
prompts = SYSTEM_PROMPTS | config["prompts"]
|
||||
prompts_count = len(prompts)
|
||||
|
||||
if config["stream"] == "native":
|
||||
stream_status = "натив"
|
||||
@@ -385,7 +488,7 @@ async def settings_handler(event: Union[Message, CallbackQuery]):
|
||||
)
|
||||
|
||||
text = f"⚡ *алло узбекгпт настройки*\nтекущая модель: `{config.get('model')}`\n" \
|
||||
f"текущий промпт: `{config.get('prompt')}`"
|
||||
f"текущий промпт: `{prompts[config.get('prompt')]['name']} ({config.get('prompt')[:4]})`"
|
||||
|
||||
if isinstance(event, Message):
|
||||
await event.reply(text, reply_markup=keyboard)
|
||||
|
||||
Reference in new issue
Block a user