mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
feat: add telegram proxy support (#1764)
* Add support for reverse proxy of telegram API * Add Telegram API proxy hint --------- Co-authored-by: Athurg Feng <athurg@gooth.org>
This commit is contained in:
@@ -3,23 +3,19 @@ package telegram
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
var ErrNoToken = errors.New("token is empty")
|
||||
|
||||
func (r *Robot) postForm(ctx context.Context, apiPath string, formData url.Values, result any) error {
|
||||
token := r.handler.RobotToken(ctx)
|
||||
if token == "" {
|
||||
return ErrNoToken
|
||||
apiURL, err := r.apiURL(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
uri := "https://api.telegram.org/bot" + token + apiPath
|
||||
resp, err := http.PostForm(uri, formData)
|
||||
resp, err := http.PostForm(apiURL+apiPath, formData)
|
||||
if err != nil {
|
||||
return fmt.Errorf("fail to http.PostForm: %s", err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user