feat: complete M4 contact and group automation

This commit is contained in:
2026-09-04 23:01:02 +08:00
parent 5e3aa97644
commit 77e1e9dc2b
6 changed files with 1016 additions and 1 deletions
+46
View File
@@ -0,0 +1,46 @@
namespace WxAgent.Core;
public sealed record WechatContactSnapshot(
string DisplayName,
string? WechatId = null,
IReadOnlyList<string>? Tags = null,
string? Signature = null,
string? Source = null,
int? CommonGroupCount = null);
public sealed record WechatNewFriendSnapshot(string DisplayName, string Status);
public sealed record WechatGroupMemberSnapshot(string DisplayName, string? GroupNickname = null, bool IsOwner = false);
public sealed record WechatSubWindowSnapshot(string Title, string Kind, int ProcessId);
public sealed record WechatAccountSnapshot(string DisplayName, string? WechatId = null, string? Region = null);
public sealed record WechatOperationResult(bool Success, WxAgentErrorCode? Code, string Message)
{
public static WechatOperationResult Ok(string message = "ok") => new(true, null, message);
}
public static class WechatOperationPolicy
{
public const string Confirmation = "CONFIRM";
public static void RequireConfirmation(string? confirmation, string operation)
{
if (!string.Equals(confirmation, Confirmation, StringComparison.Ordinal))
{
throw new WxAgentException(
WxAgentErrorCode.InvalidArgument,
$"{operation} requires explicit confirmation '{Confirmation}'.");
}
}
public static void ValidateNames(IEnumerable<string> names, string parameterName)
{
ArgumentNullException.ThrowIfNull(names);
if (!names.Any() || names.Any(string.IsNullOrWhiteSpace))
{
throw new WxAgentException(WxAgentErrorCode.InvalidArgument, $"{parameterName} must contain at least one non-empty name.");
}
}
}