$TOKEN = "СТЕРЕТЬ_И_ВСТАВИТЬ_ТОКЕН"
# Сама программа:
Write-Host "Бот работает! Напишите ему в Telegram команду /play" -ForegroundColor Green
$offset = 0
while ($true) {
try {
$url = "https://telegram.org"
$res = Invoke-RestMethod -Uri $url -Method Get -TimeoutSec 10
foreach ($up in $res.result) {
$offset = $up.update_id + 1
if ($up.message.text -eq "/play") {
# Включаем громкость на 100%
$wsh = New-Object -ComObject WScript.Shell
for ($i=0; $i -le 50; $i++) { $wsh.SendKeys([char]175) }
# Запускаем звук
$player = New-Object System.Media.SoundPlayer
$player.SoundLocation = "C:\bot\sound.wav"
$player.Play()
# Отвечаем в Телеграм
$send = "https://telegram.org! Звук включен."
Invoke-RestMethod -Uri $send -Method Get
}
}
} catch { Start-Sleep -Seconds 1 }
}