This repository has been archived by the owner on May 27, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.rb
105 lines (86 loc) · 3.05 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
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 = true)
unless skipwelcome
puts 'Welcome to SpamBeGone 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
config
end
def config
puts 'Alright! Config time.'
puts 'What would you like to configure?'
puts '[1] - Bot information (REQUIRED)'
puts '[2] - Connection information (REQUIRED)'
puts '[3] - Exit'
input = gets.chomp
configure('bot') if input == '1'
configure('server') if input == '2'
exit
end
def configure(section)
if section == 'bot'
puts 'Pick a nickname for the bot - REQUIRED'
@config['nickname'] = gets.chomp
puts 'What channels should the bot join on startup? this must be comma seperated with #s before the names. - Optional'
puts 'Hint! You can always invite the bot to your channel and it will join!'
@config['channels'] = gets.chomp
puts "What should be the bot's realname? This is shown in 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 'Bot Oper Username - Required'
puts 'The bot needs oper access to kill users, please put in the oper username'
@config['operusername'] = gets.chomp
puts 'Bot Oper Pass - Required'
puts 'The bot needs oper access to kill users, please put in the oper password'
@config['operpass'] = gets.chomp
puts 'It turns out you\'re done configuring bot settings!'
save
config
end
if section == 'server'
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)'
input = gets.chomp
@config['ssl'] = true?(input)
puts 'Done configuring server connection information!'
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 true?(obj)
obj.to_s == 'true'
end
end
jerry = Setup.new
jerry.welcome(false)