mirror of
https://github.com/dyrkin/luxmed-bot.git
synced 2025-12-24 06:28:37 +01:00
Fixed bug when user can't choose a date using date picker but only manually
This commit is contained in:
@@ -27,7 +27,7 @@ import java.time.format.TextStyle
|
||||
import java.time.{LocalTime, ZonedDateTime}
|
||||
|
||||
import akka.actor.ActorSystem
|
||||
import com.lbs.bot.model.{Button, Command}
|
||||
import com.lbs.bot.model.Button
|
||||
import com.lbs.bot.{Bot, _}
|
||||
import com.lbs.server.conversation.DatePicker._
|
||||
import com.lbs.server.conversation.Login.UserId
|
||||
@@ -101,9 +101,9 @@ class DatePicker(val userId: UserId, val bot: Bot, val localization: Localizatio
|
||||
bot.sendMessage(userId.source, "Incorrect date. Please use format dd-MM")
|
||||
goto(requestDate)
|
||||
}
|
||||
case Msg(Command(_, msg, Some(tag)), date) =>
|
||||
case Msg(cmd@CallbackCommand(tag), date) =>
|
||||
val modifiedDate = modifyDate(date, tag)
|
||||
bot.sendEditMessage(userId.source, msg.messageId, inlineKeyboard = dateButtons(modifiedDate))
|
||||
bot.sendEditMessage(userId.source, cmd.message.messageId, inlineKeyboard = dateButtons(modifiedDate))
|
||||
stay() using modifiedDate
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ package com.lbs.server.conversation
|
||||
import java.time.LocalTime
|
||||
|
||||
import akka.actor.ActorSystem
|
||||
import com.lbs.bot.model.{Button, Command}
|
||||
import com.lbs.bot.model.Button
|
||||
import com.lbs.bot.{Bot, _}
|
||||
import com.lbs.server.conversation.Login.UserId
|
||||
import com.lbs.server.conversation.TimePicker.{Mode, Tags, TimeFromMode, TimeToMode}
|
||||
@@ -96,9 +96,9 @@ class TimePicker(val userId: UserId, val bot: Bot, val localization: Localizatio
|
||||
bot.sendMessage(userId.source, "Incorrect time. Please use format HH:mm")
|
||||
goto(requestTime)
|
||||
}
|
||||
case Msg(Command(_, msg, Some(tag)), time) =>
|
||||
case Msg(cmd@CallbackCommand(tag), time) =>
|
||||
val modifiedTime = modifyTime(time, tag)
|
||||
bot.sendEditMessage(userId.source, msg.messageId, inlineKeyboard = timeButtons(modifiedTime))
|
||||
bot.sendEditMessage(userId.source, cmd.message.messageId, inlineKeyboard = timeButtons(modifiedTime))
|
||||
stay() using modifiedTime
|
||||
}
|
||||
|
||||
|
||||
@@ -128,11 +128,11 @@ package object util {
|
||||
object MessageExtractors {
|
||||
|
||||
object TextCommand {
|
||||
def unapply(cmd: Command): Option[String] = cmd.message.text.filter(_.nonEmpty)
|
||||
def unapply(cmd: Command): Option[String] = if(cmd.callbackData.isEmpty) cmd.message.text.filter(_.nonEmpty) else None
|
||||
}
|
||||
|
||||
object OptionalTextCommand {
|
||||
def unapply(cmd: Command): Option[Option[String]] = Some(TextCommand.unapply(cmd))
|
||||
def unapply(cmd: Command): Option[Option[String]] = if(cmd.callbackData.isEmpty) Some(TextCommand.unapply(cmd)) else None
|
||||
}
|
||||
|
||||
object CallbackCommand {
|
||||
|
||||
Reference in New Issue
Block a user