
Framework de bots basado en PowerShell
PoshBot es un proyecto de código abierto con licencia MIT. El desarrollo continuo es posible gracias al apoyo de los patrocinadores. Si deseas convertirte en patrocinador, puedes hacerlo a través de GitHub Sponsors o Patreon.
¿Quieres guías detalladas? ¡Echa un vistazo a ChatOps the Easy Way en Leanpub!
PoshBot es un bot de chat escrito en PowerShell. Hace un uso extensivo de las clases introducidas en PowerShell 5.0. Los módulos de PowerShell se cargan en PoshBot y están disponibles instantáneamente como comandos del bot. Actualmente, PoshBot es compatible con Slack para ofrecerte una increíble funcionalidad de ChatOps.
Prácticamente cualquier cosa que quieras :) No, en serio. PoshBot ejecuta funciones o cmdlets de módulos de PowerShell. Usa PoshBot para conectarte a servidores e informar su estado, desplegar código, ejecutar runbooks, consultar APIs, etc. Si puedes escribirlo en PowerShell, PoshBot puede ejecutarlo.
La documentación detallada está disponible en ReadTheDocs.
Consulta Compilando PoshBot para obtener documentación sobre cómo compilar PoshBot desde el código fuente.
Los cambios detallados de cada versión se documentan en las notas de la versión.
Para empezar ahora, obtén un SLACK-API-TOKEN para tu 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