<commit_before>#  -*- coding: utf-8 -*-
#  github_info.rb
#  Author: <NAME>
#  ------------------------
#  A Cinch plugin that gets information about a user from GitHub.
#  ------------------------
#  This code is licensed by <NAME> under the MIT License.
#  http://opensource.org/licenses/MIT

require 'json'
require 'open-uri'

require_relative 'yossarian_plugin'

class GitHubInfo < YossarianPlugin
	include Cinch::Plugin

	def usage
		'!gh <user> - Get information about <user> on GitHub. Alias: !github.'
	end

	def match?(cmd)
		cmd =~ /^(!)?(github)|(gh)$/
	end

	match /gh (\S+)/, method: :github_info, strip_colors: true
	match /github (\S+)/, method: :github_info, strip_colors: true

	def github_info(m, username)
		url = "https://api.github.com/users/#{URI.encode(username)}"

		begin
			hash = JSON.parse(open(url).read)

			if hash.has_key?('login')
				login = hash['login']
				name = hash['name'] || 'No name given'
				repos = hash['public_repos']
				followers = hash['followers']
				following = hash['following']
				m.reply "#{login} (#{name}) has #{repos} repositories, #{followers} followers, and is following #{following} people. See more at https://github.com/#{login}", true
			else
				m.reply "No such user \'#{username}\'.", true
			end
		rescue
			m.reply "No such user \'#{username}\' or possible network error.", true
		end
	end
end<commit_msg>make github_info error handling match others<commit_after>#  -*- coding: utf-8 -*-
#  github_info.rb
#  Author: <NAME>
#  ------------------------
#  A Cinch plugin that gets information about a user from GitHub.
#  ------------------------
#  This code is licensed by <NAME> under the MIT License.
#  http://opensource.org/licenses/MIT

require 'json'
require 'open-uri'

require_relative 'yossarian_plugin'

class GitHubInfo < YossarianPlugin
	include Cinch::Plugin

	def usage
		'!gh <user> - Get information about <user> on GitHub. Alias: !github.'
	end

	def match?(cmd)
		cmd =~ /^(!)?(github)|(gh)$/
	end

	match /gh (\S+)/, method: :github_info, strip_colors: true
	match /github (\S+)/, method: :github_info, strip_colors: true

	def github_info(m, username)
		url = "https://api.github.com/users/#{URI.encode(username)}"

		begin
			hash = JSON.parse(open(url).read)

			if hash.has_key?('login')
				login = hash['login']
				name = hash['name'] || 'No name given'
				repos = hash['public_repos']
				followers = hash['followers']
				following = hash['following']
				m.reply "#{login} (#{name}) has #{repos} repositories, #{followers} followers, and is following #{following} people. See more at https://github.com/#{login}", true
			else
				m.reply "No such user \'#{username}\'.", true
			end
		rescue Exception => e
			m.reply e.to_s, true
		end
	end
end
{'fraction_non_alphanumeric': 0.18661331393233904, 'fraction_numerical': 0.0007275372862859222, 'mean_word_length': 3.129129129129129, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 12, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, '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': '1422321', 'n_tokens_mistral': 1003, 'n_tokens_neox': 893, 'n_words': 267}