<commit_before>require 'httparty'
require 'open-uri'
require 'json'

module Cinch
  module Plugins
    class Flickr
      include Cinch::Plugin

      match /(flickr) (.+)/
      match /(help flickr)$/, method: :help

      def execute(m, prefix, flickr, user)
        username = URI.encode(user.split(/[[:space:]]/).join(' ').downcase)
        buffet = open("https://api.flickr.com/services/rest/?method=flickr.people.findByUsername&api_key=#{ENV['FLICKR_KEY']}&username=#{username}&format=json&nojsoncallback=1").read
        result = JSON.parse(buffet)
        nsid = result['user']['nsid']
        photos_req = open("https://api.flickr.com/services/rest/?method=flickr.people.getPublicPhotos&api_key=#{ENV['FLICKR_KEY']}&user_id=#{nsid}&format=json&nojsoncallback=1").read
        response = JSON.parse(photos_req)

        return m.reply 'nada' if response['photos']['photo'].size == 0

        photo_title = response['photos']['photo'].first['title']
        photo_id = response['photos']['photo'].first['id']

        m.reply "https://www.flickr.com/photos/#{nsid}/#{photo_id}/"
      end

      def help(m)
        m.reply 'returns most recent flickr pic of specified user'
      end

    end
  end
end<commit_msg>Refactor: Better variable naming<commit_after>require 'httparty'
require 'open-uri'
require 'json'

module Cinch
  module Plugins
    class Flickr
      include Cinch::Plugin

      match /(flickr) (.+)/
      match /(help flickr)$/, method: :help

      def execute(m, prefix, flickr, user)
        username = URI.encode(user.split(/[[:space:]]/).join(' ').downcase)
        nsid_req = open("https://api.flickr.com/services/rest/?method=flickr.people.findByUsername&api_key=#{ENV['FLICKR_KEY']}&username=#{username}&format=json&nojsoncallback=1").read
        result = JSON.parse(nsid_req)
        nsid = result['user']['nsid']
        photos_req = open("https://api.flickr.com/services/rest/?method=flickr.people.getPublicPhotos&api_key=#{ENV['FLICKR_KEY']}&user_id=#{nsid}&format=json&nojsoncallback=1").read
        response = JSON.parse(photos_req)

        return m.reply 'nada' if response['photos']['photo'].size == 0

        photo_title = response['photos']['photo'].first['title']
        photo_id = response['photos']['photo'].first['id']

        m.reply "https://www.flickr.com/photos/#{nsid}/#{photo_id}/"
      end

      def help(m)
        m.reply 'returns most recent flickr pic of specified user'
      end

    end
  end
end
{'fraction_non_alphanumeric': 0.1690312119983786, 'fraction_numerical': 0.0024321037697608433, 'mean_word_length': 3.471014492753623, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 6, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '76321', 'n_tokens_mistral': 837, 'n_tokens_neox': 789, 'n_words': 136}