>(
- editing?.config ?? EMPTY_CONFIG.telegram,
+ { ...EMPTY_CONFIG[editing?.type ?? 'telegram'], ...(editing?.config ?? {}) },
)
const [enabled, setEnabled] = useState(editing?.enabled ?? true)
const [saving, setSaving] = useState(false)
@@ -233,12 +241,38 @@ function ChannelFormModal({
const onSubmit = async (e: FormEvent) => {
e.preventDefault()
+ if (type === 'telegram') {
+ if (!String(config.bot_token ?? '').trim()) {
+ toast.error('请填写 Telegram Bot Token')
+ return
+ }
+ if (!String(config.chat_id ?? '').trim()) {
+ toast.error('请填写通知 Chat ID')
+ return
+ }
+ if (!String(config.admin_user_ids ?? '').trim()) {
+ toast.error('请填写管理员 Telegram ID')
+ return
+ }
+ const chatID = String(config.chat_id ?? '').trim()
+ const groupChatID = String(config.group_chat_id ?? '').trim()
+ const channelChatID = String(config.channel_chat_id ?? '').trim()
+ if (!groupChatID && !channelChatID && !chatID.startsWith('-')) {
+ toast.error('请至少填写绑定群组 ID 或绑定频道 ID;或把群组/频道负数 ID 填到 Chat ID')
+ return
+ }
+ if (!groupChatID && !channelChatID && chatID.startsWith('-')) {
+ config.group_chat_id = chatID
+ }
+ }
setSaving(true)
try {
const input: NotifyChannelInput = {
name: name.trim(),
type: type,
- config,
+ config: Object.fromEntries(
+ Object.entries(config).map(([key, value]) => [key, String(value ?? '').trim()]),
+ ),
enabled,
}
if (editing) {
@@ -336,8 +370,24 @@ function ChannelFormModal({
onChange={(e) => updateConfig('channel_chat_id', e.target.value)}
/>
+
+ updateConfig('api_base_url', e.target.value)}
+ />
+
+
+ updateConfig('proxy_url', e.target.value)}
+ />
+
- 必须至少填写群组 ID 或频道 ID。只有配置群组/频道中的成员可以唤醒 Bot、使用 /start 用户名 密码 绑定账号和隐藏成人目录;/status、/search、/downloads、/stats 仅管理员 Telegram ID 或已绑定的本地管理员可用。
+ 必须至少填写群组 ID 或频道 ID。只有配置群组/频道中的成员可以唤醒 Bot、使用 /start 用户名 密码 绑定账号和隐藏成人目录;/status、/search、/downloads、/stats 仅管理员 Telegram ID 或已绑定的本地管理员可用。若测试通知超时,可填写反代 API 地址或代理地址。
>
)}