How to use the pyrogram.Filters function in Pyrogram

To help you get started, we’ve selected a few Pyrogram examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github pyrogram / plugins / plugins / haste / haste.py View on Github external
@Client.on_message(Filters.command("haste", prefix="!") & Filters.reply)
def haste(client, message):
    reply = message.reply_to_message

    if reply.text is None:
        return

    message.delete()

    result = requests.post(
        "{}/documents".format(BASE),
        data=reply.text.encode("UTF-8")
    ).json()

    message.reply(
        "{}/{}.py".format(BASE, result["key"]),
        reply_to_message_id=reply.message_id
github JosXa / tgintegration / tgintegration / botcontroller.py View on Github external
def get_default_filters(self, user_filters: Filter = None) -> Filter:
        if user_filters is None:
            return Filters.chat(self.peer_id) & Filters.incoming
        else:
            return user_filters & Filters.chat(self.peer_id) & Filters.incoming
github kandnub / TG-UserBot / userbot / events.py View on Github external
group: int = 0
) -> callable:
    """Create simple commands by just providing the pattern without the prefix.

    Args:
        command (``str``):
            The pattern you want to use, excluding the prefix.
        prefix (``str``, optional):
            If you want to change the default prefix set.
            Defaults to "[!.#]".
        group (``int``, optional):
            The group to use for the message handler. Defaults to 0.
    """

    filters = (
        Filters.outgoing &
        Filters.regex(f"(?i)^{prefix}{command}")
    )

    return Client.on_message(filters, group)
github odysseusmax / utube / bot / plugins / upload.py View on Github external
    Filters.private 
    & Filters.incoming 
    & Filters.command('upload') 
    & Filters.user(Config.AUTH_USERS)
)
async def _upload(c, m):
    if not os.path.exists(Config.CRED_FILE):
        await m.reply_text(tr.NOT_AUTHENTICATED_MSG, True)
        return

    if not m.reply_to_message:
        await m.reply_text(tr.NOT_A_REPLY_MSG, True)
        return

    message = m.reply_to_message

    if not message.media:
github JosXa / tgintegration / tgintegration / botintegrationclient.py View on Github external
def get_default_filters(self, user_filters=None):
        if user_filters is None:
            return Filters.chat(self.peer_id) & Filters.incoming
        else:
            return user_filters & Filters.chat(self.peer_id) & Filters.incoming
github SpEcHiDe / AnyDLBot / plugins / FFMpegRoBot.py View on Github external
@pyrogram.Client.on_message(pyrogram.Filters.command(["clearffmpegmedia"]))
async def clear_media(bot, update):
    if update.from_user.id not in Config.AUTH_USERS:
        await bot.delete_messages(
            chat_id=update.chat.id,
            message_ids=update.message_id,
            revoke=True
        )
        return
    TRChatBase(update.from_user.id, update.text, "clearffmpegmedia")
    saved_file_path = Config.DOWNLOAD_LOCATION + "/" + str(update.from_user.id) + ".FFMpegRoBot.mkv"
    if os.path.exists(saved_file_path):
        os.remove(saved_file_path)
    await bot.send_message(
        chat_id=update.chat.id,
        text=Translation.FF_MPEG_DEL_ETED_CUSTOM_MEDIA,
        reply_to_message_id=update.message_id
github pyrogram / pyrogram / examples / welcome.py View on Github external
@app.on_message(Filters.chat(TARGET) & Filters.new_chat_members)
def welcome(client, message):
    # Build the new members list (with mentions) by using their first_name
    new_members = [MENTION.format(i.first_name, i.id) for i in message.new_chat_members]

    # Build the welcome message by using an emoji and the list we built above
    text = MESSAGE.format(Emoji.SPARKLES, ", ".join(new_members))

    # Send the welcome message, without the web page preview
    message.reply(text, disable_web_page_preview=True)
github JosXa / tgintegration / tgintegration / botintegrationclient.py View on Github external
def get_default_filters(self, user_filters=None):
        if user_filters is None:
            return Filters.chat(self.peer_id) & Filters.incoming
        else:
            return user_filters & Filters.chat(self.peer_id) & Filters.incoming