@@ -55,6 +55,8 @@ internal suspend fun UserCommandSender.withHelper(block: suspend PixivHelper.()
55
55
is String -> quoteReply(message)
56
56
is IllustInfo -> sendIllust(message)
57
57
is ArtWorkInfo -> sendArtwork(message)
58
+ is UserPreview -> quoteReply(buildUserPreviewMessage(message, subject))
59
+ is UserDetail -> quoteReply(buildUserDetailMessage(message, subject))
58
60
else -> quoteReply(message.toString())
59
61
}
60
62
} catch (exception: CancellationException ) {
@@ -317,46 +319,37 @@ public suspend fun buildIllustMessage(illust: IllustInfo, contact: Contact): Mes
317
319
}
318
320
}
319
321
320
- //
321
- // internal suspend fun PixivHelper.buildMessageByUser(preview: UserPreview) = buildMessageChain {
322
- // appendLine("NAME: ${preview.user.name}")
323
- // appendLine("UID: ${preview.user.id}")
324
- // appendLine("ACCOUNT: ${preview.user.account}")
325
- // appendLine("FOLLOWED: ${preview.user.isFollowed}")
326
- // appendLine("TWITTER: ${Twitter[preview.user.id].joinToString { it.screen }}")
327
- // try {
328
- // append(preview.user.getProfileImage().uploadAsImage(contact))
329
- // } catch (e: Throwable) {
330
- // logger.warning({ "User(${preview.user.id}) ProfileImage 下载失败" }, e)
331
- // }
332
- // for (illust in preview.illusts.apply { replicate() }.write()) {
333
- // if (illust.isEro().not()) continue
334
- // try {
335
- // if (illust.age == AgeLimit.ALL) {
336
- // illust.useImageResources { index, resource ->
337
- // if (index < 1) add(resource.uploadAsImage(contact))
338
- // }
339
- // }
340
- // } catch (e: Throwable) {
341
- // logger.warning({ "User(${preview.user.id}) PreviewImage 下载失败" }, e)
342
- // }
343
- // }
344
- // }
345
- //
346
- // internal suspend fun PixivHelper.buildMessageByUser(detail: UserDetail) = buildMessageChain {
347
- // appendLine("NAME: ${detail.user.name}")
348
- // appendLine("UID: ${detail.user.id}")
349
- // appendLine("ACCOUNT: ${detail.user.account}")
350
- // appendLine("FOLLOWED: ${detail.user.isFollowed}")
351
- // appendLine("TOTAL: ${detail.profile.totalArtwork}")
352
- // appendLine("TWITTER: ${detail.twitter()}")
353
- // try {
354
- // append(detail.user.getProfileImage().uploadAsImage(contact))
355
- // } catch (e: Throwable) {
356
- // logger.warning({ "User(${detail.user.id}) ProfileImage 下载失败" }, e)
357
- // }
358
- // }
359
- //
322
+ public suspend fun buildUserPreviewMessage (preview : UserPreview , contact : Contact ): MessageChain {
323
+ return buildMessageChain {
324
+ appendLine(" NAME: ${preview.user.name} " )
325
+ appendLine(" UID: ${preview.user.id} " )
326
+ appendLine(" ACCOUNT: ${preview.user.account} " )
327
+ appendLine(" FOLLOWED: ${preview.user.isFollowed} " )
328
+ appendLine(" TWITTER: ${Twitter [preview.user.id].joinToString { it.screen }} " )
329
+ try {
330
+ append(preview.user.profile().uploadAsImage(contact))
331
+ } catch (cause: Exception ) {
332
+ logger.warning({ " User(${preview.user.id} ) ProfileImage 下载失败" }, cause)
333
+ }
334
+ }
335
+ }
336
+
337
+ public suspend fun buildUserDetailMessage (detail : UserDetail , contact : Contact ): MessageChain {
338
+ return buildMessageChain {
339
+ appendLine(" NAME: ${detail.user.name} " )
340
+ appendLine(" UID: ${detail.user.id} " )
341
+ appendLine(" ACCOUNT: ${detail.user.account} " )
342
+ appendLine(" FOLLOWED: ${detail.user.isFollowed} " )
343
+ appendLine(" TOTAL: ${detail.profile.totalArtwork} " )
344
+ appendLine(" TWITTER: ${detail.twitter()} " )
345
+ try {
346
+ append(detail.user.profile().uploadAsImage(contact))
347
+ } catch (cause: Exception ) {
348
+ logger.warning({ " User(${detail.user.id} ) ProfileImage 下载失败" }, cause)
349
+ }
350
+ }
351
+ }
352
+
360
353
// internal suspend fun PixivHelper.buildMessageByUser(uid: Long) = buildMessageByUser(detail = userDetail(uid))
361
354
//
362
355
// internal suspend fun PixivHelper.buildMessageByCreator(creator: CreatorDetail) = buildMessageChain {
@@ -438,7 +431,7 @@ public suspend fun loadIllustInfo(
438
431
439
432
// region Download Image
440
433
441
- internal suspend fun UserInfo.getProfileImage (): File {
434
+ internal suspend fun UserInfo.profile (): File {
442
435
val image = Url (profileImageUrls.values.lastOrNull() ? : NO_PROFILE_IMAGE )
443
436
return ProfileFolder .resolve(image.filename).apply {
444
437
if (exists().not ()) {
0 commit comments