PoshBot
v0.13.0
Azure管道 | GitHub 操作 | 文档 | PS画廊 | 执照 |
---|---|---|---|---|
PoshBot 是一个 MIT 许可的开源项目。由于赞助商的支持,持续的发展成为可能。如果您想成为赞助商,可以通过 GitHub Sponsors 或 Patreon 来实现。
想要一些深入的指南吗?在 Leanpub 上查看 ChatOps the Easy Way!
PoshBot 是一个用 PowerShell 编写的聊天机器人。它广泛使用了 PowerShell 5.0 中引入的类。 PowerShell 模块加载到 PoshBot 中并立即可用作机器人命令。 PoshBot 目前支持连接到 Slack,为您提供出色的 ChatOps 功能。
几乎任何你想要的:) 不认真的。 PoshBot 从 PowerShell 模块执行函数或 cmdlet。使用 PoshBot 连接到服务器并报告状态、部署代码、执行 Runbook、查询 API 等。如果您可以在 PowerShell 中编写它,PoshBot 就可以执行它。
详细文档可以在 ReadTheDocs 中找到。
有关如何从源代码构建 PoshBot 的文档,请参阅构建 PoshBot。
每个版本的详细更改都记录在发行说明中。
要立即开始,请为您的机器人获取 SLACK-API-TOKEN:
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
基本用法:
# 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