pull/95/merge
Mohamad Jahani 8 years ago committed by GitHub
commit 3ea3cf2b24
  1. 14
      bot.go
  2. 15
      bot_test.go

@ -255,6 +255,20 @@ func (bot *BotAPI) Send(c Chattable) (Message, error) {
}
}
// DeleteMessage deletes a message from a Chat
//
// It requires the Message to delete
func (bot *BotAPI) DeleteMessage(message Message) (APIResponse, error) {
v := url.Values{}
v.Add("chat_id", strconv.FormatInt(message.Chat.ID, 10))
v.Add("message_id", strconv.Itoa(message.MessageID))
bot.debugLog("deleteMessage", v, nil)
return bot.MakeRequest("deleteMessage", v)
}
// debugLog checks if the bot is currently running in debug mode, and if
// so will display information about the request and response in the
// debug log.

@ -58,6 +58,21 @@ func TestGetUpdates(t *testing.T) {
}
}
func TestDeleteMessage(t *testing.T) {
bot, _ := getBot(t)
msg := tgbotapi.NewMessage(ChatID, "A test message from the test library in telegram-bot-api")
msg.ParseMode = "markdown"
message, _ := bot.Send(msg)
_, err := bot.DeleteMessage(message)
if err != nil {
t.Error(err)
t.Fail()
}
}
func TestSendWithMessage(t *testing.T) {
bot, _ := getBot(t)