★ wanayoo — archive 1999 https://github.com/pyrogram/pyrogram/issues/139Nouvelle recherche | Portail wanayoo
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Official" Bot commands with trailing usernames don't work in groups #139

Open
delivrance opened this issue Oct 14, 2018 · 6 comments
Open

"Official" Bot commands with trailing usernames don't work in groups #139

delivrance opened this issue Oct 14, 2018 · 6 comments

Comments

@delivrance
Copy link
Member

@delivrance delivrance commented Oct 14, 2018

Example:

/start@pyrogrambot

Workaround:

Filters.command(["start", "start@pyrogrambot])

Would be nice to have it automatically handled.

@fenilgandhi
Copy link

@fenilgandhi fenilgandhi commented Oct 23, 2018

I would like to work on it.

@delivrance
Copy link
Member Author

@delivrance delivrance commented Oct 23, 2018

Sure, if you have any idea feel free to propose a pull request

@delivrance delivrance added this to the v1.0.0 milestone Jun 15, 2019
@ColinTheShark
Copy link
Member

@ColinTheShark ColinTheShark commented Jul 8, 2019

I don't know if this would work, but would it make sense to just use regex?

Filters.command("start", "/") and in the background it creates the compiled regex:

f"{prefix}{command}(@{username)?" which would return /start(@samplebot)? and trigger on both with and without the @samplebot at the end.

@delivrance
Copy link
Member Author

@delivrance delivrance commented Jul 9, 2019

@ColinTheShark The issue is how to get the bot username to be used inside the filter, automatically.

While we have the message instance available in the filter's callback, we can do message._client.get_me().username, or call get_me() somewhere in the client and store the username somewhere and then do message._client.username in the filter. Both solutions are ugly because they make use of non-public attributes (_client).

Maybe we can just match (?i).+@\w+bot?

@ColinTheShark
Copy link
Member

@ColinTheShark ColinTheShark commented Jul 9, 2019

Using such a generic Regex would possibly catch updates meant for other clients 🤔

If my bot were ColinSharkBot, /hi@AhoyBot would also be caught by my bot and unintentionally react to it.

(Commenting here parallel to the discussion in the chat to have it in the Issues, too)

@AVee
Copy link

@AVee AVee commented Oct 19, 2019

Would it make sense to always call get_me() on Client.start() and make that info available? I guess there are more scenarios where that would be useful...

@delivrance delivrance removed this from the v1 milestone Aug 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.