Skip to content

Commit

Permalink
Merge pull request #105 from ChrisLGardner/add-backend-context
Browse files Browse the repository at this point in the history
Pass the backend type into a Command -fixes #104
  • Loading branch information
devblackops authored Sep 8, 2018
2 parents 6421ce1 + b41e395 commit 8c1f44d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion PoshBot/Classes/Command.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class Command : BaseLogger {
# }

# Execute the command in a PowerShell job and return the running job
[object]Invoke([ParsedCommand]$ParsedCommand, [bool]$InvokeAsJob = $this.AsJob) {
[object]Invoke([ParsedCommand]$ParsedCommand, [bool]$InvokeAsJob = $this.AsJob, [string]$Backend) {

$outer = {
[cmdletbinding()]
Expand All @@ -96,6 +96,7 @@ class Command : BaseLogger {
ConfigurationDirectory = $options.ConfigurationDirectory
ParsedCommand = $options.ParsedCommand | Select-Object -ExcludeProperty $parsedCommandExcludes
OriginalMessage = $options.OriginalMessage
BackendType = $options.BackendType
}

& $cmd @namedParameters @positionalParameters
Expand All @@ -108,6 +109,7 @@ class Command : BaseLogger {
CallingUserInfo = $ParsedCommand.CallingUserInfo
OriginalMessage = $ParsedCommand.OriginalMessage.ToHash()
ConfigurationDirectory = $script:ConfigurationDirectory
BackendType = $Backend
}
if ($this.FunctionInfo) {
$options.Function = $this.FunctionInfo
Expand Down
4 changes: 2 additions & 2 deletions PoshBot/Classes/CommandExecutor.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +103,15 @@ class CommandExecutor : BaseLogger {

# Kick off job and add to job tracker
$cmdExecContext.IsJob = $true
$cmdExecContext.Job = $cmdExecContext.Command.Invoke($cmdExecContext.ParsedCommand, $true)
$cmdExecContext.Job = $cmdExecContext.Command.Invoke($cmdExecContext.ParsedCommand, $true,$this._bot.Backend.GetType().Name)
$this.LogDebug("Command [$($cmdExecContext.FullyQualifiedCommandName)] executing in job [$($cmdExecContext.Job.Id)]")
$cmdExecContext.Complete = $false
} else {
# Run command in current session and get results
# This should only be 'builtin' commands
try {
$cmdExecContext.IsJob = $false
$hash = $cmdExecContext.Command.Invoke($cmdExecContext.ParsedCommand, $false)
$hash = $cmdExecContext.Command.Invoke($cmdExecContext.ParsedCommand, $false,$this._bot.Backend.GetType().Name)
$cmdExecContext.Complete = $true
$cmdExecContext.Ended = (Get-Date).ToUniversalTime()
$cmdExecContext.Result.Errors = $hash.Error
Expand Down

0 comments on commit 8c1f44d

Please sign in to comment.