diff --git a/PoshBot/Classes/Bot.ps1 b/PoshBot/Classes/Bot.ps1 index 00115a9c..d53e9de5 100644 --- a/PoshBot/Classes/Bot.ps1 +++ b/PoshBot/Classes/Bot.ps1 @@ -291,6 +291,7 @@ class Bot : BaseLogger { [bool]IsBotCommand([Message]$Message) { $parsedCommand = [CommandParser]::Parse($Message) foreach ($prefix in $this._PossibleCommandPrefixes ) { + $prefix = [regex]::Escape($prefix) if ($parsedCommand.command -match "^$prefix") { $this.LogDebug('Message is a bot command') return $true @@ -519,7 +520,8 @@ class Bot : BaseLogger { $firstWord = ($Message.Text -split ' ')[0] foreach ($prefix in $this._PossibleCommandPrefixes) { - if ($firstWord -match "^$prefix") { + $prefixEscaped = [regex]::Escape($prefix) + if ($firstWord -match "^$prefixEscaped") { $Message.Text = $Message.Text.TrimStart($prefix).Trim() } }