feat: add support for sending notifications to Telegram group topics (#401)

This commit is contained in:
Didin Sino 2026-01-28 01:43:05 +07:00 committed by GitHub
parent eaaaa55c90
commit d449547336
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 21 additions and 1 deletions

View file

@ -86,6 +86,7 @@ const defaultValuesForType = {
type: "telegram" as const,
botToken: "",
chatId: "",
threadId: "",
},
generic: {
type: "generic" as const,

View file

@ -39,6 +39,20 @@ export const TelegramForm = ({ form }: Props) => {
</FormItem>
)}
/>
<FormField
control={form.control}
name="threadId"
render={({ field }) => (
<FormItem>
<FormLabel>Thread ID (Optional)</FormLabel>
<FormControl>
<Input {...field} placeholder="3" />
</FormControl>
<FormDescription>Telegram Group Topic ID to send notifications to.</FormDescription>
<FormMessage />
</FormItem>
)}
/>
</>
);
};

View file

@ -71,6 +71,7 @@ export const telegramNotificationConfigSchema = type({
type: "'telegram'",
botToken: "string",
chatId: "string",
threadId: "string?",
});
export const genericNotificationConfigSchema = type({

View file

@ -1,5 +1,9 @@
import type { NotificationConfig } from "~/schemas/notifications";
export const buildTelegramShoutrrrUrl = (config: Extract<NotificationConfig, { type: "telegram" }>) => {
return `telegram://${config.botToken}@telegram?channels=${config.chatId}`;
let shoutrrrUrl = `telegram://${config.botToken}@telegram?channels=${config.chatId}`;
if (config.threadId) {
shoutrrrUrl += `:${config.threadId}`;
}
return shoutrrrUrl;
};