mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
feat: notify by telegram while new memo create by HTTP (#2215)
* Inject telegram bot into API service * Add support for send telegram message * Send notification by telegram while new memo post
This commit is contained in:
@@ -9,9 +9,12 @@ import (
|
||||
// SendReplyMessage make a sendMessage api request.
|
||||
func (b *Bot) SendReplyMessage(ctx context.Context, chatID, replyID int64, text string) (*Message, error) {
|
||||
formData := url.Values{
|
||||
"reply_to_message_id": {strconv.FormatInt(replyID, 10)},
|
||||
"chat_id": {strconv.FormatInt(chatID, 10)},
|
||||
"text": {text},
|
||||
"chat_id": {strconv.FormatInt(chatID, 10)},
|
||||
"text": {text},
|
||||
}
|
||||
|
||||
if replyID > 0 {
|
||||
formData.Set("reply_to_message_id", strconv.FormatInt(replyID, 10))
|
||||
}
|
||||
|
||||
var result Message
|
||||
@@ -22,3 +25,8 @@ func (b *Bot) SendReplyMessage(ctx context.Context, chatID, replyID int64, text
|
||||
|
||||
return &result, nil
|
||||
}
|
||||
|
||||
// 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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user