Skip to content

Commit

Permalink
Switched to CommandParser
Browse files Browse the repository at this point in the history
Switched to using the command parser to determine if a message is a command
  • Loading branch information
AndrewPla committed Sep 13, 2018
1 parent 5eb7819 commit 485ac52
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions PoshBot/Classes/Bot.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -289,12 +289,13 @@ class Bot : BaseLogger {
# Determine if message text is addressing the bot and should be
# treated as a bot command
[bool]IsBotCommand([Message]$Message) {
$firstWord = ($Message.Text -split ' ')[0]
$parsedCommand = [CommandParser]::Parse($Message)
foreach ($prefix in $this._PossibleCommandPrefixes ) {
if ($firstWord -match "^$prefix") {
if ($parsedcommand.command -match "^$prefix") {
$this.LogDebug('Message is a bot command')
return $true
}
else { $This.LogDebug("$($parsedcommand.command) didn't match $prefix")}
}
return $false
}
Expand Down

0 comments on commit 485ac52

Please sign in to comment.