public static IEnumerable <object[]> Interpolated_TestData() { var cqCodeMessage = SendingMessage.At(123456789); var textMessage = "hello"; var imageMessage = SendingMessage.LocalImage("/a.jpg"); var multipleSegmentMessage = SendingMessage.At(123456789) + "hello" + SendingMessage.LocalImage("/a.jpg"); { yield return(new object[] { SendingMessage.FromInterpolated($"{1}"), "1" }); yield return(new object[] { SendingMessage.FromInterpolated($"{cqCodeMessage},你好"), cqCodeMessage + ",你好" }); yield return(new object[] { SendingMessage.FromInterpolated($"{multipleSegmentMessage},你好"), multipleSegmentMessage + ",你好" }); yield return(new object[] { SendingMessage.FromInterpolated($"{cqCodeMessage}{textMessage}"), cqCodeMessage + textMessage }); yield return(new object[] { SendingMessage.FromInterpolated($"{textMessage}{cqCodeMessage},[]& {23}"), textMessage + cqCodeMessage + ",[]& " + 23.ToString() }); } }
public async Task ProcessAsync(Sisters.WudiLib.Posts.Message message, HttpApiClient api) { var osuApi = OsuApi; // 获取操作者信息。 var operatorBind = await Database.GetBindingIdAsync(_operator); if (!operatorBind.Success) { await api.SendMessageAsync(message.Endpoint, "查询数据库失败,无法记录日志。"); return; } string operatorName = (await osuApi.GetUserInfoAsync(operatorBind.Result.Value, OsuMixedApi.Mode.Standard)).Item2?.Name ?? "未知"; // 获取此用户名的相关信息。 var(networkSuccess, newUser) = await osuApi.GetUserInfoAsync(_username, OsuMixedApi.Mode.Standard); if (!networkSuccess) { await api.SendMessageAsync(message.Endpoint, "网络访问失败。"); return; } ExecutingException.Cannot(newUser == null, "没有这个用户。"); // 绑定。 var oldBind = (await Database.ResetBindingAsync( qq: _qq, osuId: newUser.Id, osuName: newUser.Name, source: "由管理员修改", operatorId: _operator, operatorName: operatorName, reason: _reason )).EnsureSuccess("绑定失败,数据库访问出错。"); ExecutingException.Cannot(oldBind.Result == newUser.Id, "未更改绑定,因为已经绑定了该账号。"); SendingMessage message1 = new SendingMessage("将") + SendingMessage.At(_qq) + new SendingMessage($"绑定为{newUser.Name}。"); if (oldBind.Result == null) { await api.SendMessageAsync(message.Endpoint, message1); return; } // 获取旧的用户信息。 OsuMixedApi.UserInfo oldUser; (networkSuccess, oldUser) = await osuApi.GetUserInfoAsync(oldBind.Result.Value, OsuMixedApi.Mode.Standard); if (!networkSuccess) { message1 += new SendingMessage($"因网络问题,无法获取旧的用户名(id: {oldBind.Result.Value})。"); } else if (oldUser == null) { message1 += new SendingMessage($"以前绑定的用户已经被 Ban(id: {oldBind.Result.Value})。"); } else { message1 += new SendingMessage($"取代{oldUser.Name}({oldUser.Id})。"); } await api.SendMessageAsync(message.Endpoint, message1); }