add api scripts and telegram modules

This commit is contained in:
Alex Kup 2023-11-03 16:25:24 +03:00 committed by GitHub
parent f63b143a7e
commit bcae4dfa7b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 310 additions and 0 deletions

View file

@ -0,0 +1,21 @@
function Get-Translate {
param (
$data,
$key = "KEY" # Get https://cloud.google.com/translate/docs/reference/rest
)
$url = "https://translation.googleapis.com/language/translate/v2?key=$key"
$body = @{
q = $data
target = "ru"
source = "en"
} | ConvertTo-Json
try {
$response = Invoke-RestMethod -Uri $url -Method POST -ContentType "application/json" -Body $body
$translation = $response.data.translations[0].translatedText
return $translation
} catch {
Write-Output "Error: $($_.Exception.Message)"
}
}
# Get-Translate -data "What is your name"