Last active
August 10, 2022 15:20
-
-
Save installero/44df53efc851036174c2aaebb9bc46e5 to your computer and use it in GitHub Desktop.
Revisions
-
installero revised this gist
Aug 10, 2022 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ # https://www.stopforumspam.com/usage # require 'byebug' require 'httparty' -
installero created this gist
Aug 10, 2022 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,38 @@ # require 'byebug' require 'httparty' url = 'http://api.stopforumspam.org/api'; username, email, ip = ARGV[0..2] data = {username: [username], email: email, ip: ip} response = HTTParty.post(url, query: data, format: :xml) check_results_hash = response['response'] # { # username: {appears: false}, # email: {appears: true, frequency: 321, last_seen_at: '2022-07-18 16:44:41'}, # ip: {appears: true, frequency: 2875, last_seen_at: '2022-08-02 23:02:01'} # } result = {} last_seen_index_offset = 0 check_results_hash['type'].each.with_index do |field_name, index| appears = check_results_hash['appears'][index] == 'yes' result[field_name] = {appears: appears} unless appears last_seen_index_offset -= 1 next end result[field_name].merge!({ frequency: check_results_hash['frequency'][index], last_seen_at: check_results_hash['lastseen'][index + last_seen_index_offset] }) end puts result.inspect