feat: add support for sending notifications to Telegram group topics
This commit is contained in:
parent
da37b08fa0
commit
61014eae72
4 changed files with 21 additions and 1 deletions
|
|
@ -86,6 +86,7 @@ const defaultValuesForType = {
|
||||||
type: "telegram" as const,
|
type: "telegram" as const,
|
||||||
botToken: "",
|
botToken: "",
|
||||||
chatId: "",
|
chatId: "",
|
||||||
|
threadId: "",
|
||||||
},
|
},
|
||||||
generic: {
|
generic: {
|
||||||
type: "generic" as const,
|
type: "generic" as const,
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,20 @@ export const TelegramForm = ({ form }: Props) => {
|
||||||
</FormItem>
|
</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>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,7 @@ export const telegramNotificationConfigSchema = type({
|
||||||
type: "'telegram'",
|
type: "'telegram'",
|
||||||
botToken: "string",
|
botToken: "string",
|
||||||
chatId: "string",
|
chatId: "string",
|
||||||
|
threadId: "string?",
|
||||||
});
|
});
|
||||||
|
|
||||||
export const genericNotificationConfigSchema = type({
|
export const genericNotificationConfigSchema = type({
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,9 @@
|
||||||
import type { NotificationConfig } from "~/schemas/notifications";
|
import type { NotificationConfig } from "~/schemas/notifications";
|
||||||
|
|
||||||
export const buildTelegramShoutrrrUrl = (config: Extract<NotificationConfig, { type: "telegram" }>) => {
|
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;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue