diff --git a/plugins/vcn.rb b/plugins/vcn.rb new file mode 100644 index 0000000..78ff280 --- /dev/null +++ b/plugins/vcn.rb @@ -0,0 +1,24 @@ +require 'net/https' +require 'uri' + +class VCN + include Cinch::Plugin + + match "vcn" + + def execute(m) + base_uri = "https://webmail.ventuordici.org/toolz/token" + uri = URI.parse(base_uri+"/generate") + Net::HTTP.start(uri.host, uri.port, + :use_ssl => uri.scheme == 'https', + :verify_mode => OpenSSL::SSL::VERIFY_NONE) do |https| + + request = Net::HTTP::Post.new(uri.request_uri) + request.set_form_data({"email" => ENV["ORTICHE_MAIL"], "password" => ENV["ORTICHE_PASS"], "type" => "vcn"}) + response = https.request(request) + if response.body =~ /(.*?)<\/span>/ + m.reply base_uri+"/check/"+$1 + end + end + end +end