PoshBot 是一个采用 MIT 许可证的开源项目。持续的开发得益于赞助商的支持。如果您想成为赞助商,可以通过 GitHub Sponsors 或 Patreon 进行赞助。
想要深入了解?请查阅 Leanpub 上的 ChatOps the Easy Way!
PoshBot 是一个用 PowerShell 编写的聊天机器人。它广泛使用了 PowerShell 5.0 引入的类。PowerShell 模块被加载到 PoshBot 中,并立即作为机器人命令可用。PoshBot 目前支持连接到 Slack,为您提供出色的 ChatOps 体验。
几乎任何您想做的事 :) 说真的。PoshBot 执行 PowerShell 模块中的函数或 cmdlet。使用 PoshBot 连接服务器并报告状态、部署代码、执行运行手册、查询 API 等。只要您能用 PowerShell 编写,PoshBot 就能执行。
详细文档可在 ReadTheDocs 上找到。
请参阅 构建 PoshBot 了解如何从源代码构建 PoshBot。
每个版本的详细变更记录在 发行说明 中。
要立即开始,请为您的机器人获取一个 Slack API 令牌:
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