How to use the pyrogram.Client.on_message 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 SpEcHiDe / AnyDLBot / plugins / download_stickers.py View on Github external
@pyrogram.Client.on_message(pyrogram.Filters.sticker)
async def DownloadStickersBot(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, "DownloadStickersBot")
    logger.info(update.from_user)
    download_location = Config.DOWNLOAD_LOCATION + "/" + str(update.from_user.id) + "_DownloadStickersBot_" + str(update.from_user.id) + ".png"
    a = await bot.send_message(
        chat_id=update.chat.id,
        text=Translation.DOWNLOAD_START,
        reply_to_message_id=update.message_id
    )
github SpEcHiDe / AnyDLBot / plugins / FFMpegRoBot.py View on Github external
@pyrogram.Client.on_message(pyrogram.Filters.command(["downloadmedia"]))
async def download_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, "downloadmedia")
    saved_file_path = Config.DOWNLOAD_LOCATION + "/" + str(update.from_user.id) + ".FFMpegRoBot.mkv"
    if not os.path.exists(saved_file_path):
        a = await bot.send_message(
            chat_id=update.chat.id,
            text=Translation.DOWNLOAD_START,
            reply_to_message_id=update.message_id
        )
github pyrogram / plugins / plugins / eval / eval.py View on Github external
@Client.on_message(Filters.command("eval", prefix="!"))
def eval_expression(client, message):
    expression = " ".join(message.command[1:])

    if expression:
        m = message.reply(RUNNING.format(expression))

        try:
            result = eval(expression)
        except Exception as error:
            client.edit_message_text(
                m.chat.id,
                m.message_id,
                ERROR.format(expression, error)
            )
        else:
            if result is None:
github SpEcHiDe / AnyDLBot / plugins / unzip.py View on Github external
@pyrogram.Client.on_message(pyrogram.Filters.command(["unzip"]))
async def unzip(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, "unzip")
    saved_file_path = Config.DOWNLOAD_LOCATION + \
        "/" + str(update.from_user.id) + ".unzip.zip"
    if os.path.exists(saved_file_path):
        os.remove(saved_file_path)
    reply_message = update.reply_to_message
    if ((reply_message is not None) and
        (reply_message.document is not None) and
github kandnub / TG-UserBot / userbot / events.py View on Github external
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)