mirror of
https://github.com/maubot/maubot
synced 2025-09-04 12:50:38 +00:00
Fix active command matching
This commit is contained in:
parent
b805641ea4
commit
f06c6dd767
3 changed files with 7 additions and 3 deletions
|
@ -43,6 +43,7 @@ func (pc *ParsedCommand) parseCommandSyntax(command maubot.Command) error {
|
|||
argumentEncountered := false
|
||||
|
||||
regexBuilder.WriteString("^!")
|
||||
swBuilder.WriteRune('!')
|
||||
words := strings.Split(command.Syntax, " ")
|
||||
for i, word := range words {
|
||||
argument, ok := command.Arguments[word]
|
||||
|
@ -50,8 +51,10 @@ func (pc *ParsedCommand) parseCommandSyntax(command maubot.Command) error {
|
|||
if ok && len(word) > 0 /*&& word[0] == '$'*/ {
|
||||
argumentEncountered = true
|
||||
regex := argument.Matches
|
||||
if argument.Required {
|
||||
if !argument.Required {
|
||||
regex = fmt.Sprintf("(?:%s)?", regex)
|
||||
} else {
|
||||
regex = fmt.Sprintf("(%s)", regex)
|
||||
}
|
||||
pc.Arguments = append(pc.Arguments, word)
|
||||
regexBuilder.WriteString(regex)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue