-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathviby
executable file
·48 lines (40 loc) · 1.2 KB
/
viby
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
#!/usr/bin/env ruby
require 'bundler/setup'
require 'cinch'
require 'yaml'
ROOT = File.dirname(__FILE__)
plugins = []
configFile = File.join(ROOT, 'config.yml')
if File.exists? configFile
config = YAML.load_file(configFile)
else
raise "Config file not found"
end
Dir[File.join(ROOT, 'plugins', '*.cinch.plugin.rb')].each do |plugin|
begin
require plugin
name = File.basename(plugin).split('.').first
next if config.include?('bypassPlugin') && config['bypassPlugin'].include?(name)
klass = Kernel.const_get name
plugins << klass
rescue NameError
puts "Error trying to load #{plugin.inspect}. #{name} not found."
rescue
puts "Error trying to load #{plugin.inspect}. Tried to load #{name}."
end
end
bot = Cinch::Bot.new do
configure do |c|
c.nick = config['nick'] || 'viby'
c.server = config['server'] || 'localhost'
c.port = config['port'] || '6667'
c.channels = config['channels'] || ['#viby']
c.password = config['password']
c.ssl = Cinch::Configuration::SSL.new use: true if config['ssl']
for name, cplugin in config['plugin'] || []
c.plugins.options[Kernel.const_get name] = cplugin
end
c.plugins.plugins = plugins
end
end
bot.start