Class: TARS::API
Class Method Summary collapse
- .me ⇒ Object
- .reply_to(chat_id, text) ⇒ Object
- .reply_with_photo(chat_id, photo) ⇒ Object
- .updates ⇒ Object
- .webhook ⇒ Object
Class Method Details
.me ⇒ Object
14 15 16 |
# File 'lib/tars/api.rb', line 14 def self.me request 'getMe' end |
.reply_to(chat_id, text) ⇒ Object
26 27 28 |
# File 'lib/tars/api.rb', line 26 def self.reply_to(chat_id, text) request 'sendMessage', chat_id: chat_id, text: text end |
.reply_with_photo(chat_id, photo) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/tars/api.rb', line 30 def self.reply_with_photo(chat_id, photo) uri = "https://#{BASE_URI}/bot#{TARS.config.token}/sendPhoto" random = "/tmp/#{Digest::MD5.hexdigest(photo)}#{File.extname(photo)}" IO.copy_stream(open(photo), random) RestClient.post(uri, chat_id: chat_id, photo: open(random)) File.delete(random) end |
.updates ⇒ Object
18 19 20 |
# File 'lib/tars/api.rb', line 18 def self.updates request 'getUpdates' end |