예제 #1
0
async def save_note(client, message):
    is_admin = await admin_check(message)
    if not is_admin:
        return
    status_message = await message.reply_text("checking 🤔🙄🙄",
                                              quote=True)
    if len(message.command) == 2:
        chat_id = message.chat.id
        note_message_id = int(message.command[1])
        sql.add_welcome_setting(chat_id, True, 0, note_message_id)
        await status_message.edit_text("welcome message saved")
    elif message.reply_to_message and message.reply_to_message.reply_markup is not None:
        fwded_mesg = await message.reply_to_message.forward(
            chat_id=TG_URI, disable_notification=True)
        chat_id = message.chat.id
        note_message_id = fwded_mesg.message_id
        sql.add_welcome_setting(chat_id, True, 0, note_message_id)
        await status_message.edit_text("welcome message saved")
    else:
        note_name, text, data_type, content, buttons = get_note_type(
            message, 1)

        if data_type is None:
            await status_message.edit_text("🤔 maybe welcome text is empty")
            return

        # construct message using the above parameters
        fwded_mesg = None
        reply_markup = None
        if len(buttons) > 0:
            reply_markup = InlineKeyboardMarkup(buttons)
        if data_type in (Types.BUTTON_TEXT, Types.TEXT):
            fwded_mesg = await client.send_message(
                chat_id=TG_URI,
                text=text,
                parse_mode="md",
                disable_web_page_preview=True,
                disable_notification=True,
                reply_to_message_id=1,
                reply_markup=reply_markup)
        elif data_type is not None:
            fwded_mesg = await client.send_cached_media(
                chat_id=TG_URI,
                file_id=content,
                caption=text,
                parse_mode="md",
                disable_notification=True,
                reply_to_message_id=1,
                reply_markup=reply_markup)

        # save to db 🤔
        if fwded_mesg is not None:
            chat_id = message.chat.id
            note_message_id = fwded_mesg.message_id
            sql.add_welcome_setting(chat_id, bool(note_name), 0,
                                    note_message_id)
            await status_message.edit_text("welcome message saved")
        else:
            await status_message.edit_text("🥺 this might be an error 🤔")
예제 #2
0
async def save_note(client, message):
    status_message = await message.reply_text("checking 🤔🙄🙄", quote=True)
    if (message.reply_to_message
            and message.reply_to_message.reply_markup is not None):
        fwded_mesg = await message.reply_to_message.forward(
            chat_id=TG_URI, disable_notification=True)
        chat_id = message.chat.id
        note_name = " ".join(message.command[1:])
        note_message_id = fwded_mesg.message_id
        sql.add_note_to_db(chat_id, note_name, note_message_id)
        await status_message.edit_text(
            f"note <u>{note_name}</u> added"
            # f"<a href='https://'>{message.chat.title}</a>"
        )
    else:
        note_name, text, data_type, content, buttons = get_note_type(
            message, 2)

        if data_type is None:
            await status_message.edit_text("🤔 maybe note text is empty")
            return

        if not note_name:
            await status_message.edit_text(
                "എന്തിന്ന് ഉള്ള മറുപടി ആണ് എന്ന് വ്യക്തം ആക്കിയില്ല 🤔")
            return

        # construct message using the above parameters
        fwded_mesg = None
        reply_markup = None
        if len(buttons) > 0:
            reply_markup = InlineKeyboardMarkup(buttons)
        if data_type in (Types.BUTTON_TEXT, Types.TEXT):
            fwded_mesg = await client.send_message(
                chat_id=TG_URI,
                text=text,
                parse_mode="md",
                disable_web_page_preview=True,
                disable_notification=True,
                reply_to_message_id=1,
                reply_markup=reply_markup)
        elif data_type is not None:
            fwded_mesg = await client.send_cached_media(
                chat_id=TG_URI,
                file_id=content,
                caption=text,
                parse_mode="md",
                disable_notification=True,
                reply_to_message_id=1,
                reply_markup=reply_markup)

        # save to db 🤔
        if fwded_mesg is not None:
            chat_id = message.chat.id
            note_message_id = fwded_mesg.message_id
            sql.add_note_to_db(chat_id, note_name, note_message_id)
            await status_message.edit_text(
                f"note <u>{note_name}</u> added"
                # f"<a href='https://'>{message.chat.title}</a>"
            )
        else:
            await status_message.edit_text("🥺 this might be an error 🤔")
