Sha256: 6669eb642bc990f44d9a3ee3b9126fffc7454e60006e85ec8186a85c9a3a230e

Contents?: true

Size: 628 Bytes

Versions: 8

Compression:

Stored size: 628 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
    when Telegram::Bot::Types::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
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
telegram-bot-ruby-2.2.0 examples/bot.rb
telegram-bot-ruby-2.1.0 examples/bot.rb
telegram-bot-ruby-2.0.0 examples/bot.rb
telegram-bot-ruby-1.0.0 examples/bot.rb
telegram-bot-ruby-1.0.0.rc1 examples/bot.rb
telegram-bot-ruby-1.0.0.pre examples/bot.rb
telegram-bot-ruby-0.23.0 examples/bot.rb
telegram-bot-ruby-0.22.0 examples/bot.rb