how do I retrieve the latest telegram bot messages posted in a channel through the api? - telegram-bot

I want to see the last post a bot makes to my channel through the API/https
I tried getUpdates and it only shows messages I sent to the bot. I'd like to see messages the bot broadcasts to my channel
https://api.telegram.org/botxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/getUpdates

The getUpdates method only retrieves messages that are sent to the bot by normal users. Bots cannot see other bot messages, that means it cannot see its own messages. However you can track messages sent by the bot in your code logic. E.g. in Node.js you would do something like:
bot.sendMessage(channelId, "The message sent to the channel").then(ctx => {
// ctx contains the details of the message sent to the channel
// you can do whatever you want with it
});

Related

discordGo guildUpdate

When guildUpdate is detected when updated with a server.
with discordGo
I want my bot to send a message to a channel. So when an authorized person makes changes to the server, I want a message to be sent to a particular channel only once, how can I do that?
Its logic is like an invitation bot. Instead of sending a message when the member logs in, it will only send a notification to a channel when the server is edited (updated). But I don't know as I am new to this coding language. :(

How to delete messages posted to slack after sometime?

I have a slack bot that is sending direct messages to users. I want to add a functionality that will delete the message automatically 10 minutes after it has been sent. Please help.
There is an api that is used to delete chat messages :
https://api.slack.com/methods/chat.delete
For your use case, you need to capture the channel & timestamp details from the response of message that was sent. Once the message is sent, wait for required time and then call 'chat.delete' api to delete the message.

Telegram Bot - Send Info message

currently I am working to creating telegram bot. Now I required to know is there is any API to send info messages (like the one we get during a user is added r deleted in a group chat)
Thanks in advance
What you want to do can be done using answerCallbackQuery method.
But first of all you have to create a CallbackQuery using InlineKeyboardMarkup to create inline keyboards you can follow the steps in this link.
After creating the callback query you have to answer it using one of the codes below:
if (update.CallbackQuery.Data == "CQ1")
{
await Bot.AnswerCallbackQueryAsync(update.CallbackQuery.Id,"Text",true,null, 0);
}
This way the message will look like a message box and will disappear after the user taps on OK. But if you use the code below, the message will show up and disappear automatically after a few seconds.
else if (update.CallbackQuery.Data == "CQ2")
{
await Bot.AnswerCallbackQueryAsync(update.CallbackQuery.Id, "Text", false,null, 30);
}
By the way, messages that are shown at times like adding a user to a
group are service messages and theses kinds of message can only be
sent by telegram server.
If my suggestion does not fix your issue you can use pinMessage method
that sticks a single message to the top of the page in groups and
channels. But note that you can only pin one message to a channel
or group and for pinning another message firstly you should unpin the
previous one.
Currently there is no way to send such info messages.
And in my opinion, this feature is unlikely to be added in future because:
info messages usually tell you information about your chat; they are managed by telegram servers
therefore they should not be sent by Users
bot is an instance of User

Is it possible to read bot Telegram messages

I have successfully created a bot with and am able to fetch messages from a chat using the getupdates method (long polling).
The getUpdates method is only showing user posted messages (clientside). When I post messages directly using the sendmessage method (serverside) these messages do appear in the chat, but do not in the getUpdates log.
This page https://github.com/LibreLabUCM/teleg-api-bot/wiki/Getting-started-with-the-Telegram-Bot-API#getupdates
states it logs only when "An user messages your bot, either directly or in a group." and some other ways, but the sendMessage way is not mentioned.
I've read a bit on the setwebhook method (push) but am not sure this will fix my issue.
Is this possible?
According to Bot FAQ, bots will not be able to see messages from other bots regardless of mode.
The getUpdates method shows only updates from users, not from the bot itself. This means that when you fetch the new messages with the getUpdates method, the Telegram API will list only the messages sent by the users, not the messages sent by the bot via any method (e.g sendMessage, sendPhoto ...).
To get old messages you can store the entire update (or only the parts of the update you need) for each message (even those sent by the bot with the sendMessage method) in a file or in a database and when you need an old message you can simply fetch it form the database or the files.
I managed to get the bot messages using two bots.
One does the sendMessage method and the other one does the getUpdates method.
#Giolacca9 answer inspired me to try this workaround and it works, "not from the bot itself" :)

What happens when GCM topics limit exceeded?

From documentations,
we can get TOO_MANY_SUBSCRIBERS error, when try to send push message to topic.
Are messages sent or topics stop working?
From this point we need to send messages using tokens?
Should we use tokens instead of topics from the beginning?
Is this error comes only to server?
If yes, why it's recommended to unsubscribe device from topic?
Is it possible to catch this error at the client?