L
L
L1MO2021-11-06 14:47:41
Python
L1MO, 2021-11-06 14:47:41

How to create a team on pyrogram?

Hello, I'm a beginner "pythonist", I wanted to make a command, when sending it, a text was sent to me in private messages.

My version:

from pyrogram import Client

api_id = id
api_hash = "hash"

with Client("my_account", api_id, api_hash) as app:

    def main():
        app.on_message(filters.command(["texts"], prefixes="."))
        app.send_message("me", "test pyrogram", disable_web_page_preview=True)


app.run()


As a result, I get nothing.
I apologize in advance for my stupidity.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vindicar, 2021-11-06
@Vindicar

Compare with example

from pyrogram import Client, filters

app = Client("my_account")

@app.on_message(filters.text & filters.private)
def echo(client, message):
    message.reply_text(message.text)

app.run()  # Automatically start() and idle()

For some reason, you turned the app.on_message decorator into a regular call and put it inside a function.
And yes, if you are a beginner pythonist, then do not start immediately with bots - this is not a trivial topic at all.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question