15 lines
656 B
C#
15 lines
656 B
C#
namespace WxAgent.Core;
|
|
|
|
public static class WechatTextInput
|
|
{
|
|
public static string Prepare(string text)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(text))
|
|
throw new WxAgentException(WxAgentErrorCode.InvalidArgument, "Message text must not be empty.");
|
|
var normalized = text.ReplaceLineEndings("\n");
|
|
if (normalized.Length > 4000 || normalized.Any(character => char.IsControl(character) && character is not ('\n' or '\t')))
|
|
throw new WxAgentException(WxAgentErrorCode.InvalidArgument, "Message text must not exceed 4000 characters or contain unsupported control characters.");
|
|
return normalized;
|
|
}
|
|
}
|