So, I have a topic link given by a user. I want to verify if that topic link is correct or not using Telegram Bot API
1 Answer 1
As of now, there's no API methods in Telegram Bot API to know if the link actually leads to a existing topic in a Forum chat.
But, a workaround I can suggest is you can try calling a send method such as sendMessage with passing the thread id. Remember, your bot must be in the specified chat (and need necessary permissions - if required) to send message.
If the topic does not exist, you will receive a exception from Telegram Bot API as follows:
{
"ok": false,
"error_code": 400,
"description": "Bad Request: message thread not found"
}
So the workaround is something like:
- Send a test message
- If it fails with the specified exception the topic does not exist
- If bot is able to send message the topic exist, optionally, you can simply use the
deleteMessagemethod to delete the test message.
Hope this helps!