BOTtum 1.0.5

A PowerShell 7 module implementing the following KeyBase functionality.

  1. KeyBase BOT for performing CRUD operations on the KeyBase KVstore.

    See the BOT in action.

  2. KeyBase FileSystem Explorer for displaying folders and files.

    See the KB Explorer in action.



The BOTtum module consists of 3 cmdlets called, Connect-BOTtumKB, Set-BOTtumConfiguration, and Show-KBMessages that implement BOT functionality.

The 4 cmdlets, Get-KBCapacity, Show-KBCapacity, Get-KBFileSystem, and Show-KBFileSystem implement the KeyBase FileSystem Explorer.



This module can be installed by downloading the installation script Install BOTtum or by following the instructions below.

This module requires the installation of the PoshRSJob module.

Install-Module PoshRSJob

Another requirement of this module is that the KeyBase client be actively running. As of version 1.0.5, this module is working on both Windows and Linux.

Installation of BOTtum

Join the KeyBase BOTtum team

Download the BOTtum module

git clone keybase://team/bottum/bottum

The environmental variable '$env:PSModulePath' controls where the server will look for PowerShell modules. My recommendation is to create new folder for your personal PowerShell modules and update the PSModulePath variable to include a reference this new folder.

Copy the folder created by 'git clone' to a folder location referenced in $env:PSModulePath. At a minimum the folder should have the follow files and structure where 'local' is a folder.

BOTtum
  Local
  BOTtum.psd1
  BOTtum.psm1
  BOTtum-cfg.xml

To verify that PowerShell 7 has recognized this module, start a NEW PowerShell console session and enter the following command.

Get-Command -module BOTtum.

This should produce the following output.

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Function        Connect-BOTtumKB                                   1.0.5      BOTtum
Function        Get-KBCapacity                                     1.0.5      BOTtum
Function        Get-KBFileSystem                                   1.0.5      BOTtum
Function        Set-BOTtumConfiguration                            1.0.5      BOTtum
Function        Show-KBCapacity                                    1.0.5      BOTtum
Function        Show-KBFileSystem                                  1.0.5      BOTtum
Function        Show-KBMessages                                    1.0.5      BOTtum

The final step is to set the configuraton for your environment by executing.

Set-BOTtumConfiguration

This command will update the file, BOTtum-cfg.xml located in the module root folder.

variable Example Description
PathToMonitor C:\bin\ps Temporary files are created in this folder
FileToMonior KBinput.Json Input messages received from the KeyBase client
LogFile BOTtum.log Log record written into this file
KEYBASE_BIN C:\Users<username>\AppData\Local\Keybase\KeyBase.exe
KEYBASE_BOT dad,mom Comma separated list of chat members to respond to.
KEYBASE_CHL team1,team2 Comma separated list of teams to respond to.
KEYBASE_NS optional Default namespace value to use.

The KEYBASE_BOT and KEYBASE_CHL variables control to whom the BOT will respond to. If no values are specified, then no responses will be generated.



KeyBase FileSystem Explorer

KB Explorer

Executing the cmdlet, Show-KBFileSystem will display a Grid View table showing the folders and files within the specified KeyBase filesystem.

The title line displays the current path being referenced along with the available capacity in the KeyBase filesystem.

The Filter box is used for filtering the displayed content.

To navigate through the KeyBase directory structure, select a DIR record by using the arrow keys and the space bar. When the value return appears in the list, it can be selected to return to the parent folder. After making a selected, press the enter key.

When a file is selected, the options to 'Copy, Remove, View, Run, or Execute' will be presented. The Run option is currently only available when selecting a PowerShell script file with an '.ps1' extension.


KeyBase fs cmdlets

cmdlet Description
Show-KBFileSystem Displays folders and files in a Grid View
Get-KBCapacity returns available capacity in the Keybase filesystem
Show-KBCapacity Outputs KeyBase filesytem capacity metrics
Get-KBFileSystem returns an object containing folders and files


Starting BOT in the console

Connect-BOTkumKB

BOTtum listener is started and a message handler process is started in a separate multi-threaded runspace. BOTtum should be able to respond to a fairly high volume of messages.

The command will block the current PowerShell session. To quit the process, enter ctrl-C.

Running BOTtum as a Windows Service

This procedure does establish the Windows service, BOTtum but the cmdlet, Connect-BOTtumKB is NOT functioning properly when configured as a service. Also, this procedure will generally work for running any PowerShell code as a Windows Service.

Download and install Non-Sucking Service Manager

Update the system environmental variable Path to include the path to the nssm.exe location.

Must be in Administrator mode to install a Windows Service

$nssm = (Get-Command nssm).Source
$serviceName = 'BOTtum'
$pwsh7 = (Get-Command pwsh).Source
$scriptPath = 'C:\CoreModules\BOTtum\local\BOTtum-Service.ps1'
$arguments = '-ExecutionPolicy Bypass -NoProfile -File "{0}"' -f $scriptPath

& $nssm install $serviceName $pwsh7 $arguments
& $nssm status $serviceName

Start-Service $serviceName
Get-Service $serviceName

Run services.msc to verify that the BOTtum service is listed and running.


KVstore commands

The scope of the commands is limited to the chat or team session from where the commands is executed.

Syntax Description
.KVgetKeys Lists the keys in the default namespace
.KVgetKeys [namespace] Lists the keys for the specified namespace
.KVnameSpaces Lists the namespaces for the chat or team session
.KVgetValue [key] Returns the value of the key in the default namespace
.KVgetValue [key] [namespace] Returns the value of the key in the specified namespace
.KVsetValue [key] [value] Creates or updates the key/value in the default namespace
.KVsetValue [key] [value] [namespace] Creates or updates the key/value for the specifed namespace
.KVremoveKey [key] Removes the key from the default namespace
.KVremoveKey [key] [namespace] Removes the key from the specified namespace