Ejemplo n.º 1
0
async def on_snip_save(event):
    name = event.pattern_match.group(1)
    msg = await event.get_reply_message()
    if msg:
        snip = {'type': TYPE_TEXT, 'text': msg.message or ''}
        if msg.media:
            media = None
            if isinstance(msg.media, types.MessageMediaPhoto):
                media = utils.get_input_photo(msg.media.photo)
                snip['type'] = TYPE_PHOTO
            elif isinstance(msg.media, types.MessageMediaDocument):
                media = utils.get_input_document(msg.media.document)
                snip['type'] = TYPE_DOCUMENT
            if media:
                snip['id'] = media.id
                snip['hash'] = media.access_hash
                snip['fr'] = media.file_reference
        add_filter(event.chat_id, name, snip['text'], snip['type'],
                   snip.get('id'), snip.get('hash'), snip.get('fr'))
        await event.edit("Filtro salvato!")
        await asynco.sleep(2)
    else:
        await event.edit(
            f"`{DEFAULTUSER}:`**Rispondi ad un messaggio `.savefilter` e il testo per salvare il filtro**"
        )
Ejemplo n.º 2
0
async def on_snip_save(event):
    name = event.pattern_match.group(1)
    msg = await event.get_reply_message()
    if msg:
        snip = {'type': TYPE_TEXT, 'text': msg.message or ''}
        if msg.media:
            media = None
            if isinstance(msg.media, types.MessageMediaPhoto):
                media = utils.get_input_photo(msg.media.photo)
                snip['type'] = TYPE_PHOTO
            elif isinstance(msg.media, types.MessageMediaDocument):
                media = utils.get_input_document(msg.media.document)
                snip['type'] = TYPE_DOCUMENT
            if media:
                snip['id'] = media.id
                snip['hash'] = media.access_hash
                snip['fr'] = media.file_reference
        add_filter(event.chat_id, name, snip['text'], snip['type'],
                   snip.get('id'), snip.get('hash'), snip.get('fr'))
        await event.edit(
            f"filtro {name} salvato con successo. usalo con {name}")
    else:
        await event.edit(
            "Rispondi a un messaggio con .savefilter parola per salvare il filtro"
        )
Ejemplo n.º 3
0
async def on_snip_save(event):
    name = event.pattern_match.group(1)
    meseg = event.pattern_match.group(2)
    msg = await event.get_reply_message()
    if msg:
        snip = {'type': TYPE_TEXT, 'text': msg.message or ''}
        if msg.media:
            media = None
            if isinstance(msg.media, types.MessageMediaPhoto):
                media = utils.get_input_photo(msg.media.photo)
                snip['type'] = TYPE_PHOTO
            elif isinstance(msg.media, types.MessageMediaDocument):
                media = utils.get_input_document(msg.media.document)
                snip['type'] = TYPE_DOCUMENT
            if media:
                snip['id'] = media.id
                snip['hash'] = media.access_hash
                snip['fr'] = media.file_reference
    else:
        snip = {'type': TYPE_TEXT, 'text': meseg or ''}
    add_snip(name, snip['text'], snip['type'], snip.get('id'),
             snip.get('hash'), snip.get('fr'))
    await event.edit(
        "snip {name} saved successfully. Get it with #{name}".format(name=name)
    )
Ejemplo n.º 4
0
async def add_filter(fltr):
    """ For .save command, saves notes in a chat. """
    if not fltr.text[0].isalpha() and fltr.text[0] not in ("/", "#", "@", "!"):
        try:
            from userbot.modules.sql_helper.notes_sql import add_note
        except AttributeError:
            await fltr.edit("`Running on Non-SQL mode!`")
            return

        notename = fltr.pattern_match.group(1)
        msg = await fltr.get_reply_message()
        if not msg:
            await fltr.edit("`I need something to save as a note.`")
        else:
            snip = {'type': TYPE_TEXT, 'text': msg.message or ''}
            if msg.media:
                media = None
                if isinstance(msg.media, types.MessageMediaPhoto):
                    media = utils.get_input_photo(msg.media.photo)
                    snip['type'] = TYPE_PHOTO
                elif isinstance(msg.media, types.MessageMediaDocument):
                    media = utils.get_input_document(msg.media.document)
                    snip['type'] = TYPE_DOCUMENT
                if media:
                    snip['id'] = media.id
                    snip['hash'] = media.access_hash
                    snip['fr'] = media.file_reference

        success = "`Note {} successfully. Use` #{} `to get it`"

        if add_note(str(fltr.chat_id), notename, snip['text'], snip['type'],
                    snip.get('id'), snip.get('hash'), snip.get('fr')) is False:
            return await fltr.edit(success.format('updated', notename))
        else:
            return await fltr.edit(success.format('added', notename))
Ejemplo n.º 5
0
async def on_snip_save(event):
    hitler = await edit_or_reply(event, "Processing....")
    name = event.pattern_match.group(1)
    msg = await event.get_reply_message()
    if msg:
        snip = {"type": TYPE_TEXT, "text": msg.message or ""}
        if msg.media:
            media = None
            if isinstance(msg.media, types.MessageMediaPhoto):
                media = utils.get_input_photo(msg.media.photo)
                snip["type"] = TYPE_PHOTO
            elif isinstance(msg.media, types.MessageMediaDocument):
                media = utils.get_input_document(msg.media.document)
                snip["type"] = TYPE_DOCUMENT
            if media:
                snip["id"] = media.id
                snip["hash"] = media.access_hash
                snip["fr"] = media.file_reference
        add_filter(
            event.chat_id,
            name,
            snip["text"],
            snip["type"],
            snip.get("id"),
            snip.get("hash"),
            snip.get("fr"),
        )
        await hitler.edit(
            f"filter {name} saved successfully. Get it with {name}")
    else:
        await hitler.edit(
            "Reply to a message with `savefilter keyword` to save the filter")
Ejemplo n.º 6
0
async def _(event):
    name = event.pattern_match.group(1)
    msg = await event.get_reply_message()
    if msg:
        snip = {"type": TYPE_TEXT, "text": msg.message or ""}
        if msg.media:
            media = None
            if isinstance(msg.media, types.MessageMediaPhoto):
                media = utils.get_input_photo(msg.media.photo)
                snip["type"] = TYPE_PHOTO
            elif isinstance(msg.media, types.MessageMediaDocument):
                media = utils.get_input_document(msg.media.document)
                snip["type"] = TYPE_DOCUMENT
            if media:
                snip["id"] = media.id
                snip["hash"] = media.access_hash
                snip["fr"] = media.file_reference
        add_snip(
            name,
            snip["text"],
            snip["type"],
            snip.get("id"),
            snip.get("hash"),
            snip.get("fr"),
        )
        await event.reply(
            "Note {name} saved successfully. Get it with ?{name}".format(name=name)
        )
    else:
        await event.reply("Reply to a message with `snips keyword` to save the snip")
Ejemplo n.º 7
0
async def add_new_filter(new_handler):
    """ For .filter command, allows adding new filters in a chat """
    if not new_handler.text[0].isalpha() and new_handler.text[0] not in (
            "/", "#", "@", "!"):
        try:
            from userbot.modules.sql_helper.filter_sql import add_filter
        except AttributeError:
            await new_handler.edit("`Running on Non-SQL mode!`")
            return

        keyword = new_handler.pattern_match.group(1)
        msg = await new_handler.get_reply_message()
        if msg:
            snip = {'type': TYPE_TEXT, 'text': msg.message or ''}
            if msg.media:
                media = None
                if isinstance(msg.media, types.MessageMediaPhoto):
                    media = utils.get_input_photo(msg.media.photo)
                    snip['type'] = TYPE_PHOTO
                elif isinstance(msg.media, types.MessageMediaDocument):
                    media = utils.get_input_document(msg.media.document)
                    snip['type'] = TYPE_DOCUMENT
                if media:
                    snip['id'] = media.id
                    snip['hash'] = media.access_hash
                    snip['fr'] = media.file_reference

        success = "`Filter` **{}** `{} successfully`"

        if add_filter(str(new_handler.chat_id), keyword, snip['text'],
                      snip['type'], snip.get('id'), snip.get('hash'),
                      snip.get('fr')) is True:
            await new_handler.edit(success.format(keyword, 'added'))
        else:
            await new_handler.edit(success.format(keyword, 'updated'))
Ejemplo n.º 8
0
async def on_snip_save(event):
    name = event.pattern_match.group(1)
    msg = await event.get_reply_message()
    if msg:
        snip = {'type': TYPE_TEXT, 'text': msg.message or ''}
        if msg.media:
            media = None
            if isinstance(msg.media, types.MessageMediaPhoto):
                media = utils.get_input_photo(msg.media.photo)
                snip['type'] = TYPE_PHOTO
            elif isinstance(msg.media, types.MessageMediaDocument):
                media = utils.get_input_document(msg.media.document)
                snip['type'] = TYPE_DOCUMENT
            if media:
                snip['id'] = media.id
                snip['hash'] = media.access_hash
                snip['fr'] = media.file_reference
        add_filter(event.chat_id, name, snip['text'], snip['type'],
                   snip.get('id'), snip.get('hash'), snip.get('fr'))
        await edit_or_reply(
            event, f"filtre {name} başarıyla kaydedildi. {Name} ile alın")
    else:
        await edit_or_reply(
            event,
            "Filtreyi kaydetmek için 'kaydedici filtre anahtar kelimesi` ile bir mesajı yanıtlayın"
        )
Ejemplo n.º 9
0
async def on_snip_save(event):
    name = event.pattern_match.group(1)
    msg = await event.get_reply_message()
    if msg:
        snip = {'type': TYPE_TEXT, 'text': msg.message or ''}
        if msg.media:
            media = None
            if isinstance(msg.media, types.MessageMediaPhoto):
                media = utils.get_input_photo(msg.media.photo)
                snip['type'] = TYPE_PHOTO
            elif isinstance(msg.media, types.MessageMediaDocument):
                media = utils.get_input_document(msg.media.document)
                snip['type'] = TYPE_DOCUMENT
            if media:
                snip['id'] = media.id
                snip['hash'] = media.access_hash
                snip['fr'] = media.file_reference
        add_filter(
            event.chat_id,
            name,
            snip['text'],
            snip['type'],
            snip.get('id'),
            snip.get('hash'),
            snip.get('fr'))
        await edit_or_reply(event, f"filter {name} saved successfully. Get it with {name}")
    else:
        await edit_or_reply(event, "Reply to a message with `savefilter keyword` to save the filter")
Ejemplo n.º 10
0
async def on_snip_save(event):
    """ For .snip command, saves snips for future use. """
    try:
        from userbot.modules.sql_helper.snips_sql import add_snip
    except AtrributeError:
        await event.edit("`Running on Non-SQL mode!`")
        return
    name = event.pattern_match.group(1)
    msg = await event.get_reply_message()
    if not msg:
        await event.edit("`I need something to save as a snip.`")
        return
    else:
        snip = {'type': TYPE_TEXT, 'text': msg.message or ''}
        if msg.media:
            media = None
            if isinstance(msg.media, types.MessageMediaPhoto):
                media = utils.get_input_photo(msg.media.photo)
                snip['type'] = TYPE_PHOTO
            elif isinstance(msg.media, types.MessageMediaDocument):
                media = utils.get_input_document(msg.media.document)
                snip['type'] = TYPE_DOCUMENT
            if media:
                snip['id'] = media.id
                snip['hash'] = media.access_hash
                snip['fr'] = media.file_reference
                
        success = "`Snip {} successfully. Use` **${}** `anywhere to get it`"
        
        if add_snip(name, snip['text'], snip['type'], snip.get('id'), snip.get('hash'), snip.get('fr')) is False:
            await event.edit(success.format('updated', name))
        else:
            await event.edit(success.format('saved', name))
