Skip to content

Commit

Permalink
[telegram] multiple authors in notifications (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
siper authored Dec 10, 2023
1 parent 495d481 commit 6359105
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/main/kotlin/ru/stersh/bookcrawler/core/Notification.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ data class Notification(
val type: MessageType,
val title: String,
val coverUrl: String,
val author: String,
val authors: List<String>,
val series: Series?,
val availableActions: List<Action>
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class AtLibraryCheckTask : TaskManager.Task {
id = BookId(work.id, At.PROVIDER_NAME),
title = work.title,
coverUrl = work.coverUrl,
author = work.authorFIO,
authors = listOfNotNull(work.authorFIO, work.coAuthorFIO),
series = getSeriesFromWork(work),
type = MessageType.NEW_BOOK_IN_LIBRARY,
availableActions = if (work.inLibraryState == LibraryState.Finished) {
Expand Down Expand Up @@ -78,7 +78,7 @@ class AtLibraryCheckTask : TaskManager.Task {
id = BookId(work.id, At.PROVIDER_NAME),
title = work.title,
coverUrl = work.coverUrl,
author = work.authorFIO,
authors = listOfNotNull(work.authorFIO, work.coAuthorFIO),
series = getSeriesFromWork(work),
type = MessageType.UPDATES_IN_READING_BOOK,
availableActions = if (work.inLibraryState == LibraryState.Finished) {
Expand All @@ -101,7 +101,7 @@ class AtLibraryCheckTask : TaskManager.Task {
id = BookId(nextWork.id, At.PROVIDER_NAME),
title = nextWork.title,
coverUrl = nextWork.coverUrl,
author = nextWork.authorFIO,
authors = listOfNotNull(nextWork.authorFIO, nextWork.coAuthorFIO),
series = getSeriesFromWork(nextWork),
type = MessageType.NEW_BOOK_IN_SERIES,
availableActions = listOf(Action.ADD_TO_LIBRARY)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,15 @@ class TelegramNotificationHandler(
append("\n")
append("*${notification.title}*")
append("\n")
append("_${notification.author}_")
}
message.append("_")
notification.authors.forEachIndexed { index, author ->
if (index > 0) {
message.append(", ")
}
message.append(author)
}
message.append("_")
if (notification.series != null) {
message.append("\n")
message.append("__${notification.series.title} (${notification.series.order})__")
Expand Down

0 comments on commit 6359105

Please sign in to comment.