TGDeleteMessage - Sreyas-Sreelal/tgconnector GitHub Wiki

TGDeleteMessage

  • Description

    Deletes a specified message in a chat

  • Parameters

    • TGBot:bot - bot instance id
    • TGChatId:chatid[] - chat id to which message to be deleted
    • TGMessage:messageid - id of message to be deleted
  • Example

    new TGBot:bot = TGConnect("your_bot_token_here");
    new TGChatId:chatid[] = "562896556";//replace with your chatid
    
    TGSendMessage(
    	bot,
    	chatid,
    	"`markdown text` ***bold*** _italic_ 123",
    	.parse_mode=MARKDOWN,
    	.callback="SendingMessage"
    );
    
    forward SendingMessage(TGBot:bot,TGMessage:messageid);
    public SendingMessage(TGBot:bot,TGMessage:messageid) {
    	new TGChatId:chatid[12];
    	TGCacheGetChatId(chatid);
    	TGDeleteMessage(bot,chatid,messageid);
    	return 1;
    }
    
  • Notes

    • A message can only be deleted if it was sent less than 48 hours ago.
    • Bots can delete outgoing messages in private chats, groups, and supergroups.
    • 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.