can Telegram Bot sends message to group? - telegram-bot

I create a group on Telegram and created a bot and add in.
I am trying to send a message to group that I created and the error shown as below
{"ok":false,"error_code":403,"description":"[Error]: Forbidden: can't write to chat with deleted user"}
I have use getUpdates from Bot Documents and managed to get chat id and doesn't work again for me. p2p (private type message) works for me but not group type.
Any advice please? Thank you.

Yes you can, you have to invite the bot into the group, grab the chat_id of the group and send the message as you are sending a normal message to a private user.
The error message is self-explanatory tough.

Related

How to send message to the user by using telegram id and python_telegram_bot library?

I want to send the message to anybody by using his telegramid and python_telegram_bot library.
I can send the message to me by using below code but if I put other's id then I can not send the message and it says chat not found message.
updater = Updater(mybot_token, use_context=True)
updater.bot.send_message(chat_id = receiver_id, text="welcome")
I am not sure why it is only possible to send the message to me, not the others even though I puth the chat_id as their telegram_id.
Bots can only send messages to users that have already started the bot. See the Telegram Bot docs.

How To Get Telegram Bot ID?

Anyone Who Add In My Group, I Want To Greet Them With My Bot! But After Some Time I Want To Delete That Bot Messages Too... For That I Need Bot Chat ID. So From Where I Can Get It?? The Bot Is Created With BotFather!
To delete messages, you only need the chat_id of the chat the message was sent in and the message_id of the message. See deleteMessage, you don't need the user id of your bot. If you need that for some other reason, you can get the via getMe: The return value is a User object that has the id field.

How to get authenticated by Telegram bot in Group chats?

Please kindly someone explain me how can the Telegram bot could understand who is sending the command in group chats and respond it with the the unique answer which is just for that user.
Surely in this case security issues should be considered and a user must not send command as another user.
I guess I can use username to send along with command.
Any suggestions...
The Message Object contains two objects apart from other objects:
Chat, message['chat'] which represents the Chat from which the message is coming. In your case the group.
User, message['from'] which represents the user that sent the message/command.
So it's easy to differentiate which user sent the message. And in case of Private chats, both the Chat object and the User Object are same.

Is that possible a telegram bot can remove messages from group

i want create telegram bot .
It can join to the group and delete messages in group .
Is that possible a telegram bot can remove messages from group ?
i search and some people say yes it possible , some people say no
Check this link out, it seems the new bot API made it possible with some restrictions:
https://core.telegram.org/bots/api#deletemessage
The following details are from telegram API page:
A message can only be deleted if it was sent less than 48 hours ago.
Bots can delete outgoing messages in groups and supergroups.
Bots granted can_post_messages permissions can delete outgoing messages in channels.
If the bot is an administrator of a group, it can delete any message there.
If the bot has can_delete_messages permission in a supergroup or a channel, it can delete any message there.
Returns True on success.
This is now outdated, please see Darkc0d3r's answer
Using the Telegram Bot API? No, there is no such functionality as of now.
However you can if you are using the Telegram API, where you can use the messages.deleteMessages method, which requires you to give it a list of message id's as a parameter.
You can use
bot.DeleteMessageAsync(chatId, messageId)
you should make it in a try catch in case the message doesn't exist anymore or you have a wrong messageId,
messageId is a property which you get in MessageEventArgs.Message,
Note: the chatId should be the Group/Channel chatId and not of the user who sent it, get that in Chat.Id property of MessageEventArgs.Message ...

How can I send message to specific chatID?

I have chatId and want send messages while execute some tasks from java code. I found this explain on telegram "Bots can't initiate conversations with users. A user must either add them to a group or send them a message first. People can use telegram.me/ links or username search to find your bot." But my task works good when I use https request directly from browser. My bot perfectly answer for requests but how I can do this without user request?
I can not truly understand your case!
Anyway, your bot can send a message to a chat ID Only if the user witch blongs to the specified chat ID added your bot (send start to a bot).
and if it happened then send your message with
/sendMessage