'How to prevent the bot from responding to the admin in Pyrogram
@app.on_message(filters.private & filters.user != ADMIN) def something(app, message): doSomething()
Solution 1:[1]
I Expect ADMIN is the chat_id of Admin
ADMIN=849816969
@app.on_message(filters.private & ~filters.user(ADMIN))
def something(app, message):
doSomething()
If More than one admin
ADMIN=[849816969, 599815969, 488681569]
@app.on_message(filters.private & ~filters.user(ADMIN))
def something(app, message):
doSomething()
here ~ work as not operator
you can find it in Pyrogram Docs: https://docs.pyrogram.org/topics/use-filters#combining-filters
Use ~ to invert a filter (behaves like the not operator).
Use & and | to merge two filters (behave like and, or operators respectively).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
