Sha256: 76c98f0b2af0ecef9196fb12146e8311ef130c283d3e21678b456eb990b149f7

Contents?: true

Size: 548 Bytes

Versions: 6

Compression:

Stored size: 548 Bytes

Contents

# frozen_string_literal: true

require 'rubygems'
require 'telegram/bot'

token = 'replace-me-with-your-real-token'

Telegram::Bot::Client.run(token) do |bot|
  bot.listen do |message|
    case message.text
    when '/start'
      bot.api.send_message(chat_id: message.chat.id, text: "Hello, #{message.from.first_name}!")
    when '/end'
      bot.api.send_message(chat_id: message.chat.id, text: "Bye, #{message.from.first_name}!")
    else
      bot.api.send_message(chat_id: message.chat.id, text: "I don't understand you :(")
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
telegram-bot-ruby-0.21.1 examples/bot.rb
telegram-bot-ruby-0.21.0 examples/bot.rb
telegram-bot-ruby-0.20.0 examples/bot.rb
telegram-bot-ruby-0.19.2 examples/bot.rb
telegram-bot-ruby-0.19.1 examples/bot.rb
telegram-bot-ruby-0.19.0 examples/bot.rb