-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update: Readme.md fix: merge conflicts
- Loading branch information
Showing
15 changed files
with
139 additions
and
141 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export const NotificationMessage = { | ||
SUCCESS: `Backup successful at ${new Date()}`, | ||
FAILURE: `Backup failed at ${new Date()}`, | ||
SUCCESS: `[+] Backup successful at ${new Date()}`, | ||
FAILURE: `[-] Backup failed at ${new Date()}`, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Notifier } from "./Notifier"; | ||
|
||
export class CustomNotifier extends Notifier { | ||
constructor(webhookUrl: string, message: string) { | ||
super(webhookUrl, message); | ||
} | ||
sendNotification(): void { | ||
this.notify(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,11 @@ | ||
import Print from "../constants/Print"; | ||
import { Notifier } from "./Notifier"; | ||
|
||
export class DiscordNotifier extends Notifier { | ||
private message: string = ""; | ||
|
||
constructor(private readonly webhookUrl: string) { | ||
super(); | ||
this.webhookUrl = webhookUrl; | ||
constructor(webhookUrl: string, message: string) { | ||
super(webhookUrl, message); | ||
} | ||
|
||
validate() { | ||
if (!this.webhookUrl) { | ||
Print.error("DISCORD_WEBHOOK_URL is not set"); | ||
throw new Error("DISCORD_WEBHOOK_URL is not set"); | ||
} | ||
sendNotification(): void { | ||
this.notify(); | ||
} | ||
|
||
async notify(message?: string) { | ||
if (message) { | ||
this.message = message; | ||
} | ||
this.validate(); | ||
const discordMessage = { | ||
content: this.message, | ||
username: "Captain Hook", | ||
}; | ||
try { | ||
await fetch(this.webhookUrl, { | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
body: JSON.stringify(discordMessage), | ||
}); | ||
console.log("Discord Notification Successfully Sent..."); | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
} | ||
|
||
withMessage(message: string) { | ||
this.message = message; | ||
return this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,11 @@ | ||
import Print from "../constants/Print"; | ||
import { Notifier } from "./Notifier"; | ||
|
||
export class SlackNotifier extends Notifier { | ||
private message: string = ""; | ||
|
||
constructor(private readonly webhookUrl: string) { | ||
super(); | ||
this.webhookUrl = webhookUrl; | ||
constructor(webhookUrl: string, message: string) { | ||
super(webhookUrl, message); | ||
} | ||
|
||
validate() { | ||
if (!this.webhookUrl) { | ||
Print.error("SLACK_WEBHOOK_URL is not set"); | ||
throw new Error("SLACK_WEBHOOK_URL is not set"); | ||
} | ||
sendNotification(): void { | ||
this.notify(); | ||
} | ||
|
||
async notify(message?: string) { | ||
if (message) { | ||
this.message = message; | ||
} | ||
this.validate(); | ||
const slackMessage = { | ||
text: `AutoBackup🤖: ${this.message}`, | ||
}; | ||
try { | ||
await fetch(this.webhookUrl, { | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
body: JSON.stringify(slackMessage), | ||
}); | ||
console.log("Slack Notification Successfully Sent..."); | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
} | ||
|
||
withMessage(message: string) { | ||
this.message = message; | ||
return this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.