Ejemplo n.º 11
0
async def save(event):
    if event.is_group:
        if not await is_admin(event, event.sender_id):
            await event.reply("You need to be an admin to do this.")
            return
        if not await can_change_info(message=event):
            await event.reply(
                "You are missing the following rights to use this command: CanChangeInfo"
            )
            return
    else:
        return
    if not event.reply_to_msg_id:
        input = event.pattern_match.group(1)
        if input:
            arg = input.split(" ", 1)
        if len(arg) == 2:
            name = arg[0]
            msg = arg[1]
            snip = {"type": TYPE_TEXT, "text": msg}
        else:
            name = arg[0]
            if not name:
                await event.reply("You need to give the filter a name!")
                return
            await event.reply("You need to give the filter some content!")
            return
    else:
        message = await event.get_reply_message()
        name = event.pattern_match.group(1)
        if not name:
            await event.reply("You need to give the filter a name!")
            return
        if not message.media:
            msg = message.text
            snip = {"type": TYPE_TEXT, "text": msg}
        else:
            snip = {"type": TYPE_TEXT, "text": ""}
            media = None
            if isinstance(message.media, types.MessageMediaPhoto):
                media = utils.get_input_photo(message.media.photo)
                snip["type"] = TYPE_PHOTO
            elif isinstance(message.media, types.MessageMediaDocument):
                media = utils.get_input_document(message.media.document)
                snip["type"] = TYPE_DOCUMENT
            if media:
                snip["id"] = media.id
                snip["hash"] = media.access_hash
                snip["fr"] = media.file_reference
    add_filter(
        event.chat_id,
        name,
        snip["text"],
        snip["type"],
        snip.get("id"),
        snip.get("hash"),
        snip.get("fr"),
    )
    await event.reply(f"Saved filter `{name}`")
Ejemplo n.º 12
0
async def on_snip_save(event):
    if event.is_group:
        if not await can_change_info(message=event):
            return
    else:
        return

    name = event.pattern_match.group(1)
    msg = await event.get_reply_message()

    if msg:

        snip = {"type": TYPE_TEXT, "text": msg.message or ""}

        if msg.media:

            media = None

            if isinstance(msg.media, types.MessageMediaPhoto):

                media = utils.get_input_photo(msg.media.photo)

                snip["type"] = TYPE_PHOTO

            elif isinstance(msg.media, types.MessageMediaDocument):

                media = utils.get_input_document(msg.media.document)

                snip["type"] = TYPE_DOCUMENT

            if media:

                snip["id"] = media.id

                snip["hash"] = media.access_hash

                snip["fr"] = media.file_reference

        add_filter(
            event.chat_id,
            name,
            snip["text"],
            snip["type"],
            snip.get("id"),
            snip.get("hash"),
            snip.get("fr"),
        )

        await event.reply(
            f"Classic Filter {name} saved successfully. you can get it with {name}\nNote: Try our new filter system /addfilter "
        )

    else:

        await event.reply(
            "Usage: Reply to user message with /cfilter <text>.. \nNot Recomended use new filter system /savefilter"
        )
Ejemplo n.º 13
0
async def on_snip_save(event):
    if event.is_group:
        if not await can_change_info(message=event):
            return
    else:
        return

    name = event.pattern_match.group(1)
    msg = await event.get_reply_message()

    if msg:

        snip = {"type": TYPE_TEXT, "text": msg.message or ""}

        if msg.media:

            media = None

            if isinstance(msg.media, types.MessageMediaPhoto):

                media = utils.get_input_photo(msg.media.photo)

                snip["type"] = TYPE_PHOTO

            elif isinstance(msg.media, types.MessageMediaDocument):

                media = utils.get_input_document(msg.media.document)

                snip["type"] = TYPE_DOCUMENT

            if media:

                snip["id"] = media.id

                snip["hash"] = media.access_hash

                snip["fr"] = media.file_reference

        add_filter(
            event.chat_id,
            name,
            snip["text"],
            snip["type"],
            snip.get("id"),
            snip.get("hash"),
            snip.get("fr"),
        )

        await event.reply(
            f"Filter {name} saved successfully. Get it with {name}")

    else:

        await event.reply(
            "Reply to a message with /savefilter keyword to save the filter")
Ejemplo n.º 14
0
async def on_snip_save(event):
    name = event.pattern_match.group(1)
    msg = await event.get_reply_message()
    if msg:
        snip = {'type': TYPE_TEXT, 'text': msg.message or ''}
        if msg.media:
            media = None
            if isinstance(msg.media, types.MessageMediaPhoto):
                media = utils.get_input_photo(msg.media.photo)
                snip['type'] = TYPE_PHOTO
            elif isinstance(msg.media, types.MessageMediaDocument):
                media = utils.get_input_document(msg.media.document)
                snip['type'] = TYPE_DOCUMENT
            if media:
                snip['id'] = media.id
                snip['hash'] = media.access_hash
                snip['fr'] = media.file_reference
        add_snip(name, snip['text'], snip['type'], snip.get('id'), snip.get('hash'), snip.get('fr'))
        await event.edit("Taglio {name} salvato con successo. Prendilo con #{name}".format(name=name))
    else:
        await event.edit("Rispondi ad un messaggio con `snips parola` per salvare il taglio.")
Ejemplo n.º 15
0
async def _(event):
    if event.fwd_from:
        return
    msg = await event.get_reply_message()
    if msg and msg.media:
        media = None
        message_type = TYPE_TEXT
        if isinstance(msg.media, types.MessageMediaPhoto):
            media = utils.get_input_photo(msg.media.photo)
            message_type = TYPE_PHOTO
        elif isinstance(msg.media, types.MessageMediaDocument):
            media = utils.get_input_document(msg.media.document)
            message_type = TYPE_DOCUMENT
        #
        add_welcome_setting(event.chat_id, msg.message, True, 0, message_type,
                            media.id, media.access_hash, media.file_reference)
        await event.edit("Welcome note saved. ")
    else:
        input_str = event.text.split(None, 1)
        add_welcome_setting(event.chat_id, input_str[1], True, 0)
        await event.edit("Welcome note saved. ")
Ejemplo n.º 16
0
async def on_snip_save(event):
    name = event.pattern_match.group(1)
    msg = await event.get_reply_message()
    if msg:
        snip = {'type': TYPE_TEXT, 'text': msg.message or ''}
        if msg.media:
            media = None
            if isinstance(msg.media, types.MessageMediaPhoto):
                media = utils.get_input_photo(msg.media.photo)
                snip['type'] = TYPE_PHOTO
            elif isinstance(msg.media, types.MessageMediaDocument):
                media = utils.get_input_document(msg.media.document)
                snip['type'] = TYPE_DOCUMENT
            if media:
                snip['id'] = media.id
                snip['hash'] = media.access_hash
                snip['fr'] = media.file_reference
        add_filter(event.chat_id, name, snip['text'], snip['type'],
                   snip.get('id'), snip.get('hash'), snip.get('fr'))
        await event.edit(f"الرد {name} تم اضافته بنجاح. اكتب {name}")
    else:
        await event.edit("رد على الرد وااكتب النص الاساسي `اضف رد` لحفظ الرد")
Ejemplo n.º 17
0
async def on_snip_save(event):
    name = event.pattern_match.group(1)
    msg = await event.get_reply_message()
    if msg:
        snips.pop(name, None)
        snip = {"type": TYPE_TEXT, "text": msg.message or ""}
        if msg.media:
            media = None
            if isinstance(msg.media, types.MessageMediaPhoto):
                media = utils.get_input_photo(msg.media.photo)
                snip["type"] = TYPE_PHOTO
            elif isinstance(msg.media, types.MessageMediaDocument):
                media = utils.get_input_document(msg.media.document)
                snip["type"] = TYPE_DOCUMENT
            if media:
                snip["id"] = media.id
                snip["hash"] = media.access_hash

        snips[name] = snip
        storage.snips = snips

    await event.delete()
