Skip to content

Commit ecfeb9a

Browse files
author
hungtu
committed
aichaos#92 Add special handling for [*]
1 parent 6b5ef3f commit ecfeb9a

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

rivescript/sorting.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ def __init__(self, pattern, index, weight, inherit = sys.maxsize):
5656
# Without any words number of stars does not matter, they all mean match any.
5757
self.star = sys.maxsize # Make sure "*" is last in the list, "* love *" > "*"
5858

59+
# Special handle for the case "[*]", since self.len is not re-set, self.len = -2 < 0. Thus, "[*]" > "*"
60+
elif (self.option == 1) & (self.wordcount == -2):
61+
self.wordcount = sys.maxsize
62+
self.star = sys.maxsize
63+
self.pound = sys.maxsize
64+
self.under = sys.maxsize
65+
self.option = sys.maxsize
5966

6067
def sort_trigger_set(triggers, exclude_previous=True, say=None):
6168
"""Sort a group of triggers in optimal sorting order.

0 commit comments

Comments
 (0)