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
/
bot.rb
92 lines (78 loc) · 2.31 KB
/
bot.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
# IdleRPG Bot
# Require Gems needed to run programs and plugins
require './requiregems.rb'
# Load config from file
begin
CONFIG = YAML.load_file('config.yaml')
rescue
puts 'Config file not found, this is fatal, running setup.'
`ruby setup.rb`
exit
end
# Require each plugin
Dir["#{File.dirname(__FILE__)}/plugins/*.rb"].each { |file| require file }
# Set up uptime.
STARTTIME = Time.now
# Pre-Config
botnick = if CONFIG['nickname'] == '' || CONFIG['nickname'].nil?
puts 'The bot doesn\'t have a nickname! Please set one'
exit
else
CONFIG['nickname'].to_s
end
botserver = if CONFIG['server'] == '' || CONFIG['server'].nil?
puts 'You did not configure a server for the bot to connect to. Please set one!'
exit
else
CONFIG['server'].to_s
end
botport = if CONFIG['port'].nil?
'6667'
else
CONFIG['port']
end
botuser = if CONFIG['username'].nil? || CONFIG['username'] == ''
CONFIG['nickname']
else
CONFIG['username']
end
botrealname = if CONFIG['realname'].nil? || CONFIG['realname'] == ''
'IdleRPG Bot - https://github.com/Chewbotcca/IdleRPG'
else
"#{CONFIG['realname']} - https://github.com/Chewbotcca/IdleRPG"
end
botssl = if CONFIG['ssl'].nil? || CONFIG['ssl'] == '' || CONFIG['ssl'] == 'false'
nil
else
'true'
end
botserverpass = if CONFIG['serverpass'].nil? || CONFIG['serverpass'] == ''
nil
else
CONFIG['serverpass']
end
botprefix = if CONFIG['prefix'].nil? || CONFIG['prefix'] == ''
/!/
else
Regexp.new CONFIG['prefix']
end
# Configure the Bot
bot = Cinch::Bot.new do
configure do |c|
# Bot Settings, Taken from pre-config
c.nick = botnick
c.server = botserver
c.channels = [CONFIG['channels']]
c.port = botport
c.user = botuser
c.realname = botrealname
c.messages_per_second = 20
c.ssl.use = botssl
c.password = botserverpass
c.plugins.prefix = botprefix
# Load modules.
c.plugins.plugins = [Main, NickServ, Accounts]
end
end
# START THE BOT
bot.start