mirror of
https://github.com/usememos/memos.git
synced 2024-11-30 22:14:19 +03:00
9987337eca
Fix all ID from int to int64 to avoid 32bits machine break
39 lines
927 B
Go
39 lines
927 B
Go
package telegram
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"fmt"
|
|
"net/url"
|
|
"strconv"
|
|
)
|
|
|
|
// EditMessage make an editMessageText api request.
|
|
func (b *Bot) EditMessage(ctx context.Context, chatID, messageID int64, text string, inlineKeyboards [][]InlineKeyboardButton) (*Message, error) {
|
|
formData := url.Values{
|
|
"message_id": {strconv.FormatInt(messageID, 10)},
|
|
"chat_id": {strconv.FormatInt(chatID, 10)},
|
|
"text": {text},
|
|
}
|
|
|
|
if len(inlineKeyboards) > 0 {
|
|
var markup struct {
|
|
InlineKeyboard [][]InlineKeyboardButton `json:"inline_keyboard"`
|
|
}
|
|
markup.InlineKeyboard = inlineKeyboards
|
|
data, err := json.Marshal(markup)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("fail to encode inlineKeyboard: %s", err)
|
|
}
|
|
formData.Set("reply_markup", string(data))
|
|
}
|
|
|
|
var result Message
|
|
err := b.postForm(ctx, "/editMessageText", formData, &result)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &result, nil
|
|
}
|