deleteMessage
Elimina un mensaje.
Devuelve: Si la llamada tiene éxito, devuelve True.
Parámetros
| Parámetro | Tipo | Obligatorio | Descripción |
|---|---|---|---|
chat_id | Integer or String | Sí | ID del chat |
message_id | Integer | Sí | ID del mensaje |
Ejemplo de solicitud
curl
curl -s -X POST "https://api.telegram.org/bot$TOKEN/deleteMessage" \
-H "Content-Type: application/json" \
-d '{"chat_id":123456789,"message_id":42}'
Python
import requests
TOKEN = "123456789:AAEexampleTokenReplaceWithYours"
resp = requests.post(
f"https://api.telegram.org/bot{TOKEN}/deleteMessage",
json={
"chat_id": 123456789,
"message_id": 42
},
timeout=30,
)
print(resp.json())
JavaScript
const TOKEN = "123456789:AAEexampleTokenReplaceWithYours";
const res = await fetch(`https://api.telegram.org/bot${TOKEN}/deleteMessage`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"chat_id": 123456789,
"message_id": 42
}),
});
console.log(await res.json());
Guía paso a paso: Cómo crear un bot en Telegram paso a paso: de BotFather a tu primer mensaje
Métodos relacionados
sendMessageEnvía un mensaje de texto.forwardMessageReenvía un mensaje.forwardMessagesReenvía varios mensajes.copyMessageCopia un mensaje sin el enlace al original.copyMessagesCopia varios mensajes.deleteMessagesElimina varios mensajes.sendChatActionEnvía una acción de chat (typing, etc.).sendMessageDraftEnvía un borrador de mensaje: vista previa temporal (Bot API 9.5+).sendContactEnvía un contacto.sendLocationEnvía una ubicación.sendVenueEnvía un lugar.setMessageReactionEstablece una reacción en un mensaje.