Telegram bot: forward old messages - telegram

Is there any way to have a Telegram bot that forwards very old messages? Let's say that a bot has had access to a chat for 2 years, can it forward the first message it received in that chat?
From my understanding, the forwardMessage() function requires a message_id parameter which corresponds to the ID received by getUpdates(), which however only holds messages up to 24 hours prior to the call.
But maybe there is some other way?

Related

Make Telegram bot to read only /commands as administrator

I am using Telegram bot API with AWS Lambda and Zappa.
Everything was working fine. Until I realised that bot's webhook is being called everytime whenever a message is sent by anyone in the group.
I want to limit this webhook requests, as Lambda allows for only 1 million calls which is sufficient if bot is invoked, but only when /commands are called.
As I have to pin and edit messages using bot, that's why administrator permission is must.
I just want my bot to respond only to /commands along with administrator rights.
Please help me in tackling this issue.
I am assuming you added your bot to a Telegram group. In this case, the first thing that you need is group id. This should help: https://github.com/GabrielRF/telegram-id#web-group-id
And then you need to write a function that identifies the status of a chat member. You can do this using getChatMember method in Telegram Bots API.
If the chat member's status is "creator" or "administrator" then the response is sent to that user.
There are 2 things you need to do.
setPrivacy for your bot - go to BotFather chat and use the /setPrivacy command which gives you the ability to set:
'Enable' - your bot will only receive messages that either start with
the '/' symbol or mention the bot by username. (Should be default)
'Disable' - your bot
will receive all messages that people send to groups. Current status
is: DISABLED.
When setting the commands for the bot, set the BotCommandScopeAllChatAdministrators scope which should limit the use of the command only to the admins of the chat.

Can a bot who's a member of a group track the amount of messages sent?

I'm trying to track the number of messages sent in a group, which my bot was invited to, without having to disable Privacy Mode. Just Count.
I'm currently using node-telegram-bot-api.
Is this possible?
No.
The documentation is quite clear about this
A bot running in privacy mode will not receive all messages that
people send to the group. Instead, it will only receive:
Messages that start with a slash ‘/’
Replies to the bot's own messages
Service messages (people added or removed from the group, etc.)
Messages from channels where it's a member
So if a message does not fulfill those conditions your bot will not receive the update at all.

What is rate limit of accessing Telegram bot APIs?

I read in the docs that bot can send:
30 messages/second to different chats
1 message per second to the same chat
20 messages per minute to the same group chat
but this is all about sending messages, what about other endpoints? more specifically getChatMembersCount method?
Thanks
I know it's been a long time, but there's a very good resource now - https://limits.tginfo.me/en. There's a Bots section there. Also if you have time you can send pull request to the github repository - https://github.com/tginfo/Telegram-Limits/

Cannot delete bot message in telegram

I sent a message using telegram bot api. The bot I'm writing is kind of private channel bot, not inline.
So I've just sent a message, 48 hours has not lasted.
I tried to use this: https://api.telegram.org/botTOKEN/deleteMessage?chat_id=CID&message_id=MID
As a result I got "Bad Request: message can't be deleted"
Why so?
In my case I'm asking user for a price. If the price is not valid, I send a notification, asking user to re-enter the price. So, there might be many service messages, asking user to correct the price. After he entered correct value I want to erase these service messages. I can't think of any other solution except removing these messages, but I couldn't manage to do this.

How to get channel name in incoming message using only Telegram Bot API?

I'm working on one Telegram bot and faced a big problem: In order to exlude some "fraud" things one can do with my bot, I need to verify whether a user is admin in some channel or not. However, if user forward message from channel to bot, Chat.type parameter is still private, not channel.
Is there any way to get a pair user_id <--> in which channel user_id can post using only Bot API? Unfortunately, Inline mode doesn't help at all too.
Of course, I can use Telegram CLI for that, but in this particular situation it's prohibited.
As of May 6, 2016, a new field forward_from_chat is added to Message object. So my problem is solved.
More info about Message object: here

Resources