Not able to get telegram group chat_id param - telegram

My goal is to send messages to a specific telegram group using a telegram bot. So, I created a telegram bot and I added itself to the telegram group in order to retrieve the chat_id param. However I am not able to get the chat_id, calling the getUpdates API, I always get:
ok true
result []
Here the steps I did to try to get the chat_id:
I Created a new bot via botFather.
I Created a new telegram group and added the bot.
I used the getMe API to see that everything was good with the bot.
I disabled for privacy the bot (suggested in several forum).
To extract the chat_id, I used the getUpdates method. I did a GET with this URL https://api.telegram.org/botTOKEN/getUpdates (where TOKEN is substitute with what I got from botFather)
I continued with the step 5, while writing random messages on the telegram group and also calling the bot with /start.
There are no coding tasks till now, I have just been using the telegram app.
Not able to get the chat_id; hope you can help me, thanks in advance.

Related

Is it possible to send message from my account with interval in Telegram?

I need to send message from my own account with my nickname and profile (not from bot account) to any selected contact or group. How can I do that? I found bots with similar behaviour but messages are sent from bot account not from my profile which is what I need.
what you're looking for is a so-called "userbot" or "selfbot", i.e. a bot that works with the Telegram API in contrast to the Telegram Bot API. Searching for Telegram userbot library <your preferred programming language> should probably get you started.

Telegram BOT - How to get chat ID of users in my group?

I've been using a Telegram BOT to send notifications for a group, and for users.
I already know i can get Chat ID by receiving a message from the user on my bot, using getUpdates.
I also know i can get Group ID using the same method...
But what i really need is:
There is three users in my group.
My bot.
Me.
Another user that didn't sent any messages to my bot so it does not appear on getUpdates
Is it possible to get this third user his ID?
PS: I am the group owner, and also added my bot as Admin...
The third user is a normal user.
Can someone help me?
Thanks!
That's not possible with the offical Telegram Bot API
Possible Workarounds:
Hold a list of your own. If a user is joining (new_chat_member), lefting (left_chat_member), somebody is sending a message in the group, and so on. Check Message for more information.
Check if a user is a member of the group with getChatMember.
Also may be helpful: getChatMembersCount and getChatAdministrators

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.

How do I determine if a message is deleted from telegram group chat in api results?

I am creating a telegram bot to fetch messages from a chat group. But I have noticed that inappropriate comments that are deleted by admin/me in the group are still fetched when I call /getUpdates method (i.e. using telegram api)
https://api.telegram.org/bot<token>/getUpdates
My question is - is there a way, I can tell that a message has been deleted in the group from the json results that I get when I call the /getUpdates endpoint?
You need to look at edited_message, see: https://core.telegram.org/bots/api#update

ignore positive chat I'd telegram bot

I have webhook a telegram bot for search data my a hosted
How can ignore positive chat I'd by bot I have a bot to search files from my hosted data And get link using telegram I want that bot just work in groups only If any person try to use it in personal chat it will not give reply means not search data and not give a link
Every message has a chat field and each chat has a type see telegram bot api
Type of chat, can be either “private”, “group”, “supergroup” or
“channel”
check if type of chat of message is equal to “group” or “supergroup” then do what you want.
In php can check like below
if($message->chat->type == "group")
...
Can you clear before using this command
if($message->chat->type == "group")
Need other commands in header
Or full command please

Resources