Edit posts in a Telegram channel after 1 hour using API (PHP) - telegram

Is there a way to automatically edit posts in a channel using a bot after 1 hour?
For example, I want this message:
This is my Ad
call me: 2000
Changed to this message after 1 hour:
This is my Ad
Expired

Read section Updating messages in telegram documentation.

Related

401 Unauthorized error after a year of successful using of Telegram API

Today when I as usually run my client to read income messages of my Telegram Bot I get the error
{"ok":false,"error_code":401,"description":"Unauthorized"}
I had been successfully used Telegram API every day during a year and never seen this error. I also didn't change any settings
What may happened?
At the page https://core.telegram.org/api/errors I read it's possible to get more detailed error description like AUTH_KEY_UNREGISTERED, AUTH_KEY_INVALID, USER_DEACTIVATED and so on.
But how can I do that?
Is it possible just to add something in the address bar to the request like https://api.telegram.org/bot<MY_TOKEN>/... ?
It may be helpful for someone.
I was not using my main account of Telegram associated with my phone number more than a year. That's why Telegram deleted my main account and accordingly my Telegram bot.

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.

Telegram bot: forward old messages

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?

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/

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