diff --git a/bot/controller.go b/bot/controller.go index 1749cda..d14c060 100644 --- a/bot/controller.go +++ b/bot/controller.go @@ -245,10 +245,7 @@ func (bc *BotController) commandCreateSimpleTx(m *tb.Message) { return } hint := tx.NextHint(bc.Repo, m) - _, err = bc.Bot.Send(Recipient(m), hint.Prompt, ReplyKeyboard(hint.KeyboardOptions)) - if err != nil { - bc.Logf(ERROR, m, "Sending bot message failed: %s", err.Error()) - } + bc.sendNextTxHint(hint, m) } func (bc *BotController) commandAddComment(m *tb.Message) { @@ -660,12 +657,7 @@ func (bc *BotController) handleTextState(m *tb.Message) { return } hint := tx.NextHint(bc.Repo, m) - replyKeyboard := ReplyKeyboard(hint.KeyboardOptions) - bc.Logf(TRACE, m, "Sending hints for next step: %v", hint.KeyboardOptions) - _, err = bc.Bot.Send(Recipient(m), hint.Prompt, replyKeyboard) - if err != nil { - bc.Logf(ERROR, m, "Sending bot message failed: %s", err.Error()) - } + bc.sendNextTxHint(hint, m) return } else if state == ST_TPL { if bc.processNewTemplateResponse(m, bc.State.tplStates[chatId(m.Chat.ID)]) { @@ -677,6 +669,15 @@ func (bc *BotController) handleTextState(m *tb.Message) { "Are there new state types not maintained yet?") } +func (bc *BotController) sendNextTxHint(hint *Hint, m *tb.Message) { + replyKeyboard := ReplyKeyboard(hint.KeyboardOptions) + bc.Logf(TRACE, m, "Sending hints for next step: %v", hint.KeyboardOptions) + _, err := bc.Bot.Send(Recipient(m), escapeCharacters(hint.Prompt, "(", ")", "."), replyKeyboard, tb.ModeMarkdownV2) + if err != nil { + bc.Logf(ERROR, m, "Sending bot message failed: %s", err.Error()) + } +} + func clearKeyboard() *tb.ReplyMarkup { return &tb.ReplyMarkup{ReplyKeyboardRemove: true} } diff --git a/bot/transactionBuilder.go b/bot/transactionBuilder.go index 15047f1..b0e6769 100644 --- a/bot/transactionBuilder.go +++ b/bot/transactionBuilder.go @@ -184,10 +184,10 @@ func CreateSimpleTx(suggestedCur, template string) (Tx, error) { stepDetails: make(map[command]Input), template: template, }). - addStep("amount", fmt.Sprintf("Please enter the amount of money (e.g. '12.34' or '12.34 %s')", suggestedCur), HandleFloat). - addStep("from", "Please enter the account the money came from (or select one from the list)", HandleRaw). - addStep("to", "Please enter the account the money went to (or select one from the list)", HandleRaw). - addStep("description", "Please enter a description (or select one from the list)", HandleRaw) + addStep("amount", fmt.Sprintf("Please enter the *amount* of money (e.g. '12.34' or '12.34 %s')", suggestedCur), HandleFloat). + addStep("from", "Please enter the *account* the money came *from* (or select one from the list)", HandleRaw). + addStep("to", "Please enter the *account* the money went *to* (or select one from the list)", HandleRaw). + addStep("description", "Please enter a *description* (or select one from the list)", HandleRaw) return tx, nil } diff --git a/scenarioTests/features/list.feature b/scenarioTests/features/list.feature index c3a6cdc..782f05d 100644 --- a/scenarioTests/features/list.feature +++ b/scenarioTests/features/list.feature @@ -25,6 +25,7 @@ Feature: List transactions And I create a simple tx with amount 1.23 and accFrom someFromAccount and accTo someToAccount and desc Test Tx And I wait 0.1 seconds When I send the message "/list dated" + And I wait 0.1 seconds Then 1 messages should be sent back And the response should include the message "; recorded on $today " diff --git a/scenarioTests/features/templates.feature b/scenarioTests/features/templates.feature index 5a1aba6..9bd18d2 100644 --- a/scenarioTests/features/templates.feature +++ b/scenarioTests/features/templates.feature @@ -14,10 +14,10 @@ Feature: Templates When I send the message "/t my" Then 2 messages should be sent back And the response should include the message "Creating a new transaction from your template 'mytpl'" - And the response should include the message "Please enter the amount" + And the response should include the message "Please enter the *amount*" When I send the message "15,15" Then 1 messages should be sent back - And the response should include the message "Please enter a description" + And the response should include the message "Please enter a **description**" When I send the message "some description" Then 1 messages should be sent back And the response should include the message "Successfully recorded your transaction." diff --git a/scenarioTests/features/transactions.feature b/scenarioTests/features/transactions.feature index a464530..dadb0e7 100644 --- a/scenarioTests/features/transactions.feature +++ b/scenarioTests/features/transactions.feature @@ -19,13 +19,13 @@ Feature: Transactions When I send the message "12.34" Then 2 messages should be sent back And the response should include the message "created a new transaction for you" - And the response should include the message "enter the account the money came from" + And the response should include the message "enter the **account** the money came **from**" When I send the message "FromAccount" Then 1 messages should be sent back - And the response should include the message "enter the account the money went to" + And the response should include the message "enter the **account** the money went **to**" When I send the message "ToAccount" Then 1 messages should be sent back - And the response should include the message "enter a description" + And the response should include the message "enter a **description**" When I send the message "any random tx description" Then 1 messages should be sent back And the response should include the message "Successfully recorded your transaction." diff --git a/scenarioTests/steps/bot.py b/scenarioTests/steps/bot.py index d88eaed..bc4ffa4 100644 --- a/scenarioTests/steps/bot.py +++ b/scenarioTests/steps/bot.py @@ -83,7 +83,7 @@ async def step_impl(context, same, message): try: assert message in response.text except AssertionError: - print("substring", message, "could not be found in", response.text) + print("substring '", message, "' could not be found in '", response.text, "'") assert False @then('the response should have a keyboard with {position} entry being "{keyboardEntry}"')