Skip to content

Instantly share code, notes, and snippets.

@Voker57
Created May 8, 2016 21:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Voker57/c5e64fd57dc04d32cc67acde04785259 to your computer and use it in GitHub Desktop.
Save Voker57/c5e64fd57dc04d32cc67acde04785259 to your computer and use it in GitHub Desktop.
# 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