2023-05-26 04:43:51 +03:00
|
|
|
package telegram
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"net/url"
|
|
|
|
"strconv"
|
|
|
|
)
|
|
|
|
|
|
|
|
// SendReplyMessage make a sendMessage api request.
|
2023-09-06 16:14:07 +03:00
|
|
|
func (b *Bot) SendReplyMessage(ctx context.Context, chatID, replyID int64, text string) (*Message, error) {
|
2023-05-26 04:43:51 +03:00
|
|
|
formData := url.Values{
|
2023-09-13 16:36:43 +03:00
|
|
|
"chat_id": {strconv.FormatInt(chatID, 10)},
|
|
|
|
"text": {text},
|
|
|
|
}
|
|
|
|
|
|
|
|
if replyID > 0 {
|
|
|
|
formData.Set("reply_to_message_id", strconv.FormatInt(replyID, 10))
|
2023-05-26 04:43:51 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
var result Message
|
2023-05-29 14:49:05 +03:00
|
|
|
err := b.postForm(ctx, "/sendMessage", formData, &result)
|
2023-05-26 04:43:51 +03:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
return &result, nil
|
|
|
|
}
|
2023-09-13 16:36:43 +03:00
|
|
|
|
|
|
|
// SendMessage make a sendMessage api request.
|
|
|
|
func (b *Bot) SendMessage(ctx context.Context, chatID int64, text string) (*Message, error) {
|
|
|
|
return b.SendReplyMessage(ctx, chatID, 0, text)
|
|
|
|
}
|