-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
main.rb
executable file
·86 lines (73 loc) · 2.16 KB
/
main.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
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'rubygems'
require 'bundler/setup'
Bundler.require(:default)
# Mainly for docker, makes the log output a lot more sane.
$stdout.sync = true
module YuukiBot
class << self
attr_reader :uploader, :launch_time
attr_accessor :crb
end
@launch_time = Time.now
require_relative 'modules/setup'
require_relative 'modules/version'
class CommandrbBot < CommandrbBot
def owner?(id)
if YuukiBot.config['master_owner'].to_i == id
true
else
Helper.owners.include?(id)
end
end
end
init_hash = YuukiBot.build_init
@crb = CommandrbBot.new(init_hash)
module_dirs = %w[owner helper logging misc mod statistics utility]
module_dirs.each do |dir|
Dir["modules/#{dir}/*.rb"].each do |r|
require_relative r
puts "Loaded: #{r}" if @config['verbose']
end
end
require_relative 'modules/custom'
puts 'Loaded custom commands!'
# Load Extra Commands if enabled.
if YuukiBot.config['extra_commands']
puts 'Loading: Extra commands...' if @config['verbose']
Dir['modules/extra/*.rb'].each do |r|
require_relative r
puts "Loaded: #{r}" if @config['verbose']
end
end
# Check if the key redis_password exists or is string literal 'nil'
# If so, set it!
redis_password = YuukiBot.config['redis_password']
orig_redis = if redis_password.nil? || (redis_password == 'nil')
Redis.new(
host: YuukiBot.config['redis_host'],
port: YuukiBot.config['redis_port']
)
else
Redis.new(
host: YuukiBot.config['redis_host'],
port: YuukiBot.config['redis_port'],
password: redis_password
)
end
REDIS = Redis::Namespace.new(
YuukiBot.config['redis_namespace'],
redis: orig_redis
)
puts '>> Initial loading succesful!! <<'
@uploader = Haste::Uploader.new(@config['hastebin_instance_url'])
if YuukiBot.config['use_pry']
@crb.bot.run(true)
require 'pry'
binding.pry
else
puts 'Connecting to Discord....'
@crb.bot.run
end
end