-
Notifications
You must be signed in to change notification settings - Fork 477
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
ChatByUsername telegram: chat not found (400) #701
Comments
I also tried using Entities() for _, element := range c.Entities() {
log.Println(element.Type)
if element.Type == "mention" {
log.Println(element.User)
}
} |
Hello @poikl246, I'm afraid you can't do this, as telegram makes bots unable to get an user's id (Or any information whatsoever) by its username. What you are searching is an userbot, you can create a local api that does the job for you, I suggest the "plug-n-play" solution provided here: https://github.com/Poolitzer/usernameToChatAPI You will just need to create a tiny wrapper for the api. Hope this answers your question! |
Another solution is to have a database that contains every user's username and their id. This would however lead to unexpected problems if you don't update the database in the right time. For example: Neither of them sends an update to the bot after changing their usernames. Now, if you try to /ban @usera, even if you want to ban @userb you will instead ban the original owner of @usera (now @UserABC) |
Okay, thank you very much. It's very sad that the standard doesn't have this functionality( |
Hello, please advise.
Task:
Need to get the username of a user from admin and then ban him.
How I see this solution
Take the Ban command and pass the username to it via ChatMember
So it goes something like this
but that's how we get the error
telegram: Bad Request: invalid user_id specified (400)
I also tried using BanSenderChat
but I'm getting the error again
telegram: Bad Request: sender_chat_id is not a valid Integer (400)
after which I just switched to using ChatByUsername
There was a lot of hope for this method, as it seems to give data including user data. But it doesn't work at all.
on any attempts to pass different data to the method I always get this error
<nil> telegram: chat not found (400)
Can you please tell me what I'm doing wrong?
Thank you in advance, I really hope for your answer)
Don't throw slippers at me, I'm a beginner.
The text was updated successfully, but these errors were encountered: