poshbotio / PoshBot

Powershell-based bot framework
MIT License
536 stars 108 forks source link

Feature Request: remove trailing space when parsing command #164

Closed delrio1110 closed 5 years ago

delrio1110 commented 5 years ago

Ive added suggested actions to the Teams bot but when you select the action, it adds a SPACE at the end. This space is fine if Im going to add a param after it but not good if its a single command like Status. could you point me in the right direction to add TrimEnd()

Expected Behavior

image

I selected the action STATUS and hit ENTER. Result would be the status of the bot.

Current Behavior

I selected the action STATUS and hit ENTER. No command found matching [status??]

Possible Solution

add TrimEnd()

devblackops commented 5 years ago

Gotta loves Teams 😄

It looks like when a space is at the end of the message, Teams replaces that with ??. You can see this with debug logging turned on and looking at the raw messages returned from the backend.

{
    "DataTime": "2019-03-24 20:37:53Z",
    "Class": "TeamsBackend",
    "Method": "ReceiveMessage",
    "Severity": "Normal",
    "LogLevel": "Debug",
    "Message": "Raw message",
    "Data": {
        "text": "!about??",
        "textFormat": "plain",
        "type": "message",
        "timestamp": "2019-03-24T20:37:52.907Z",
        "localTimestamp": "2019-03-24T13:37:52.907-07:00",
    }
}

We are already trimming the message text in the command parser here but we don't receive spaces at the end in Teams, but ??.

We can probably take care of this edge case in the Teams backend and look for message text with ?? at the end and remove it.

https://github.com/poshbotio/PoshBot/blob/master/PoshBot/Implementations/Teams/TeamsBackend.ps1#L78

delrio1110 commented 5 years ago

Thank you @devblackops pointing me in the correct direction. I was able to fix it with a simple Replace('\?\?$','') and now my suggested actions are working nicely!!

delrio1110 commented 5 years ago

Thank you for fixing this