Closed AndrewPla closed 4 years ago
This may seem somewhat dirty, but adding an additional $Message = $this.TrimPrefix($Message)
fixes the issue. trimprefix will remove the /r/n from the message, but it won't remove '/r/n' AND '!' if it's only called once. This is what I have as of right now and it is working.
if (-not $isBotCommand) {
$cmdSearch = $false
$this.LogDebug('Message is not a bot command. Command triggers WILL NOT be searched.')
} else {
# The message is intended to be a bot command
$this.LogDebug('Message before trim', $Message)
$Message = $this.TrimPrefix($Message)
$this.LogDebug('Trimmed', $Message)
$Message = $this.TrimPrefix($Message)
$this.LogDebug('Trimmed again', $Message)
}
These are the results of my logs.
Message Before Trim
"Message":"Message before trim","Data":{"Type":2,"Subtype":0,"Id":"1550606665522","Text":"\r\n!about\n",
After Being trimmed
"Message":"Trimmed","Data":{"Type":2,"Subtype":0,"Id":"1550606665522","Text":"!about"
After being trimmed twice
"Message":"Trimmed again","Data":{"Type":2,"Subtype":0,"Id":"1550606665522","Text":"about"
I will do some testing on this over the weekend to better determine what needs to be changed on trimprefix()
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I am having this same issue. If I copy and paste !help
from Teams and paste it back into Teams, I get "No command found matching [!help]" Typing the command works fine. Also, if I copy and paste from notepad or notepad++ it works properly.
@kevinblumenfeld Teams is "trying" to be helpful and automatically pasting the formatted text. The extra characters from this formatting is seen in PoshBot and prevents it from properly matching the text to a registered command. Have you tried using CTRL+SHIFT+V
to paste it unformatted?
CTRL+SHIFT-V
does work. Do we think it's possible to fix it so that's not a requirement?
I believe I have a fix for pasted messages in https://github.com/poshbotio/PoshBot/commit/016120a92d7f3e358fa68bea0d1b3468f660afdc but could use some folks who Teams to test it. Can you pull down the latest from master, build it with ./build.ps1 -task build
and test it out?
@devblackops :boom: looks like it works now.
I wasn't smart enough to figure out how to install the 0.14.0
output of ./build.ps1 -task build
over my existing 0.13.0
module that was installed via Install-Module PoshBot
, so I just manually made the edits to my 0.13.0
module code and restarted PoshBot.
Thanks for testing @krknopp. Until .0.14.0
is officially released, you can adjust your script that starts PoshBot to load the version from the build output, or you can manually copy the 0.14.0
directory to C:\Users\<username>\Documents\PowerShell\Modules\PoshBot
(or wherever you have PoshBot installed).
Expected Behavior
Pasting
!help
into Teams should cause poshbot to parse the command name as help and then execute the command.Log output would look like this
Current Behavior
If you paste
!help
into a message with poshbot the command parser should parse away the leading /r/n from the message and then remove the exclamation mark in the beginningNote that there is still an exclamation mark before help in this example.
Possible Solution
Steps to Reproduce (for bugs)
Context
It seems to me like the issue is stemming from the trimprefix() method. We are calling trimprefix on an unparsed command, which would cause it to still have the leading /r/n.
This is where I'm looking (lines 331-340) of bot.ps1
Similar issue was raised in #109
Your Environment