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:
Athurg Gooth
2023-05-29 13:29:21 +08:00
committed by GitHub
parent beb4d8ccb9
commit ce64894abe
7 changed files with 48 additions and 16 deletions

View File

@ -182,6 +182,14 @@ func (upsert SystemSettingUpsert) Validate() error {
if upsert.Value == "" {
return nil
}
// Robot Token with Reverse Proxy shoule like `http.../bot<token>`
if strings.HasPrefix(upsert.Value, "http") {
slashIndex := strings.LastIndexAny(upsert.Value, "/")
if strings.HasPrefix(upsert.Value[slashIndex:], "/bot") {
return nil
}
return fmt.Errorf("token start with `http` must end with `/bot<token>`")
}
fragments := strings.Split(upsert.Value, ":")
if len(fragments) != 2 {
return fmt.Errorf(systemSettingUnmarshalError, settingName)