-
-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pass the backend type into a Command -fixes #104 #105
Pass the backend type into a Command -fixes #104 #105
Conversation
Some systems like Teams will not automatically expand some output, like image links so sending them markdown instead of a plain link will correct this to enable this behaviour we need to be able to let other plugins know which backend it is talking to. Using $Global:PoshbotContext.BackendType will enable this.
Made a quick fix to tidy up the casing on _bot and add .Name since I'd missed it from one of the Invoke calls. |
@ChrisLGardner I think this should be |
Awesome. Thanks! |
@@ -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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be $this._Bot.Backend.GetType().Name
(which will always return SlackBackend
or TeamsBackend
for the builtin backends. Relying on $this._bot.Backend.Name
will prove inconsistent because that value is settable by the user when they create an instance of a backend and can be whatever value they want. See below:
$backend = New-PoshBotSlackBackend -Configuration @{
Name = 'MyAwesomeSlackBackend'
Token = 'SUPER SECRET'
}
PoshBot/Classes/CommandExecutor.ps1
Outdated
$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.Name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same answer as above
Description
Some systems like Teams will not automatically expand some output, like image links so sending them markdown instead of a plain link will correct this to enable this behaviour we need to be able to let other plugins know which backend it is talking to. Using $Global:PoshbotContext.BackendType will enable this.
I used the name of the backend as I didn't want to pass the whole Backend in when it wasn't really needed.
Related Issue
#104
How Has This Been Tested?
Tested with the xkcd plugin and using this code. Built locally and tested with Teams. I don't have a slack workspace to test it with but I can't see why it won't work. I'll submit a PR to PoshBot.xkcd as well with this fix.
Types of changes
Checklist: