-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgh.rb
61 lines (53 loc) · 1.78 KB
/
gh.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
require 'httparty'
Signal.trap("INT") do
puts "\nExiting gracefully..."
exit
end
def clr
puts "
╭━━━╮╱╱╱╱╱╱╱╱╱╱╱╱╱╭━━━┳╮
┃╭━━╯╱╱╱╱╱╱╱╱╱╱╱╱╱┃╭━━┫┃\e[34mGithub\e[32m
┃╰━━┳╮╭┳━┳━━┳━━┳━╮┃╰━━┫┃╭╮╱╭┳━╮╭━╮
┃╭━━┫┃┃┃╭┫╭╮┃╭╮┃╭╮┫╭━━┫┃┃┃╱┃┃╭╮┫╭╮╮
┃┃╱╱┃╰╯┃┃┃╰╯┃╰╯┃┃┃┃┃╱╱┃╰┫╰━╯┃┃┃┃┃┃┃
╰╯╱╱╰━━┻╯╰━╮┣━━┻╯╰┻╯╱╱╰━┻━╮╭┻╯╰┻╯╰╯
╱╱╱╱╱╱╱╱╱╱╱┃┃╱╱╱╱╱╱╱╱╱╱╱╭━╯┃\e[0mUsername
╱╱╱╱╱╱╱╱╱╱╱╰╯╱╱╱╱╱╱╱╱╱╱╱╰━━╯\e[33mChecker
\e[32m[+] Type \"cl\" to clear the screen\e[0m
"
end
def check_username(username)
response = HTTParty.get("https://github.com/#{username}", headers: { 'User-Agent' => 'Ruby' })
if response.code == 404
puts "\e[32mUsername \"#{username}\" is available.\e[0m"
ask_for_another_username
else
puts "\e[31mUsername \"#{username}\" is already taken.\e[0m"
ask_for_username
end
rescue HTTParty::ResponseError => e
puts "Error: #{e.message}"
ask_for_username
end
def ask_for_another_username
print 'Enter another username or type "exit" to quit: '
input = gets.chomp
if input.downcase == 'exit'
puts "Exiting..."
exit
else
check_username(input)
end
end
def ask_for_username
print 'Enter a GitHub username to check: '
input = gets.chomp
if input.downcase == 'cl'
system('clear') || system('cls')
ask_for_username
else
check_username(input)
end
end
clr
ask_for_username