telepush
telepush copied to clipboard
Add chat topic options for messages
Hello, I looked on the issues and could not find the option to set the parameters for sending a message to a chat that has topic enabled.
I've digged into findiing things and I came out with the following schema:
To obtain the ID of the first message in the topic, in the Telegram desktop client, right-click on the first message in the topic, select “Copy Message Link.”
You will receive a link similar to this: https://t.me/c/xxxxxxxxxx/1/1
General: https://t.me/c/xxxxxxxxxx/1/1 (the default topic)
Topic_A: https://t.me/c/xxxxxxxxxx/2/1
Topic_B: https://t.me/c/xxxxxxxxxx/3/1
https://t.me/c/STREAM_ID/TOPIC_ID/message_id
STREAM_ID: xxxxxxxxxx
(don't know the name of it, let's call it stream_id)
CHANNEL_ID: -100STREAM_ID - concatenate '-100' in front of stream_id -> -100xxxxxxxxxx
chat_id: -100CHANNEL_ID
_STREAM_ID
chat_id: -100xxxxxxxxxx_xxxxxxxxxx
message_thread_id as I understand it is the TOPIC_ID: 1 (General), 2 (Topic_A), 3 (Topic_B)
I've tested and it works as intended with the following curls:
## Set the TELEGRAM_BOT_TOKEN as env variable
export TELEGRAM_BOT_TOKEN=BOT_ID:ACCESS_TOKEN
## Debug directly with the bot with:
curl https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/getUpdates
## Send message to untopiced chat (in case of topic chats it goes to General (1))
curl -X POST -H 'Content-Type: application/json' \
-d '{"message_thread_id": "TOPIC_ID", "chat_id": "-100xxxxxxxxxx_xxxxxxxxxx", "text": "Test message "}' \
https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/sendMessage
Excuse me if I got the namings wrong and reinvented the wheel, would this be possible to implement? Thank you.