예제 #3
0
async def save_filter(client: PyroBot, message):
    status_message = await message.reply_text("Wait a Sec", quote=True)
    if (message.reply_to_message
            and message.reply_to_message.reply_markup is not None):
        fwded_mesg = await message.reply_to_message.forward(
            chat_id=TG_URI, disable_notification=True)
        chat_id = message.chat.id
        filter_kw = " ".join(message.command[1:])
        fm_id = fwded_mesg.message_id

        client.filterstore[str(chat_id)][filter_kw] = fm_id
        await client.save_public_store(TG_IRU_S_M_ID,
                                       json.dumps(client.filterstore))

        await status_message.edit_text(
            f"filter <u>{filter_kw}</u> added"
            # f"<a href='https://'>{message.chat.title}</a>"
        )

    else:
        filter_kw, text, data_type, content, buttons = get_note_type(
            message, 2)

        if data_type is None:
            await status_message.edit_text("🤔 Note Text is empty")
            return

        if not filter_kw:
            await status_message.edit_text("It is Not Clear 🤔")
            return

        # construct message using the above parameters
        fwded_mesg = None
        reply_markup = None
        if len(buttons) > 0:
            reply_markup = InlineKeyboardMarkup(buttons)
        if data_type in (Types.BUTTON_TEXT, Types.TEXT):
            fwded_mesg = await client.send_message(
                chat_id=TG_URI,
                text=text,
                parse_mode="md",
                disable_web_page_preview=True,
                disable_notification=True,
                reply_to_message_id=1,
                reply_markup=reply_markup)
        elif data_type is not None:
            fwded_mesg = await client.send_cached_media(
                chat_id=TG_URI,
                file_id=content,
                caption=text,
                parse_mode="md",
                disable_notification=True,
                reply_to_message_id=1,
                reply_markup=reply_markup)

        # save to db 🤔
        if fwded_mesg is not None:
            chat_id = message.chat.id
            fm_id = fwded_mesg.message_id

            client.filterstore[str(chat_id)][filter_kw] = fm_id
            await client.save_public_store(TG_IRU_S_M_ID,
                                           json.dumps(client.filterstore))

            await status_message.edit_text(
                f"Filter <u>{filter_kw}</u> Added Successfully"
                # f"<a href='https://'>{message.chat.title}</a>"
            )
        else:
            await status_message.edit_text("🥺 This Might Be an Error 🤔")
예제 #4
0
async def save_note(client, message):
    status_message = await message.reply_text(
        "Wait a Sec",
        quote=True
    )
    if (
        message.reply_to_message and
        message.reply_to_message.reply_markup is not None
    ):
        fwded_mesg = await message.reply_to_message.forward(
            chat_id=TG_URI,
            disable_notification=True
        )
        chat_id = message.chat.id
        note_name = " ".join(message.command[1:])
        note_message_id = fwded_mesg.message_id
        sql.add_note_to_db(
            chat_id,
            note_name,
            note_message_id
        )
        await status_message.edit_text(
            f"note <u>{note_name}</u> added"
            # f"<a href='https://'>{message.chat.title}</a>"
        )
    else:
        note_name, text, data_type, content, buttons = get_note_type(
            message,
            2
        )

        if data_type is None:
            await status_message.edit_text("🤔 Maybe Note Text is Empty")
            return

        if not note_name:
            await status_message.edit_text(
                "Not Clear 🤔"
            )
            return

        # construct message using the above parameters
        fwded_mesg = None
        reply_markup = None
        if len(buttons) > 0:
            reply_markup = InlineKeyboardMarkup(buttons)
        if data_type in (Types.BUTTON_TEXT, Types.TEXT):
            fwded_mesg = await client.send_message(
                chat_id=TG_URI,
                text=text,
                parse_mode="md",
                disable_web_page_preview=True,
                disable_notification=True,
                reply_to_message_id=1,
                reply_markup=reply_markup
            )
        elif data_type is not None:
            fwded_mesg = await client.send_cached_media(
                chat_id=TG_URI,
                file_id=content,
                caption=text,
                parse_mode="md",
                disable_notification=True,
                reply_to_message_id=1,
                reply_markup=reply_markup
            )

        # save to db 🤔
        if fwded_mesg is not None:
            chat_id = message.chat.id
            note_message_id = fwded_mesg.message_id
            sql.add_note_to_db(
                chat_id,
                note_name,
                note_message_id
            )
            await status_message.edit_text(
                f"note <u>{note_name}</u> added"
                # f"<a href='https://'>{message.chat.title}</a>"
            )
        else:
            await status_message.edit_text("🥺 This Might be An Error 🤔")
예제 #5
0
파일: save.py 프로젝트: wdtgbot/PyroGramBot
async def save_filter(client: PyroBot, message):
    status_message = await message.reply_text("checking 🤔🙄🙄", quote=True)
    if message.reply_to_message and message.reply_to_message.reply_markup is not None:
        fwded_mesg = await message.reply_to_message.forward(
            chat_id=TG_URI, disable_notification=True
        )
        chat_id = message.chat.id
        filter_kw = " ".join(message.command[1:])
        fm_id = fwded_mesg.message_id

        client.filterstore[str(chat_id)][filter_kw] = fm_id
        await client.save_public_store(TG_IRU_S_M_ID, json.dumps(client.filterstore))

        await status_message.edit_text(
            f"filter <u>{filter_kw}</u> added"
            # f"<a href='https://'>{message.chat.title}</a>"
        )

    else:
        filter_kw, text, data_type, content, buttons = get_note_type(message, 2)

        if data_type is None:
            await status_message.edit_text("🤔 maybe note text is empty")
            return

        if not filter_kw:
            await status_message.edit_text(
                "എന്തിന്ന് ഉള്ള മറുപടി ആണ് എന്ന് വ്യക്തം ആക്കിയില്ല 🤔"
            )
            return

        # construct message using the above parameters
        fwded_mesg = None
        reply_markup = None
        if len(buttons) > 0:
            reply_markup = InlineKeyboardMarkup(buttons)
        if data_type in (Types.BUTTON_TEXT, Types.TEXT):
            fwded_mesg = await client.send_message(
                chat_id=TG_URI,
                text=text,
                parse_mode="md",
                disable_web_page_preview=True,
                disable_notification=True,
                reply_to_message_id=1,
                reply_markup=reply_markup,
            )
        elif data_type is not None:
            fwded_mesg = await client.send_cached_media(
                chat_id=TG_URI,
                file_id=content,
                caption=text,
                parse_mode="md",
                disable_notification=True,
                reply_to_message_id=1,
                reply_markup=reply_markup,
            )

        # save to db 🤔
        if fwded_mesg is not None:
            chat_id = message.chat.id
            fm_id = fwded_mesg.message_id

            client.filterstore[str(chat_id)][filter_kw] = fm_id
            await client.save_public_store(
                TG_IRU_S_M_ID, json.dumps(client.filterstore)
            )

            await status_message.edit_text(
                f"filter <u>{filter_kw}</u> added"
                # f"<a href='https://'>{message.chat.title}</a>"
            )
        else:
            await status_message.edit_text("🥺 this might be an error 🤔")