pull/103/merge
Arman 8 years ago committed by GitHub
commit c29c54df59
  1. 1
      .gitignore
  2. 28
      bot_test.go
  3. 37
      configs.go
  4. 8
      helpers.go

1
.gitignore vendored

@ -1,2 +1,3 @@
.idea/
coverage.out
debug.test

@ -422,12 +422,17 @@ func TestSendChatConfig(t *testing.T) {
func TestSendEditMessage(t *testing.T) {
bot, _ := getBot(t)
msg, err := bot.Send(tgbotapi.NewMessage(ChatID, "Testing editing."))
testMsg := tgbotapi.NewMessage(ChatID, "Testing editing.")
testBtn := tgbotapi.NewInlineKeyboardButtonData("Test", "testdata")
testMsg.ReplyMarkup = tgbotapi.NewInlineKeyboardMarkup(tgbotapi.NewInlineKeyboardRow(testBtn))
msg, err := bot.Send(testMsg)
if err != nil {
t.Error(err)
t.Fail()
}
//Keyboard should be removed here!
edit := tgbotapi.EditMessageTextConfig{
BaseEdit: tgbotapi.BaseEdit{
ChatID: ChatID,
@ -443,6 +448,27 @@ func TestSendEditMessage(t *testing.T) {
}
}
func TestSendDeleteMessage(t *testing.T) {
bot, _ := getBot(t)
msg, err := bot.Send(tgbotapi.NewMessage(ChatID, "Testing deleting."))
if err != nil {
t.Error(err)
t.Fail()
}
delete := tgbotapi.DeleteMessageConfig{
ChatID: ChatID,
MessageID: msg.MessageID,
}
_, err = bot.Send(delete)
if err != nil {
t.Error(err)
t.Fail()
}
}
func TestGetUserProfilePhotos(t *testing.T) {
bot, _ := getBot(t)

@ -815,6 +815,25 @@ func (config EditMessageReplyMarkupConfig) method() string {
return "editMessageReplyMarkup"
}
// DeleteMessageConfig allows you to delete an existing message (sent by the bot).
type DeleteMessageConfig struct {
ChatID int64
MessageID int
}
func (config DeleteMessageConfig) values() (url.Values, error) {
v := url.Values{}
v.Add("chat_id", strconv.FormatInt(config.ChatID, 10))
v.Add("message_id", strconv.Itoa(config.MessageID))
return v, nil
}
func (config DeleteMessageConfig) method() string {
return "deleteMessage"
}
// UserProfilePhotosConfig contains information about a
// GetUserProfilePhotos request.
type UserProfilePhotosConfig struct {
@ -988,21 +1007,3 @@ type PreCheckoutConfig struct {
ErrorMessage string
}
// DeleteMessageConfig contains information of a message in a chat to delete.
type DeleteMessageConfig struct {
ChatID int64
MessageID int
}
func (config DeleteMessageConfig) method() string {
return "deleteMessage"
}
func (config DeleteMessageConfig) values() (url.Values, error) {
v := url.Values{}
v.Add("chat_id", strconv.FormatInt(config.ChatID, 10))
v.Add("message_id", strconv.Itoa(config.MessageID))
return v, nil
}

@ -509,6 +509,14 @@ func NewEditMessageReplyMarkup(chatID int64, messageID int, replyMarkup InlineKe
}
}
// NewDeleteMessage allows you to delete an existing message (sent previously by the bot)
func NewDeleteMessage(chatID int64, messageID int) DeleteMessageConfig {
return DeleteMessageConfig{
ChatID: chatID,
MessageID: messageID,
}
}
// NewHideKeyboard hides the keyboard, with the option for being selective
// or hiding for everyone.
func NewHideKeyboard(selective bool) ReplyKeyboardHide {