Initial Obsidian reminder notifier plugin
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
import { NotificationProviderConfig, PluginSettings } from "../types";
|
||||
|
||||
export const PROVIDER_TEMPLATES: NotificationProviderConfig[] = [
|
||||
{
|
||||
id: "local",
|
||||
type: "local",
|
||||
name: "Local notice",
|
||||
enabled: true,
|
||||
config: {},
|
||||
},
|
||||
{
|
||||
id: "telegram",
|
||||
type: "telegram",
|
||||
name: "Telegram Bot",
|
||||
enabled: false,
|
||||
config: {
|
||||
botToken: "123456:ABCDEF_your_bot_token",
|
||||
chatId: "123456789",
|
||||
parseMode: "Markdown",
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "ntfy",
|
||||
type: "ntfy",
|
||||
name: "ntfy.sh",
|
||||
enabled: false,
|
||||
config: {
|
||||
serverUrl: "https://ntfy.sh",
|
||||
topic: "my-obsidian-reminders",
|
||||
token: "",
|
||||
priority: 3,
|
||||
tags: ["calendar", "obsidian"],
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "discord",
|
||||
type: "discord",
|
||||
name: "Discord Webhook",
|
||||
enabled: false,
|
||||
config: {
|
||||
webhookUrl: "https://discord.com/api/webhooks/...",
|
||||
username: "Obsidian Reminder",
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "webhook",
|
||||
type: "webhook",
|
||||
name: "Generic Webhook",
|
||||
enabled: false,
|
||||
config: {
|
||||
method: "POST",
|
||||
url: "https://example.com/reminder",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
bodyTemplate: {
|
||||
title: "{{title}}",
|
||||
message: "{{message}}",
|
||||
dueAt: "{{dueAt}}",
|
||||
sourceFile: "{{sourceFile}}",
|
||||
},
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
export const DEFAULT_SETTINGS: PluginSettings = {
|
||||
defaultChannels: [],
|
||||
scanVaultOnStartup: true,
|
||||
scanOnFileChange: true,
|
||||
checkIntervalSeconds: 60,
|
||||
afterSend: "mark-sent",
|
||||
reminderSyntax: "@remind(YYYY-MM-DD HH:mm, provider)",
|
||||
notificationProviders: [PROVIDER_TEMPLATES[0]],
|
||||
};
|
||||
|
||||
export function createDefaultSettings(): PluginSettings {
|
||||
return JSON.parse(JSON.stringify(DEFAULT_SETTINGS)) as PluginSettings;
|
||||
}
|
||||
|
||||
export function cloneTemplate(type: string): NotificationProviderConfig | null {
|
||||
const template = PROVIDER_TEMPLATES.find((item) => item.type === type);
|
||||
if (!template) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const suffix = Date.now().toString(36);
|
||||
return {
|
||||
...template,
|
||||
id: `${template.type}-${suffix}`,
|
||||
config: JSON.parse(JSON.stringify(template.config)) as Record<string, unknown>,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user