Ejemplo n.º 18
0
async def on_snip_save(event):
    name = event.pattern_match.group(1)
    msg = await event.get_reply_message()
    if msg:
        snip = {'type': TYPE_TEXT, 'text': msg.message or ''}
        if msg.media:
            media = None
            if isinstance(msg.media, types.MessageMediaPhoto):
                media = utils.get_input_photo(msg.media.photo)
                snip['type'] = TYPE_PHOTO
            elif isinstance(msg.media, types.MessageMediaDocument):
                media = utils.get_input_document(msg.media.document)
                snip['type'] = TYPE_DOCUMENT
            if media:
                snip['id'] = media.id
                snip['hash'] = media.access_hash
                snip['fr'] = media.file_reference
        add_filter(event.chat_id, name, snip['text'], snip['type'],
                   snip.get('id'), snip.get('hash'), snip.get('fr'))
        await event.edit(f"⌔︙الرد {name} تم الحفض بنجاح. ↪️ {name}")
    else:
        await event.edit(
            "⌔︙اولا ارسل الكلمه ثم قم برد عليها بالامر + رد للـكـلمه ↪️")
Ejemplo n.º 19
0
async def on_snip_save(event):
    await event.delete()
    name = event.pattern_match.group(1)
    msg = await event.get_reply_message()
    if not msg:
        return

    snips.pop(name, None)
    snip = {'type': TYPE_TEXT, 'text': msg.message or ''}
    if msg.media:
        media = None
        if isinstance(msg.media, types.MessageMediaPhoto):
            media = utils.get_input_photo(msg.media.photo)
            snip['type'] = TYPE_PHOTO
        elif isinstance(msg.media, types.MessageMediaDocument):
            media = utils.get_input_document(msg.media.document)
            snip['type'] = TYPE_DOCUMENT
        if media:
            snip['id'] = media.id
            snip['hash'] = media.access_hash

    snips[name] = snip
    storage.snips = snips
Ejemplo n.º 20
0
async def on_snip_save(event):
    name = event.pattern_match.group(1)
    msg = await event.get_reply_message()
    if msg:
        snip = {'type': TYPE_TEXT, 'text': msg.message or ''}
        if msg.media:
            media = None
            if isinstance(msg.media, types.MessageMediaPhoto):
                media = utils.get_input_photo(msg.media.photo)
                snip['type'] = TYPE_PHOTO
            elif isinstance(msg.media, types.MessageMediaDocument):
                media = utils.get_input_document(msg.media.document)
                snip['type'] = TYPE_DOCUMENT
            if media:
                snip['id'] = media.id
                snip['hash'] = media.access_hash
                snip['fr'] = media.file_reference
        add_filter(event.chat_id, name, snip['text'], snip['type'],
                   snip.get('id'), snip.get('hash'), snip.get('fr'))
        await event.edit(f" {name}   .   {name}")
    else:
        await event.edit(
            "     ` Savefilter.`  ")
Ejemplo n.º 21
0
async def on_snip_save(event):
    name = event.pattern_match.group(1)
    msg = await event.get_reply_message()
    if msg:
        snip = {'type': TYPE_TEXT, 'text': msg.message or ''}
        if msg.media:
            media = None
            if isinstance(msg.media, types.MessageMediaPhoto):
                media = utils.get_input_photo(msg.media.photo)
                snip['type'] = TYPE_PHOTO
            elif isinstance(msg.media, types.MessageMediaDocument):
                media = utils.get_input_document(msg.media.document)
                snip['type'] = TYPE_DOCUMENT
            if media:
                snip['id'] = media.id
                snip['hash'] = media.access_hash
                snip['fr'] = media.file_reference
        add_snip(name, snip['text'], snip['type'], snip.get('id'),
                 snip.get('hash'), snip.get('fr'))
        await event.edit(
            "**Comando __{name}__ salvato ✅ \nOttienilo con:** `.{name}`".
            format(name=name))
    else:
        await event.edit("Non ci sono comandi. Salvane con `.comando`")