mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
feat: set memo visibility in telegram (#1824)
* Add telegram.Bot in MessageHandler * Change single message handler like group messages * Move message notify wrapper from plugin to server * Add keyboard buttons on Telegram reply message * Add support to telegram CallbackQuery update * Set visibility in callbackQuery * Change original reply message after callbackQuery --------- Co-authored-by: Athurg Feng <athurg@gooth.org>
This commit is contained in:
@@ -2,18 +2,32 @@ 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 int, text string) (*Message, error) {
|
||||
func (b *Bot) EditMessage(ctx context.Context, chatID, messageID int, text string, inlineKeyboards [][]InlineKeyboardButton) (*Message, error) {
|
||||
formData := url.Values{
|
||||
"message_id": {strconv.Itoa(messageID)},
|
||||
"chat_id": {strconv.Itoa(chatID)},
|
||||
"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 {
|
||||
|
Reference in New Issue
Block a user