poshbotio / PoshBot

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

CommandPrefix = '.' causes bot to respond to all messages #124

Closed ThePoShWolf closed 5 years ago

ThePoShWolf commented 5 years ago

When CommandPrefix is set to '.', it causes the bot to respond to all messages with:

No command found matching [typed message]

Commands prefixed with a period still work though.

Expected Behavior

What should happen is the bot should not respond to any messages except for commands prefixed with a period.

Current Behavior

Currently when CommandPrefix is set to '.' the bot responds to all messages with:

No command found matching [typed message]

Possible Solution

No idea. You mentioned you think that some where

"some message" -match '.'

Is evaluating to $true.

Steps to Reproduce (for bugs)

Here's my bot config:

$botParams = @{
    name = 'snipperbot'
    BotAdmins = @('anthony')
    CommandPrefix = '.'
    LogLevel = 'Verbose'
    PluginDirectory = 'C:\PoshBot\Plugins'
    BackendConfiguration = @{
        Name = 'SlackBackend'
        token = '<removed for privacy>'
    }
}
$botConfig = New-PoshBotConfiguration @botParams

Context

I was simply trying to use a period as the command prefix. Less of a stretch than an exclamation point.

Your Environment

ThePoShWolf commented 5 years ago

Also switching the CommandPrefix to '!' completely resolves the issue.

ChrisLGardner commented 5 years ago

The mention that "some command" -match "." would always evaluate to true. I think the solution there is to wrap that in a [regex]::escape() and it should handle using . or * or other regex characters as the bot command character.


From: Anthony Howell notifications@github.com Sent: Wednesday, October 10, 2018 11:44:34 PM To: poshbotio/PoshBot Cc: Subscribed Subject: Re: [poshbotio/PoshBot] CommandPrefix = '.' causes bot to respond to all messages (#124)

Also switching the CommandPrefix to '!' completely resolves the issue.

ā€” You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/poshbotio/PoshBot/issues/124#issuecomment-428758498, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AQDqFqakTC66di1S-icUHJGD7PSAeiQEks5ujnhSgaJpZM4XWd2e.

devblackops commented 5 years ago

Thanks for catching this @ThePoShWolf! Thanks for the suggestion @ChrisLGardner! Thanks for fixing it @Windos! šŸ‘ šŸ‘ šŸ‘

ThePoShWolf commented 5 years ago

Oh yeah, just me being lazy and not wanting to reach all the way for the !.