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:
Athurg Gooth
2023-09-13 21:36:43 +08:00
committed by GitHub
parent 36209eaef1
commit 626ff5e3a7
4 changed files with 58 additions and 12 deletions

View File

@@ -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)
}