
Framework de bots baseado em PowerShell
PoshBot é um projeto open source licenciado sob MIT. O desenvolvimento contínuo é possível graças ao apoio dos patrocinadores. Se você gostaria de se tornar um patrocinador, pode fazê-lo através do GitHub Sponsors ou Patreon.
Quer alguns guias aprofundados? Confira ChatOps the Easy Way no Leanpub!
PoshBot é um chatbot escrito em PowerShell. Ele faz uso extensivo de classes introduzidas no PowerShell 5.0. Módulos do PowerShell são carregados no PoshBot e instantaneamente ficam disponíveis como comandos do bot. Atualmente, o PoshBot suporta conexão com o Slack para lhe proporcionar a incrível experiência do ChatOps.
Basicamente qualquer coisa que você quiser :) Sério. O PoshBot executa funções ou cmdlets de módulos do PowerShell. Use o PoshBot para conectar-se a servidores e relatar status, implantar código, executar runbooks, consultar APIs, etc. Se você pode escrever em PowerShell, o PoshBot pode executar.
Documentação detalhada pode ser encontrada em ReadTheDocs.
Veja Construindo o PoshBot para documentação sobre como construir o PoshBot a partir do código-fonte.
Alterações detalhadas para cada versão estão documentadas nas notas de versão.
Para começar agora, obtenha um SLACK-API-TOKEN para o seu bot:
https://my.slack.com/services/new/bot
# Install the module from PSGallery
Install-Module -Name PoshBot -Repository PSGallery
# Import the module
Import-Module -Name PoshBot
# Create a bot configuration
$botParams = @{
Name = 'name'
BotAdmins = @('<SLACK-CHAT-HANDLE>')
CommandPrefix = '!'
LogLevel = 'Info'
BackendConfiguration = @{
Name = 'SlackBackend'
Token = '<SLACK-API-TOKEN>'
}
AlternateCommandPrefixes = 'bender', 'hal'
}
$myBotConfig = New-PoshBotConfiguration @botParams
# Start a new instance of PoshBot interactively or in a job.
Start-PoshBot -Configuration $myBotConfig #-AsJob
Uso básico:
# Create a Slack backend
$backendConfig = @{Name = 'SlackBackend'; Token = '<SLACK-API-TOKEN>'}
$backend = New-PoshBotSlackBackend -Configuration $backendConfig
# Create a PoshBot configuration
$pbc = New-PoshBotConfiguration -BotAdmins @('<MY-SLACK-HANDLE>') -BackendConfiguration $backendConfig
# Save configuration
Save-PoshBotConfiguration -InputObject $pbc -Path .\PoshBotConfig.psd1
# Load configuration
$pbc = Get-PoshBotConfiguration -Path .\PoshBotConfig.psd1
# Create an instance of the bot
$bot = New-PoshBotInstance -Configuration $pbc -Backend $backend
# Start the bot
$bot.Start()
# Available commands
Get-Command -Module PoshBot
CommandType Name Version Source
----------- ---- ------- ------
Function Get-PoshBot 0.12.0 poshbot
Function Get-PoshBotConfiguration 0.12.0 poshbot
Function Get-PoshBotStatefulData 0.12.0 poshbot
Function New-PoshBotCardResponse 0.12.0 poshbot
Function New-PoshBotConfiguration 0.12.0 poshbot
Function New-PoshBotDiscordBackend 0.12.0 poshbot
Function New-PoshBotFileUpload 0.12.0 poshbot
Function New-PoshBotInstance 0.12.0 poshbot
Function New-PoshBotMiddlewareHook 0.12.0 poshbot
Function New-PoshBotScheduledTask 0.12.0 poshbot
Function New-PoshBotSlackBackend 0.12.0 poshbot
Function New-PoshBotTeamsBackend 0.12.0 poshbot
Function New-PoshBotTextResponse 0.12.0 poshbot
Function Remove-PoshBotStatefulData 0.12.0 poshbot
Function Save-PoshBotConfiguration 0.12.0 poshbot
Function Set-PoshBotStatefulData 0.12.0 poshbot
Function Start-PoshBot 0.12.0 poshbot
Function Stop-Poshbot 0.12.0 poshbot