-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.rb
More file actions
34 lines (30 loc) · 1.31 KB
/
main.rb
File metadata and controls
34 lines (30 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# frozen_string_literal: true
require 'dotenv/load'
require 'telegram/bot'
require_relative 'lib/game'
token = ENV['TELEGRAM_TOKEN']
Telegram::Bot::Client.run(token) do |bot|
bot.listen do |message|
case message.text
when '/start'
greetings_message = <<~END
Добро пожаловать в карточную игру "Пьяница", #{message.from.first_name}!
Для запуска игры наберите /play;
Для просмотра очков наберите /score.
END
bot.api.send_message(chat_id: message.chat.id, text: greetings_message)
when '/play'
bot.api.send_message(chat_id: message.chat.id, text: 'Раздаю карты...')
sleep(1)
bot.api.send_message(chat_id: message.chat.id, text: 'На самом деле игра очень простая, поэтому вы увидите только результат :)')
sleep(1)
bot.api.send_message(chat_id: message.chat.id, text: 'Играем!!!')
game = Game.new(bot, message)
game.play
when '/score'
bot.api.send_message(chat_id: message.chat.id, text: Game.score(message.from.id))
when '/stop'
bot.api.send_message(chat_id: message.chat.id, text: "Пока, #{message.from.first_name}, спасибо за игру!")
end
end
end