Use this method to delete a message, including service messages, with the following limitations: - A message can only be deleted if it was sent less than 48 hours ago. - Service messages about a supergroup, channel, or forum topic creation can't be deleted.
(
self,
chat_id: str | int,
message_id: int,
*,
read_timeout: ODVInput[float] = DEFAULT_NONE,
write_timeout: ODVInput[float] = DEFAULT_NONE,
connect_timeout: ODVInput[float] = DEFAULT_NONE,
pool_timeout: ODVInput[float] = DEFAULT_NONE,
api_kwargs: JSONDict | None = None,
)
| 1160 | ) |
| 1161 | |
| 1162 | async def delete_message( |
| 1163 | self, |
| 1164 | chat_id: str | int, |
| 1165 | message_id: int, |
| 1166 | *, |
| 1167 | read_timeout: ODVInput[float] = DEFAULT_NONE, |
| 1168 | write_timeout: ODVInput[float] = DEFAULT_NONE, |
| 1169 | connect_timeout: ODVInput[float] = DEFAULT_NONE, |
| 1170 | pool_timeout: ODVInput[float] = DEFAULT_NONE, |
| 1171 | api_kwargs: JSONDict | None = None, |
| 1172 | ) -> bool: |
| 1173 | """ |
| 1174 | Use this method to delete a message, including service messages, with the following |
| 1175 | limitations: |
| 1176 | |
| 1177 | - A message can only be deleted if it was sent less than 48 hours ago. |
| 1178 | - Service messages about a supergroup, channel, or forum topic creation can't be deleted. |
| 1179 | - A dice message in a private chat can only be deleted if it was sent more than 24 |
| 1180 | hours ago. |
| 1181 | - Bots can delete outgoing messages in private chats, groups, and supergroups. |
| 1182 | - Bots can delete incoming messages in private chats. |
| 1183 | - Bots granted :attr:`~telegram.ChatMemberAdministrator.can_post_messages` permissions |
| 1184 | can delete outgoing messages in channels. |
| 1185 | - If the bot is an administrator of a group, it can delete any message there. |
| 1186 | - If the bot has :attr:`~telegram.ChatMemberAdministrator.can_delete_messages` |
| 1187 | permission in a supergroup or a channel, it can delete any message there. |
| 1188 | |
| 1189 | .. |
| 1190 | The method CallbackQuery.delete_message() will not be found when automatically |
| 1191 | generating "Shortcuts" admonitions for Bot methods because it has no calls |
| 1192 | to Bot methods in its return statement(s). So it is manually included in "See also". |
| 1193 | |
| 1194 | .. seealso:: |
| 1195 | :meth:`telegram.CallbackQuery.delete_message` (calls :meth:`delete_message` |
| 1196 | indirectly, via :meth:`telegram.Message.delete`) |
| 1197 | |
| 1198 | Args: |
| 1199 | chat_id (:obj:`int` | :obj:`str`): |chat_id_channel| |
| 1200 | message_id (:obj:`int`): Identifier of the message to delete. |
| 1201 | |
| 1202 | Returns: |
| 1203 | :obj:`bool`: On success, :obj:`True` is returned. |
| 1204 | """ |
| 1205 | data: JSONDict = {"chat_id": chat_id, "message_id": message_id} |
| 1206 | return await self._post( |
| 1207 | "deleteMessage", |
| 1208 | data, |
| 1209 | read_timeout=read_timeout, |
| 1210 | write_timeout=write_timeout, |
| 1211 | connect_timeout=connect_timeout, |
| 1212 | pool_timeout=pool_timeout, |
| 1213 | api_kwargs=api_kwargs, |
| 1214 | ) |
| 1215 | |
| 1216 | async def send_message_draft( |
| 1217 | self, |