mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
feat: add Telegram bot config UI (#1747)
* Add retry wait for telegram.GetUpdates * Add support to set telegram robot token from UI * Change validator of UserSettingTelegramUserID * Add support to set telegram user id from UI * Fix typescript check * Add validator for SystemSettingTelegramRobotTokenName * Optimize error notice while config telegram params * Change for review * Fix telegram user id could not be empty * Fix telegram robot could not be empty * Fix for eslint (again) * Update web/src/components/Settings/SystemSection.tsx --------- Co-authored-by: Athurg Feng <athurg@gooth.org> Co-authored-by: boojack <stevenlgtm@gmail.com>
This commit is contained in:
@ -3,6 +3,7 @@ package api
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/exp/slices"
|
||||
)
|
||||
@ -186,6 +187,15 @@ func (upsert SystemSettingUpsert) Validate() error {
|
||||
return fmt.Errorf(systemSettingUnmarshalError, settingName)
|
||||
}
|
||||
|
||||
case SystemSettingTelegramRobotTokenName:
|
||||
if upsert.Value == "" {
|
||||
return nil
|
||||
}
|
||||
fragments := strings.Split(upsert.Value, ":")
|
||||
if len(fragments) != 2 {
|
||||
return fmt.Errorf(systemSettingUnmarshalError, settingName)
|
||||
}
|
||||
|
||||
default:
|
||||
return fmt.Errorf("invalid system setting name")
|
||||
}
|
||||
|
Reference in New Issue
Block a user