I have a TG bot that needs to pin a message. For this it needs admin rights. Is there an event that a TG bot can use to automatically detect when it is promoted so it automatically creates a message and pins it?
Ok a related note, can the bot read the pinned message and append (not replace) the pinned message?
I have a TG bot that needs to pin a message. May I pin a message?
Yes. See more about pinChatMessage
May I unpin a message?
Yes. See more about unpinChatMessage
For this it needs admin rights. Can I check it?
Yes. see more 1 - see more 2
Can I promote a user to admin?
Yes - see more
Can the bot read the pinned message and append (not replace) the pinned message?
No The bot can't read messages. As you can see bots can be add in channel just as administrator!
So if a message pin it can read it. but can't append a pinned message. Just one message can Pin in the channel. Maybe you can get message and append it with new message with your bot and pin it as new message.
Update :
If someone upgrades the bot to admin. Now, can the bot “auto-detect” the upgrade and THEN pin the message autonomously?
No , There is no response from Telegram server when your bot promoted as admin so just can try send message and check if you have right permission :-)
Here is example of Telegram's server response when a message will be send to a channel.
{
"ok": true,
"result": [{
"update_id": 954197934,
"channel_post": {
"message_id": 26,
"author_signature": "Ğąme Ǿver!",
"chat": {
"id": -1001331798505,
"title": "Game Over is best",
"type": "channel"
},
"date": 1576160427,
"text": "0"
}
}]
}
And here is example of Telegram's server response when a message will be pin send to a channel.
{
"ok": true,
"result": [{
"update_id": 954197935,
"channel_post": {
"message_id": 27,
"chat": {
"id": -1001331798505,
"title": "Game Over is best",
"type": "channel"
},
"date": 1576160437,
"pinned_message": {
"message_id": 26,
"author_signature": "Ğąme Ǿver!",
"chat": {
"id": -1001331798505,
"title": "Game Over is best",
"type": "channel"
},
"date": 1576160427,
"text": "0"
}
}
}]
}