#!/usr/bin/env ruby require 'erb' require 'net/http' require 'uri' require 'json' require 'cgi' # Flattens any data structure to URL parameters, recursively. Because # apparently the standard library just doesn't fucking provide this. # Oh well. At least it isn't something as simple as *recursively # copying an array* (looking at you Lua.) def url_params param, key, output = {} case when param.is_a?(Array) param.each.with_index do |v, k| url_params(v, key + "[" + k.to_s + "]", output) end when param.is_a?(Hash) param.each do |k, v| url_params(v, key + "[" + k.to_s + "]", output) end else output[key] = CGI.unescapeHTML param.to_s.gsub /<\/?[^>]*>/, "" end output end CLIENT_KEY = ENV["_agw_secret_gender_swap_client_key"] CLIENT_SECRET = ENV["_agw_secret_gender_swap_client_secret"] ACCESS_TOKEN = ENV["_agw_secret_gender_swap_access_token"] ALIGNMENT = ARGV[2] PRESENTATION = ARGV[1] PRONOUNS = ARGV[0].split("/").map do |pro| path = if pro == "they" then "they/.../themself" else pro end %(#{pro}) end Net::HTTP.start("social.greyserv.net", use_ssl: true) do |http| auth = { "Authorization" => "Bearer " + ACCESS_TOKEN, } status = <<_end_ pronouns: #{PRONOUNS.join "/"} presentation: #{PRESENTATION} alignment: #{ALIGNMENT} _end_ fields = http.get( "/api/v1/accounts/verify_credentials", auth, ).body fields = JSON.parse(fields)["fields"].map do |field| if field["name"] == "current pronouns" field["value"] = PRONOUNS.join "/" end field.delete "verified_at" field end http.patch( "/api/v1/accounts/update_credentials", URI.encode_www_form(url_params(fields, "fields_attributes")), auth, ) http.post( "/api/v1/statuses", URI.encode_www_form( "status" => status, "in_reply_to_id" => "104612572584164654", "spoiler_text" => "current gender", "visibility" => "unlisted", "language" => "en" ), auth, ) end template = ERB.new < Gender

Current

Pronouns
    <% PRONOUNS.each do |pro| %>
  • <%= pro %>
  • <% end %>
Presentation <%= PRESENTATION %>
Alignment <%= ALIGNMENT %>

Explanation

I am genderflux, and my gender identity changes often. The information on this page will be up to date with my Mastodon account, so please check either of them if you're wondering how to most correctly address me at a given time! Please note that it is always fine to use they/them for me, and I don't usually mind if pronouns other than what I'm currently using are used.

html Net::HTTP.post( URI("https://fuck.greyserv.net/gender.cgi"), template.result, "Content-Type" => "text/html", ) # EOF