Fixes Chinese regex

This worked on local testing, but if someone could verify my changes, that'd be ideal!
This commit is contained in:
Robert Baker 2021-09-30 00:10:43 -07:00
parent a0403fdbbe
commit fd83590526

View file

@ -24,7 +24,7 @@ namespace Dalamud.Game.Command
private readonly Regex commandRegexJp = new(@"^そのコマンドはありません。: (?<command>.+)$", RegexOptions.Compiled);
private readonly Regex commandRegexDe = new(@"^„(?<command>.+)“ existiert nicht als Textkommando\.$", RegexOptions.Compiled);
private readonly Regex commandRegexFr = new(@"^La commande texte “(?<command>.+)” n'existe pas\.$", RegexOptions.Compiled);
private readonly Regex commandRegexCn = new(@"^“(?<command>.+)”出现问题:该命令不存在。$", RegexOptions.Compiled);
private readonly Regex commandRegexCn = new(@"^“(?<command>.+)”出現問題:該命令不存在。$", RegexOptions.Compiled);
private readonly Regex currentLangCommandRegex;
/// <summary>
@ -40,7 +40,6 @@ namespace Dalamud.Game.Command
ClientLanguage.English => this.commandRegexEn,
ClientLanguage.German => this.commandRegexDe,
ClientLanguage.French => this.commandRegexFr,
ClientLanguage.ChineseSimplified => this.commandRegexCn,
_ => this.currentLangCommandRegex,
};
@ -161,6 +160,21 @@ namespace Dalamud.Game.Command
var command = cmdMatch.Value;
if (this.ProcessCommand(command)) isHandled = true;
}
else
{
// I tried to get the start info to determine language with an else if and it failed, so this always checks instead
// Log.Debug("Trying Chinese mod pack command parse as fallback");
// Log.Information($"Message: {message.ToString()}");
// Japanese failed. Try Chinese as a fallback.
cmdMatch = this.commandRegexCn.Match(message.TextValue).Groups["command"];
// Log.Information($"Success:{cmdMatch2.Success} Groups: {this.commandRegexCn.Match(message.TextValue).Groups.Keys.GetEnumerator().Current}\nValues:{cmdMatch2.Value}");
if (cmdMatch.Success)
{
// Yes, it's a Chinese fallback chat command.
var command = cmdMatch.Value;
if (this.ProcessCommand(command)) isHandled = true;
}
}
}
}
}