Class: TelegramBot::Chat

Inherits:
Struct
  • Object
show all
Includes:
AutoFromMethods
Defined in:
lib/telegram_bot/chat.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Methods included from AutoFromMethods

included

Instance Attribute Details

#idObject

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



3
4
5
# File 'lib/telegram_bot/chat.rb', line 3

def id
  @id
end

Class Method Details

.from(id) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/telegram_bot/chat.rb', line 6

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