-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.rb
46 lines (34 loc) · 942 Bytes
/
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
# How to set up:
# $ bundle install --path vendor/bundle
# $ bundle exec ruby bot.rb
require 'rubygems'
require 'cinch'
require 'yaml'
class ConfigLoader
include Cinch::Plugin
match 'reload_config'
def execute(m)
log "Reloading configuration - Triggered by #{m.user.nick}"
ConfigLoader.load
m.reply "#{m.user.nick}: Konfiguration wurde geladen"
end
def self.load
$config = YAML.load open(File.dirname(__FILE__) + '/config.yml').read
end
end
require_relative 'plugin_loader'
ConfigLoader.load
#
bot = Cinch::Bot.new do
configure do |conf|
descr = $config['bot']
conf.realname = descr['realname']
conf.nick = descr['nick']
conf.port = descr['port'].to_i if descr['port']
conf.ssl = true if %w(true yes).include? descr['ssl']
conf.server = descr['server']
conf.channels = descr['channels']
conf.plugins.plugins = PluginLoader.load_all
end
end
bot.start