Skip to content

Commit

Permalink
Fixed too aggressive regex interpolation
Browse files Browse the repository at this point in the history
  • Loading branch information
CWolfs committed Oct 11, 2022
1 parent 9ef8c30 commit 89bf912
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/Core/ConversationInterpolator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ public ConversationInterpolator() {
public string Interpolate(string text) {
// Main.Logger.Log($"[InterpolateStats] text '{text}'");

Regex regex = new Regex("\\<.*?\\>");
Regex regex = new Regex("\\<Stats.*?\\>");
MatchCollection matchCollection = regex.Matches(text);
while (matchCollection.Count > 0) {
Match match = matchCollection[0];
string value = match.Value;
string expression = null;
if (value.Length > 2) {
expression = value.Substring(1, value.Length - 2).Trim();
}
int index = match.Index;
int length = match.Length;
while (matchCollection.Count > 0) {
Match match = matchCollection[0];
string value = match.Value;
string expression = null;
if (value.Length > 2) {
expression = value.Substring(1, value.Length - 2).Trim();
}
int index = match.Index;
int length = match.Length;

string[] lookups = expression.Split('.');
string actionType = lookups[0].ToLower();
Expand Down Expand Up @@ -69,7 +69,7 @@ private string InterpolateStats(string text, string[] lookups) {
} else {
Main.Logger.LogError($"[InterpolateStats] Stat '{statName}' does not exist for stat collection '{statType}'");
return $"[InterpolateStats] Stat {statName} does not exist for stat collection {statType}";
}
}
}
}
}

0 comments on commit 89bf912

Please sign in to comment.