Created
May 8, 2016 21:11
-
-
Save Voker57/c5e64fd57dc04d32cc67acde04785259 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# usage: ruby bnwdump.rb put <loginkey> < file | |
# ruby bnwdump.rb get <loginkey> <id> > file | |
require 'net/http' | |
require 'base64' | |
require 'json' | |
club = "files" | |
action = ARGV[0] | |
case action | |
when "put" | |
loginkey = ARGV[1] | |
gpg_kid = ARGV[3] | |
puts JSON.parse(Net::HTTP.post_form(URI.parse("https://bnw.im/api/post"), text: Base64.encode64(STDIN.read), clubs: club, login: loginkey, anonymous: 1).body)["id"] | |
when "get" | |
loginkey = ARGV[1] | |
file_id = ARGV[2] | |
puts Base64.decode64(JSON.parse(Net::HTTP.get(URI.parse("https://bnw.im/api/show?message=#{file_id}")))["messages"][0]["text"].strip) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment