Fixed bug when user can't choose a date using date picker but only manually

This commit is contained in:
Eugene Zadyra
2018-10-30 14:03:34 +01:00
parent c096c8f44f
commit ea471cdfd3
3 changed files with 8 additions and 8 deletions

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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 {