Module: Dialog::Wrappers
- Defined in:
- lib/telegram/wrappers.rb
Class Method Summary collapse
Class Method Details
.apiGetFilePath(file_id) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/telegram/wrappers.rb', line 17 def apiGetFilePath(file_id) c = Dialog::BotApi.socks5_connection url="/bot#{Dialog.config.secure.token}/getFile?file_id=#{file_id}" response = c.get url response_json = JSON.parse response.body file_path=response_json["result"]["file_path"] return file_path end |
.downloadFile(args) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/telegram/wrappers.rb', line 27 def downloadFile(args) file = args[:mmsg][:fqndata][:f][:file] c = Dialog::BotApi.socks5_connection url_file="/file/bot#{Dialog.config.secure.token}/#{file[:path]}" response = c.get url_file file.has_key?(:name) ? name = file[:name] : name = file[:path].split('/')[1] File.open("#{Dialog.config.path.dialogTmpfiles}/#{name}", 'wb') { |fp| fp.write(response.body) } return name end |