НАСТРОЙКА ГРУППОВОЙ
This commit is contained in:
1 parent
8eaf622b9d
commit
b73f17c762
7 files changed
+309
-6
No files matched your search
+125
@@ -51,6 +51,7 @@ commands = [
|
||||
"/clean",
|
||||
"/reset",
|
||||
"/tben",
|
||||
"/group",
|
||||
]
|
||||
|
||||
@router.message(Command("stats"))
|
||||
@@ -563,3 +564,127 @@ async def clear_handler(message: Message):
|
||||
async def alo(message: Message):
|
||||
await message.reply_rich(InputRichMessage(markdown="# ало"))
|
||||
return
|
||||
|
||||
|
||||
async def group_settings_handler(event: Union[Message, CallbackQuery], dataalo=""):
|
||||
if dataalo:
|
||||
group_id = int(dataalo.split("%", 1)[1])
|
||||
elif isinstance(event, Message):
|
||||
group_id = event.chat.id
|
||||
else:
|
||||
group_id = int(event.data.split("%", 1)[1])
|
||||
|
||||
user_id = event.from_user.id
|
||||
|
||||
g_config = get_group_config(group_id)
|
||||
|
||||
if g_config["post_reply"] == "da":
|
||||
post_reply_status = "да"
|
||||
post_reply_cb = "net"
|
||||
else:
|
||||
post_reply_status = "нет"
|
||||
post_reply_cb = "da"
|
||||
|
||||
if g_config["polls"] == "da":
|
||||
polls_status = "да"
|
||||
polls_cb = "net"
|
||||
else:
|
||||
polls_status = "нет"
|
||||
polls_cb = "da"
|
||||
|
||||
if g_config["lurk"] == "da":
|
||||
lurk_status = "да"
|
||||
lurk_cb = "net"
|
||||
else:
|
||||
lurk_status = "нет"
|
||||
lurk_cb = "da"
|
||||
|
||||
if g_config["post_prompt"]:
|
||||
post_prompt_status = g_config["post_prompt"][:40].replace("\n", " ")
|
||||
else:
|
||||
post_prompt_status = "не задан"
|
||||
|
||||
keyboard = InlineKeyboardMarkup(
|
||||
inline_keyboard=[
|
||||
[
|
||||
InlineKeyboardButton(
|
||||
text=f"посты канала: {post_reply_status}",
|
||||
callback_data=f"gset%{group_id}%{user_id}%post_reply%{post_reply_cb}"
|
||||
),
|
||||
InlineKeyboardButton(
|
||||
text=f"опросы: {polls_status}",
|
||||
callback_data=f"gset%{group_id}%{user_id}%polls%{polls_cb}"
|
||||
),
|
||||
],
|
||||
[
|
||||
InlineKeyboardButton(
|
||||
text=f"промпт постов: {post_prompt_status}",
|
||||
callback_data=f"gpost%{group_id}%{user_id}"
|
||||
),
|
||||
],
|
||||
[
|
||||
InlineKeyboardButton(
|
||||
text=f"подгляд: {lurk_status}",
|
||||
callback_data=f"gset%{group_id}%{user_id}%lurk%{lurk_cb}"
|
||||
),
|
||||
InlineKeyboardButton(
|
||||
text="−",
|
||||
callback_data=f"gset%{group_id}%{user_id}%lurk_chance%-2"
|
||||
),
|
||||
InlineKeyboardButton(
|
||||
text=f"глядит {g_config['lurk_chance']}%",
|
||||
callback_data="hamza"
|
||||
),
|
||||
InlineKeyboardButton(
|
||||
text="+",
|
||||
callback_data=f"gset%{group_id}%{user_id}%lurk_chance%+2"
|
||||
),
|
||||
],
|
||||
[
|
||||
InlineKeyboardButton(
|
||||
text="−",
|
||||
callback_data=f"gset%{group_id}%{user_id}%lurk_reply_chance%-1"
|
||||
),
|
||||
InlineKeyboardButton(
|
||||
text=f"пишет {g_config['lurk_reply_chance']}%",
|
||||
callback_data="hamza"
|
||||
),
|
||||
InlineKeyboardButton(
|
||||
text="+",
|
||||
callback_data=f"gset%{group_id}%{user_id}%lurk_reply_chance%+1"
|
||||
),
|
||||
],
|
||||
]
|
||||
)
|
||||
|
||||
text = f"⚡ *настройки группы*\n" \
|
||||
f"промпт для постов: `{post_prompt_status}`\n" \
|
||||
f"посты канала: {post_reply_status}\n" \
|
||||
f"опросы: {polls_status}\n" \
|
||||
f"подглядывание: {lurk_status} (глядит {g_config['lurk_chance']}%, пишет {g_config['lurk_reply_chance']}%)"
|
||||
|
||||
if isinstance(event, Message):
|
||||
await event.reply(text, reply_markup=keyboard)
|
||||
else:
|
||||
await event.message.edit_text(text, reply_markup=keyboard)
|
||||
await event.answer()
|
||||
|
||||
|
||||
@router.message(Command("group"))
|
||||
async def group_handler(message: Message):
|
||||
if message.chat.type not in [ChatType.GROUP, ChatType.SUPERGROUP]:
|
||||
return await message.reply("эта команда работает только в группах да✅")
|
||||
|
||||
if not message.from_user:
|
||||
return
|
||||
|
||||
if message.from_user.id != ADMIN_ID:
|
||||
try:
|
||||
member = await message.bot.get_chat_member(message.chat.id, message.from_user.id)
|
||||
except Exception as e:
|
||||
print(f"{RED} -- group check - {e}{RESET}")
|
||||
return await message.reply("🚫 не смог проверить что ты владелец группы.")
|
||||
if member.status != "creator":
|
||||
return await message.reply("🚫 настройки группы только для владельца группы да✅")
|
||||
|
||||
await group_settings_handler(message)
|
||||
Reference in new issue
Block a user