This repository has been archived by the owner on Aug 15, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.rb
127 lines (105 loc) · 3.78 KB
/
setup.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
class Setup
def initialize
begin
require 'yaml'
rescue LoadError
puts 'YAML not found! Is your ruby ok?'
exit
end
unless File.exist?('config.yaml')
puts 'No config file! Creating one now..'
File.new('config.yaml', 'w+')
exconfig = YAML.load_file('config.example.yaml')
File.open('config.yaml', 'w') { |f| f.write exconfig.to_yaml }
end
@config = YAML.load_file('config.yaml')
exit if @config == false
end
def welcome(skipwelcome = false)
unless skipwelcome
puts 'Welcome to IdleRPG bot setup'
puts 'This really simple GUI will guide you in setting up the bot by yourself!'
puts 'Press enter to get started'
gets
end
puts 'What would you like to Configure (type number then press enter)'
puts '[1] - Configure the bot'
puts '[2] - Set up owner perms'
puts '[3] - Exit!'
input = gets.chomp
config if input == '1'
owner if input == '2'
exit
end
def config
puts 'Alright! Config time.'
puts 'What would you like to configure?'
puts '[1] - Bot information (REQUIRED)'
puts '[2] - Owner information'
puts '[3] - Main Menu'
input = gets.chomp
configure('bot') if input == '1'
configure('owner') if input == '2'
welcome
end
def configure(section)
if section == 'bot'
puts 'Pick a nickname for the bot - REQUIRED'
@config['nickname'] = gets.chomp
puts 'Enter the server address (hostname, IP, whatever, NO PORT yet) - REQUIRED '
@config['server'] = gets.chomp
puts 'Enter the server port, if you don\'t know, use 6667 - REQUIRED '
@config['port'] = gets.chomp
puts 'Connect using SSL? (true/false) - Leave blank for false.'
@config['ssl'] = gets.chomp
puts 'What channel should IdleRPG operate in? - REQUIRED'
@config['channels'] = gets.chomp
puts "What should be the bot's realname? This is shown on a whois. - Optional"
@config['realname'] = gets.chomp
puts 'What should be the bot\'s USERNAME (this is what\'s shown before the @ in a hostname. e.g. chew!THIS@blah) - Optional'
@config['username'] = gets.chomp
puts 'NickServ Password - Optional'
puts 'Not registered? THe bot has a built in nickserv registration process!'
@config['nickservpass'] = gets.chomp
puts 'It turns out you\'re done configuring bot settings!'
save
config
end
if section == 'owner'
puts 'Owner hostmask - Optional'
puts "If you don't know, this can be added later."
@config['ownerhost'] = gets.chomp
puts 'It turns out you\'re done configuring owner settings!'
save
config
end
end
def save
File.open('config.yaml', 'w') { |f| f.write @config.to_yaml }
rescue => e
puts 'uh oh, there was an error saving. Report the following error to Chew on github'
puts e
end
def owner
puts 'Your IRC Nickname. Please use your CURRENT nickname, you will need it for the next step'
@config['ownernick'] = gets.chomp
puts 'Do you plan to use bundler (ruby gem)? If you don\'t know what this is, assume no and say "false", Otherwise say "true"'
@config['bundler'] = gets.chomp
save
if @config['bundler'] == 'true'
puts 'Now, we will use bundler to install the gems! Please standby'
`bundle install`
puts 'All installed! Let\'s continue'
end
puts 'Now, we are going to make sure you have all of your gems. Press enter to install neccessary gems.'
require './requiregems.rb'
puts 'Now, a confirmation bot will join with the config you created and verify your identify. Hop on your irc client!'
if @config['bundler'] == 'true'
`ruby scripts/confirm.rb`
else
`bundle exec ruby scripts/confirm.rb`
end
end
end
jerry = Setup.new
jerry.welcome