Module: Telegram
- Defined in:
- lib/telegram.rb
Overview
Is a representation of Telegram API
Class Method Summary collapse
- .method_missing(method_name, *args, &_block) ⇒ Object
- .parse_update(raw_update) ⇒ Object
- .path_verified(path) ⇒ Object
- .token=(telegram_token) ⇒ Object
Class Method Details
.method_missing(method_name, *args, &_block) ⇒ Object
19 20 21 22 |
# File 'lib/telegram.rb', line 19 def self.method_missing(method_name, *args, &_block) uri = URI("https://api.telegram.org/bot#{@telegram_token}/#{method_name}") Net::HTTP.post_form(uri, args.first) end |
.parse_update(raw_update) ⇒ Object
28 29 30 |
# File 'lib/telegram.rb', line 28 def self.parse_update(raw_update) Update.from_hash JSON.parse(raw_update) end |
.path_verified(path) ⇒ Object
24 25 26 |
# File 'lib/telegram.rb', line 24 def self.path_verified(path) path.start_with? "/#{@telegram_token}" end |
.token=(telegram_token) ⇒ Object
15 16 17 |
# File 'lib/telegram.rb', line 15 def self.token=(telegram_token) @telegram_token = telegram_token end |