Sha256: c62496a2beab8352f08eeba8ca514bdeba72544482387dbb9b12dd21ec7ddaf6

Contents?: true

Size: 507 Bytes

Versions: 5

Compression:

Stored size: 507 Bytes

Contents

require_relative 'objects'

class TelegramBot::Chat < Struct.new(:id)
  include TelegramBot::AutoFromMethods

  def self.from(id)
    case id
    when Integer
      TelegramBot::Chat.new(id)
    when TelegramBot::GroupChat, TelegramBot::User
      id
    when Hash
      if id.has_key? 'title'
        TelegramBot::GroupChat.from(id)
      elsif id.has_key? 'first_name'
        TelegramBot::User.from(id)
      else
        TelegramBot::Chat.from(id['id'])
      end
    else
      super
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
telegram_bot_ruby-0.1.7 lib/telegram_bot/chat.rb
telegram_bot_ruby-0.1.6 lib/telegram_bot/chat.rb
telegram_bot_ruby-0.1.5 lib/telegram_bot/chat.rb
telegram_bot_ruby-0.1.3 lib/telegram_bot/chat.rb
telegram_bot_ruby-0.1.1 lib/telegram_bot/chat.rb