Skip to content

Commit

Permalink
fix: correct replyTo for /tldr
Browse files Browse the repository at this point in the history
  • Loading branch information
Djaler committed Sep 8, 2024
1 parent c057b68 commit ab55b16
Showing 1 changed file with 6 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,31 +45,22 @@ class TlDrHandler(
message: TextMessage,
args: String?
) {
val messageToReply: Message
val link: String?

val replyTo = message.replyTo
val replyMessageLink = replyTo?.asContentMessage()?.let { extractLink(it) }
if (replyMessageLink !== null) {
messageToReply = replyTo
link = replyMessageLink
} else {
messageToReply = message
link = extractLink(message)
}
val link = message.replyTo?.asContentMessage()
?.let { extractLink(it) }
?: extractLink(message)

if (link === null) {
requestsExecutor.reply(messageToReply, "Либо пришли ссылку, либо ответь командой на сообщение со ссылкой")
requestsExecutor.reply(message, "Либо пришли ссылку, либо ответь командой на сообщение со ссылкой")
return
}

requestsExecutor.withTypingAction(message.chat) {
try {
replyWithTlDr(link, messageToReply)
replyWithTlDr(link, message)
} catch (e: Exception) {
log.error("Exception in thesis generation", e)
sentryClient.captureException(e)
requestsExecutor.reply(messageToReply, "Чёт у меня не получилось")
requestsExecutor.reply(message, "Чёт у меня не получилось")
}
}
}
Expand Down

0 comments on commit ab55b16

Please sign in to comment.