Telegram bot adaptation for PowerShell from c# powershell bot. Tested on powershell 4 and 5.
This script provides useful example to learn how to use telegram windows library 'DLL' under powershell. It also pretends to give command line access to bot messaging from windows O.S. useful for automation, alerts and scheduling.
C# library to talk to Telegrams Bot API (https://core.telegram.org/bots/api)
Make sure the requiered libraries are located at .\files
.\powerTelegram.ps1 -token "----your token----"
$fixedBotKey = "----your token----"
$message = "Wow, it's working !"
$targetUserId = 123456
$bot = New-Object NetTelegramBotApi.TelegramBot($fixedBotKey)
$getMe = New-Object NetTelegramBotApi.Requests.GetMe
$me = $bot.MakeRequestAsync($getMe).Result
if ($me -eq $null)
{
exit
}
$reqAction = New-Object NetTelegramBotApi.Requests.SendMessage($targetUserId, $message);
$bot.MakeRequestAsync($reqAction).Wait();
Updated to Bot API 2.1