Comments (4)
Sweet. Good luck with it. Btw, is there any security around who can post to your Slack URL?
No, there is no security. You just have to know the unique URL.
from plexbackup.
I do not have time to look into this now, so wouldn't promise anything, but if you are willing to make a change, you can obviously clone the code and do whatever you like, but this will involve a lot of changes: (a) the SendMail
method (to use Slack instead of email), (b) the logic that deals with mail properties (SMTP server, credentials, etc), (c) possibly the FormatEmail
method (I suspect there is a way to pass HTML message to Slack, but I do not know). You will also need a couple of new properties for Slack settings and to indicate which notification provider to use. And the logic that validates all inputs before executing the main operation. Off the top of my head, I'd say it may be nice to have but given the amount of changes, that need to be implemented, I'd skip it.
from plexbackup.
Thanks. I don't have much experience with PowerShell, but I'll see about using what already exists as a starting point. I have a good start by duplicating the FormatEmail
method.
#--------------------------------------------------------------------------
# SlackMessage
# Generates the body of the Slack message.
function SlackMessage {
[CmdletBinding()]
param (
)
WriteDebug "Entered SlackMessage."
[string]$backupMode = $null
[string]$dataDirPath = $null
if ($Script:Type) {
$backupMode = $Script:Mode + " -" + $Type
}
else {
$backupMode = $Script:Mode
}
if ($Script:Test) {
$backupMode += " (Test)"
}
$dataDirPath = $Script:BackupDir | ConvertTo-Json
$body = '*PlexBackup.ps1* completed the `' + $backupMode + '` operation on *PlexServer* (Plex version: ' + $Script:PlexVersion + '). Backup started at *' + $Script:StartTime + '* and ended at *' + $Script:EndTime + '* (total of *' + $Script:Duration + '*). Backup folder `' + $dataDirPath.Replace("`"","") + '` contains *' + $Script:ObjectCount + '* objects and *' + $Script:BackupSize + '* GB of data.'
WriteDebug "Exiting SlackMessage."
return $body
}
I'm then hijacking SendMail
right now to send the notification.
$slackHeaderSuccess = "\u2705 Success"
$slackHeaderError = "\uD83D\uDC4E Failed"
if ($Script:ErrorResult) {
$slackHeader = $slackHeaderError
}
else {
$slackHeader = $slackHeaderSuccess
}
$messageSlack = SlackMessage
$bodySlack = @"
{
"text": "$slackHeader - $messageSlack",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "$slackHeader",
"emoji": true
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "$messageSlack"
}
}
]
}
"@
$uriSlack = "https://hooks.slack.com/services/<my-unique-url>"
Invoke-RestMethod -uri $uriSlack -Method Post -body $bodySlack -ContentType 'application/json'
Obviously this needs a lot of work, but as an initial proof of concept, this appears to be a possibility.
from plexbackup.
Sweet. Good luck with it. Btw, is there any security around who can post to your Slack URL?
from plexbackup.
Related Issues (20)
- issue with backup HOT 5
- Cannot import run-time settings from default configuration file (if any). Invalid JSON primitive: Skip. HOT 1
- Validation error. Backup version does not match HOT 3
- Can't start Plex after backup HOT 6
- After backup completes getting an error when the script attempts to start Plex HOT 3
- Plex Media Server Not Restarting HOT 1
- Email Notification Not Working HOT 2
- Plex Backup Failing-Nothing Changed HOT 16
- question/enhancement HOT 4
- Only receiving the error "Error processing dependencies. You cannot call a method on a null-valued expression." HOT 6
- Fix typo in log message HOT 1
- Add support for PowerShell 7.
- RUNAS ERROR: Unable to run ... 87: The parameter is incorrect. HOT 2
- Plex Backup Fails Through Task Scheduler (Win 10 Pro) HOT 2
- 87: The parameter is incorrect HOT 13
- Create a workaround for the error 87: The parameter is incorrect HOT 1
- Restore didn
- Restore didn't work too well for me HOT 16
- Sub folders not being created by backup process HOT 5
- Add the option to exclude Cache folder HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from plexbackup.