PowerShell/Scripts/repeat-last-reply.ps1

30 lines
686 B
PowerShell
Raw Normal View History

2021-12-06 18:48:32 +01:00
<#
.SYNOPSIS
Repeats the last reply
.DESCRIPTION
2022-01-30 10:49:30 +01:00
This PowerShell script repeats the last reply by text-to-speech (TTS).
2021-12-06 18:48:32 +01:00
.EXAMPLE
PS> ./repeat-last-reply
.LINK
https://github.com/fleschutz/PowerShell
2022-01-30 10:49:30 +01:00
.NOTES
2022-09-06 21:42:04 +02:00
Author: Markus Fleschutz | License: CC0
2021-12-06 18:48:32 +01:00
#>
2021-12-09 16:36:44 +01:00
function GetTempDir {
2021-12-10 11:51:51 +01:00
if ("$env:TEMP" -ne "") { return "$env:TEMP" }
if ("$env:TMP" -ne "") { return "$env:TMP" }
2021-12-09 16:36:44 +01:00
if ($IsLinux) { return "/tmp" }
2021-12-10 11:51:51 +01:00
return "C:\Temp"
2021-12-09 16:36:44 +01:00
}
if (test-path "$(GetTempDir)/last_reply_given.txt" -pathType leaf) {
2021-12-06 18:55:29 +01:00
$Reply = "It was: "
2021-12-09 16:36:44 +01:00
$Reply += Get-Content "$(GetTempDir)/last_reply_given.txt"
2021-12-06 18:48:32 +01:00
} else {
$Reply = "Sorry, I can't remember."
}
& "$PSScriptRoot/give-reply.ps1" "$Reply"
exit 0 # success