/// <summary> /// 获取 <see cref="Messaging.Mention"/> 实例的目标。 /// </summary> /// <param name="mention">要操作的 <see cref="Messaging.Mention"/> 实例。</param> /// <param name="context">要使用的 <see cref="PluginContext"/>。</param> public static IUser GetTarget(this Mention mention, PluginContext context) { if (mention is null) { throw new ArgumentNullException(nameof(mention)); } if (context is null) { throw new ArgumentNullException(nameof(context)); } return(context.GetUser(mention.TargetNumber)); }
/// <summary> /// 设置 <see cref="Messaging.Mention"/> 实例的目标。 /// </summary> /// <param name="mention">要操作的 <see cref="Messaging.Mention"/> 实例。</param> /// <param name="target"><see cref="Messaging.Mention"/> 实例的目标。</param> public static Mention SetTarget(this Mention mention, IUser target) { if (mention is null) { throw new ArgumentNullException(nameof(mention)); } if (target is null) { throw new ArgumentNullException(nameof(target)); } mention.TargetNumber = target.Number; return(mention); }
/// <summary> /// 使用 <see cref="PluginContext.Current"/> 获取 <see cref="Messaging.Mention"/> 实例的目标。 /// </summary> /// <param name="mention">要操作的 <see cref="Messaging.Mention"/> 实例。</param> public static IUser GetTarget(this Mention mention) => GetTarget(mention, PluginContext.Current);