public static async void GetIllustDetail(SoraMessage e, int id) { var detail = await Illust.Get(id); if (detail == null) { await e.ReplyToOriginal("数据获取失败,请稍后再试"); } else { ArrayList msg = new(); foreach (var img in detail.Images) { msg.Add(CQCode.CQImage(ImageUrls.ToPixivCat(img.Medium))); } msg.Add(new StringBuilder().AppendLine() .AppendLine(detail.Title) .AppendLine($"Author: {detail.Author}") .AppendLine(detail.Caption) .AppendLine($"Tags: {string.Join(" | ", detail.Tags)}") .AppendLine($"Publish Date: {detail.CreateDate:yyyy-MM-dd hh:mm:ss}") .AppendLine($"Bookmarks: {detail.TotalBookmarks} Comments:{detail.TotalComments} Views:{detail.TotalView}") .Append(detail.Url) .ToString()); await e.Reply(msg.ToArray()); await e.RemoveCoins(5); } }
public async Task GetIllustDetail(params int[] ids) { foreach (var id in ids) { var message = await ReplyAsync($"``数据检索中…… Pixiv ID: {id}``"); var detail = await Illust.Get(id); if (detail == null) { await message.ModifyAsync(x => x.Content = $"数据(pid:{id})获取失败,请稍后再试"); } else { var sb = new StringBuilder() .AppendLine(detail.Title) .AppendLine($"Author: {detail.Author}") .AppendLine(detail.Caption) .AppendLine($"Tags: {string.Join(" | ", detail.Tags)}") .AppendLine($"Publish Date: {detail.CreateDate:yyyy-MM-dd HH:mm:ss}") .AppendLine($"Bookmarks: {detail.TotalBookmarks} Comments:{detail.TotalComments} Views:{detail.TotalView}") .Append(detail.Url); await message.ModifyAsync(x => x.Content = sb.ToString()); await SendImage(detail); } } }
public async Task GetIllustWithNoDetail(params int[] ids) { foreach (var id in ids) { var message = await ReplyAsync($"``Pixiv ID: {id} 数据检索中……``"); var detail = await Illust.Get(id); if (detail == null) { await message.ModifyAsync(x => x.Content = $"数据(pid:{id})获取失败,请稍后再试"); } else { await SendImage(detail, message); } } }
public async Task GetIllustDetail(int id) { if (await Context.User.CheckCoins(5)) { var msg = await ReplyAsync("``数据检索中……``"); var detail = await Illust.Get(id); if (detail == null) { await msg.ModifyAsync(x => x.Content = "数据获取失败,请稍后再试"); } else { StringBuilder sb = new(); foreach (var img in detail.Images) { sb.AppendLine(ImageUrls.ToPixivCat(img.Medium)); } sb.AppendLine(detail.Title) .AppendLine($"Author: {detail.Author}") .AppendLine(detail.Caption) .AppendLine($"Tags: {string.Join(" | ", detail.Tags)}") .AppendLine($"Publish Date: {detail.CreateDate:yyyy-MM-dd hh:mm:ss}") .AppendLine($"Bookmarks: {detail.TotalBookmarks} Comments:{detail.TotalComments} Views:{detail.TotalView}") .Append(detail.Url); await msg.ModifyAsync(x => x.Content = msg.ToString()); await Context.User.RemoveCoins(5); } } else { await ReplyAsync("幻币数量不足"); } }
static async void _GetIllustDetail(int id, Action <object[]> Reply, Action <object[]> SendMessage, bool slient = false) { try { var detail = await Illust.Get(id); if (detail == null) { if (!slient) { Reply?.Invoke(new object[] { $"数据(pid:{id})获取失败,请稍后再试" }); } return; } ArrayList msg = new(); if (detail.IsUgoira) { var ugoira = await detail.GetUgoira(); if (ugoira == null) { if (!slient) { Reply?.Invoke(new object[] { $"动图数据(pid:{id})获取失败" }); } } else { if (!slient) { Reply?.Invoke(new object[] { $"动图数据(pid:{id})获取成功,正在进行压缩..." }); } var img = await ugoira.LimitGifScale(500, 500); var file = await img.SaveGifToTempFile(); msg.Add(CQCode.CQImage(file)); } } else { foreach (var img in detail.Images) { var cache = await DownloadManager.GetCache(img.Medium); if (string.IsNullOrEmpty(cache)) { var url = ImageUrls.ToPixivCat(img.Medium); cache = await DownloadManager.GetCache(url); if (string.IsNullOrEmpty(cache)) { cache = await DownloadManager.Download(url); if (string.IsNullOrEmpty(cache)) { cache = await DownloadManager.Download(img.Medium, detail.Url); if (string.IsNullOrEmpty(cache)) { msg.Add("[图像缓存失败]"); continue; } } } } ImageUtils.LimitImageScale(cache, 1500, 1500); msg.Add(CQCode.CQImage(cache)); } } msg.Add(detail.ToString()); SendMessage?.Invoke(msg.ToArray()); } catch (Exception ex) { ConsoleLog.Debug("QQ Command - Pixiv", ex.GetFormatString(true)); if (!slient) { Reply?.Invoke(new object[] { $"处理作品(pid:{id})时发生异常错误,任务已终止" }); } } }