ddns and discord on windows now support being quieter with -quiet switch.
This commit is contained in:
+6
-2
@@ -31,7 +31,8 @@ param (
|
|||||||
[string] $webhook = "",
|
[string] $webhook = "",
|
||||||
[string] $botName = "",
|
[string] $botName = "",
|
||||||
[string] $color = "",
|
[string] $color = "",
|
||||||
[string] $title = ""
|
[string] $title = "",
|
||||||
|
[switch] $quiet
|
||||||
)
|
)
|
||||||
begin {
|
begin {
|
||||||
$chunk = ""
|
$chunk = ""
|
||||||
@@ -56,7 +57,7 @@ begin {
|
|||||||
process {
|
process {
|
||||||
# build up the full message
|
# build up the full message
|
||||||
foreach ($line in $message) {
|
foreach ($line in $message) {
|
||||||
if ($chunk.length + $line.length -gt 1800) {
|
if ($chunk.length + $line.length -gt 3600) {
|
||||||
# if adding the line will make it too long, queue existing chunk and reset
|
# if adding the line will make it too long, queue existing chunk and reset
|
||||||
$chunks += $chunk
|
$chunks += $chunk
|
||||||
$chunk = ""
|
$chunk = ""
|
||||||
@@ -94,8 +95,11 @@ end {
|
|||||||
if (($oldMessage -join "`n") -ne ($message -join "`n")) {
|
if (($oldMessage -join "`n") -ne ($message -join "`n")) {
|
||||||
# finally send each chunk of the message
|
# finally send each chunk of the message
|
||||||
foreach ($chunk in $chunks) {
|
foreach ($chunk in $chunks) {
|
||||||
|
# if quiet flag given, and trimmed content is empty then skip, (normally) otherwise send message
|
||||||
|
if ($chunk.trim() || ! $quiet) {
|
||||||
SendDiscordMessage -message $chunk -webhook $webhook -botName $botName -title $title -color $colorNumber
|
SendDiscordMessage -message $chunk -webhook $webhook -botName $botName -title $title -color $colorNumber
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# if distinct, store the updated message for future checking
|
# if distinct, store the updated message for future checking
|
||||||
if ($distinct) {
|
if ($distinct) {
|
||||||
|
|||||||
@@ -47,7 +47,8 @@ param(
|
|||||||
[string] $netmask = "128",
|
[string] $netmask = "128",
|
||||||
[object] $logFile = "$env:USERPROFILE\\.dynv6.log",
|
[object] $logFile = "$env:USERPROFILE\\.dynv6.log",
|
||||||
[string] $ipv4 = "",
|
[string] $ipv4 = "",
|
||||||
[string] $ipv6 = ""
|
[string] $ipv6 = "",
|
||||||
|
[switch] $quiet
|
||||||
)
|
)
|
||||||
|
|
||||||
# load in defaults from config
|
# load in defaults from config
|
||||||
@@ -100,7 +101,9 @@ $ipv6 = "$ipv6/$netmask"
|
|||||||
|
|
||||||
# update IPv4, if changed
|
# update IPv4, if changed
|
||||||
if ($old4 -eq $ipv4) {
|
if ($old4 -eq $ipv4) {
|
||||||
|
if ( ! $quiet) {
|
||||||
$events += "IPv4 address unchanged"
|
$events += "IPv4 address unchanged"
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
# send IPv4 address to dynv6
|
# send IPv4 address to dynv6
|
||||||
$body = @{
|
$body = @{
|
||||||
@@ -117,7 +120,9 @@ if ($old4 -eq $ipv4) {
|
|||||||
|
|
||||||
# update IPv6, if changed
|
# update IPv6, if changed
|
||||||
if ($old6 -eq $ipv6) {
|
if ($old6 -eq $ipv6) {
|
||||||
|
if ( ! $quiet) {
|
||||||
$events += "IPv6 address unchanged"
|
$events += "IPv6 address unchanged"
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
# send IPv6 address to dynv6
|
# send IPv6 address to dynv6
|
||||||
$body = @{
|
$body = @{
|
||||||
@@ -135,5 +140,6 @@ if ($old6 -eq $ipv6) {
|
|||||||
if ($logFile) {
|
if ($logFile) {
|
||||||
Out-File -FilePath $logFile -Append -InputObject ($events -join "`n")
|
Out-File -FilePath $logFile -Append -InputObject ($events -join "`n")
|
||||||
}
|
}
|
||||||
echo ($events -join "`n")
|
if ($events.count -gt 0) {
|
||||||
|
echo ($events -join "`n")
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user