diff --git a/app/services/telegram/command/start.rb b/app/services/telegram/command/start.rb index e441eb9..f1c71c7 100644 --- a/app/services/telegram/command/start.rb +++ b/app/services/telegram/command/start.rb @@ -5,9 +5,9 @@ class Start class << self def execute(channel) TelegramMessenger.welcome(channel) - TelegramMessenger.ask_level(channel) + TelegramMessenger.ask_language(channel) - Telegram::CommandQueue.push{ TelegramMessenger.ask_language(channel) } + Telegram::CommandQueue.push{ TelegramMessenger.ask_level(channel) } Telegram::CommandQueue.push{ TelegramMessenger.ask_length(channel) } end end diff --git a/app/services/telegram_messenger.rb b/app/services/telegram_messenger.rb index 74db280..a9ef65d 100644 --- a/app/services/telegram_messenger.rb +++ b/app/services/telegram_messenger.rb @@ -60,7 +60,10 @@ def ask_length(channel) end def game_created(game) - "Game created with #{game.secret.length} letters in the secret word." + message = "Game created: #{game.secret.length} letters." + message += " Language: #{game.dictionary.lang}" if game.dictionary.present? + + message end def guess(guess) diff --git a/spec/services/telegram_dispatcher_spec.rb b/spec/services/telegram_dispatcher_spec.rb index 66f3aeb..19f65a3 100644 --- a/spec/services/telegram_dispatcher_spec.rb +++ b/spec/services/telegram_dispatcher_spec.rb @@ -24,7 +24,7 @@ expect { expect(TelegramDispatcher.handle(message)).to be expect(TelegramMessenger).to have_received(:send_message).with(chat_id, /Welcome to Bulls and Cows!/).once - expect(TelegramMessenger).to have_received(:send_message).with(chat_id, 'Select game level:', markup).once + expect(TelegramMessenger).to have_received(:send_message).with(chat_id, 'Select game language:', markup).once }.to change(Telegram::CommandQueue, :size).by(2) end end @@ -54,19 +54,19 @@ end it 'replies with a game created text' do - expect(TelegramDispatcher.handle(message)).to include('Game created with 6 letters in the secret word') + expect(TelegramDispatcher.handle(message)).to include('Game created: 6 letters') end end context 'when /create multiple spaces in between command received' do - let!(:message) { Telegram::Bot::Types::Message.new(text: '/create коитус') } + let!(:message) { Telegram::Bot::Types::Message.new(text: '/create коитус') } before do message.stub_chain(:chat, :id).and_return(chat_id) end it 'replies with a game created text' do - expect(TelegramDispatcher.handle(message)).to include('Game created with 6 letters in the secret word') + expect(TelegramDispatcher.handle(message)).to include('Game created: 6 letters.') end end @@ -81,7 +81,7 @@ end it 'replies with a game created text' do - expect(TelegramDispatcher.handle(message)).to include('Game created with 6 letters in the secret word') + expect(TelegramDispatcher.handle(message)).to include('Game created: 6 letters. Language: EN') end end