Example #1
0
async def get_rules(c: Alita, m: Message):
    _ = GetLang(m).strs

    chat_id = m.chat.id
    rules = db.get_rules(chat_id)

    if not rules:
        await m.reply_text(_("rules.no_rules"),
                           reply_to_message_id=m.message_id)
        return

    try:
        await c.send_message(
            m.from_user.id,
            _("rules.get_rules").format(chat=m.chat.title, rules=rules),
        )
    except errors.UserIsBlocked:
        me = await c.get_me()
        pm_kb = InlineKeyboardMarkup([[
            InlineKeyboardButton("PM", url=f"https://t.me/{me.username}?start")
        ]])
        await m.reply_text(_("rules.pm_me"),
                           reply_to_message_id=m.message_id,
                           reply_markup=pm_kb)
        return

    await m.reply_text(_("rules.sent_pm_rules"),
                       reply_to_message_id=m.message_id)
    return
Example #2
0
async def get_rules(c: Alita, m: Message):

    chat_id = m.chat.id
    rules = db.get_rules(chat_id)

    if not rules:
        await m.reply_text(tlang(m, "rules.no_rules"),
                           reply_to_message_id=m.message_id)
        return

    try:
        await c.send_message(
            m.from_user.id,
            tlang(m, "rules.get_rules").format(
                chat=f"<b>{m.chat.title}</b>",
                rules=rules,
            ),
        )
    except UserIsBlocked:
        me_name = await get_key("BOT_USERNAME")
        pm_kb = InlineKeyboardMarkup(
            [[InlineKeyboardButton("PM", url=f"https://t.me/{me_name}?start")]
             ], )
        await m.reply_text(
            tlang(m, "rules.pm_me"),
            reply_to_message_id=m.message_id,
            reply_markup=pm_kb,
        )
        return

    await m.reply_text(
        tlang(m, "rules.sent_pm_rules"),
        reply_to_message_id=m.message_id,
    )
    return
Example #3
0
async def clear_rules(c: Alita, m: Message):

    res = await admin_check(c, m)
    if not res:
        return

    _ = GetLang(m).strs

    rules = db.get_rules(m.chat.id)
    if not rules:
        await m.reply_text(_("rules.no_rules"),
                           reply_to_message_id=m.message_id)
        return

    await m.reply_text(
        "Are you sure you want to clear rules?",
        reply_markup=InlineKeyboardMarkup([
            [
                InlineKeyboardButton("⚠️ Confirm",
                                     callback_data="clear.rules"),
                InlineKeyboardButton("❌ Cancel", callback_data="close"),
            ],
        ], ),
    )
    return
Example #4
0
async def clear_rules(_, m: Message):

    rules = db.get_rules(m.chat.id)
    if not rules:
        await m.reply_text(tlang(m, "rules.no_rules"))
        return

    await m.reply_text(
        tlang(m, "rules.clear_rules"),
        reply_markup=InlineKeyboardMarkup([
            [
                InlineKeyboardButton("⚠️ Confirm",
                                     callback_data="clear.rules"),
                InlineKeyboardButton("❌ Cancel", callback_data="close"),
            ],
        ], ),
    )
    return