Compare commits
1 Commits
3a3de48c8f
...
f6e9062b47
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f6e9062b47 |
@@ -171,7 +171,7 @@ object CheckDeliveryDialog {
|
||||
val message = SendMessage(chatId, "Please enter a parcel id to remove.", reply_markup = Some(markup))
|
||||
sendMessage(message, waitParcelId(parcelId => removeParcelId(parcelId)), onFailure)
|
||||
} else {
|
||||
val message = SendMessage(chatId, "You don't have watched parcels. There is nothing to remove.", reply_markup = commandsKeyboard)
|
||||
val message = SendMessage(chatId, "You don't have watched parcels. There is nothing to remove.")
|
||||
sendMessage(message, onSuccess, onFailure)
|
||||
}
|
||||
case ListParcelsFailure(exception) =>
|
||||
@@ -240,7 +240,7 @@ object CheckDeliveryDialog {
|
||||
Behaviors.same
|
||||
}
|
||||
|
||||
def sendMessage(message: SendMessage, onSuccess: => Behavior[Command], onFailure: => Behavior[Command], attempt: Int = 1): Behavior[Command] = Behaviors.setup[Command] { ctx =>
|
||||
def sendMessage(message: SendMessage, onSuccess: => Behavior[Command], onFailure: => Behavior[Command], attempt: Int = 0): Behavior[Command] = Behaviors.setup[Command] { ctx =>
|
||||
import io.circe.generic.auto._
|
||||
import io.circe.syntax._
|
||||
|
||||
@@ -254,7 +254,7 @@ object CheckDeliveryDialog {
|
||||
|
||||
Source
|
||||
.single(request)
|
||||
.initialDelay(2.seconds * (attempt - 1))
|
||||
.initialDelay(2.seconds * attempt)
|
||||
.mapAsync(1) { request =>
|
||||
http
|
||||
.singleRequest(request)
|
||||
@@ -280,7 +280,7 @@ object CheckDeliveryDialog {
|
||||
case SendMessageFailure(exception) =>
|
||||
ctx.log.error(exception, "action=send_message status=finished result=failure chat_id={} attempt={}", chatId, attempt)
|
||||
|
||||
if (attempt > 5) {
|
||||
if (attempt >= 5) {
|
||||
ctx.log.error(exception, "action=send_message result=failure message=attempts threshold exceeded")
|
||||
stashBuffer.unstashAll(ctx, onFailure)
|
||||
} else {
|
||||
|
||||
@@ -104,7 +104,7 @@ object TelegramBot {
|
||||
}
|
||||
}
|
||||
|
||||
def settingWebhook(binding: Http.ServerBinding, attempt: Int = 1): Behavior[Command] = Behaviors.setup[Command] { ctx =>
|
||||
def settingWebhook(binding: Http.ServerBinding): Behavior[Command] = Behaviors.setup[Command] { ctx =>
|
||||
case object SetWebhookSuccess extends Command
|
||||
case class SetWebhookFailure(exception: Throwable) extends Command
|
||||
|
||||
@@ -145,13 +145,9 @@ object TelegramBot {
|
||||
ctx.log.info("action=set_webhook result=success")
|
||||
stashBuffer.unstashAll(ctx, started(binding))
|
||||
case SetWebhookFailure(exception) =>
|
||||
if (attempt > 20) {
|
||||
ctx.log.error(exception, "action=set_webhook result=failure attempt={}", attempt)
|
||||
ctx.log.error("action=set_webhook result=failure", exception)
|
||||
ctx.log.error("action=start_bot result=failure")
|
||||
unbindingServer(binding, None)
|
||||
} else {
|
||||
settingWebhook(binding, attempt = attempt + 1)
|
||||
}
|
||||
case otherCommand: Command =>
|
||||
stashBuffer.stash(otherCommand)
|
||||
Behaviors.same
|
||||
|
||||
Reference in New Issue
Block a user