-
Notifications
You must be signed in to change notification settings - Fork 3
/
bot.rb
65 lines (54 loc) · 1.48 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
# -*- coding: utf-8 -*-
require 'rubygems'
require 'bundler/setup'
require 'yaml'
require 'cinch'
require 'cinch-logger-canonical'
require 'cinch-calculate'
require 'cinch-convert'
require 'cinch-dicebag'
require 'cinch-karma'
require 'cinch-logsearch'
require 'cinch-magic'
require 'cinch-notes'
require 'cinch-seen'
require 'cinch-links-logger'
require 'cinch-links-titles'
require 'cinch-twitterstatus'
require 'cinch-weatherman'
require 'cinch-urbandict'
require 'cinch-wikipedia'
# Load the bot config
conf = YAML::load(File.open('config/bot.yml'))
# Init Bot
@bot = Cinch::Bot.new do
configure do |c|
# Base Config
c.nick = conf[:nick]
c.server = conf[:server]
c.channels = conf[:chans].map { |chan| "##{chan}" }
c.max_messages = 1
c.port = conf[:port] if conf.key?(:port)
# Plugins
c.plugins.prefix = '.'
c.plugins.plugins = Cinch::Plugins.constants.map { |c| Class.module_eval("Cinch::Plugins::#{c}") }
# Link logger config
if conf.key?(:links)
c.plugins.options[Cinch::Plugins::LinksLogger] = conf[:links]
end
if conf.key?(:links)
c.plugins.options[Cinch::Plugins::LinksTitles] = conf[:links]
end
# Twitter config
if conf.key?(:twitter)
c.plugins.options[Cinch::Plugins::TwitterStatus] = conf[:twitter]
end
end
end
# Loggers
if conf.key?(:logging)
conf[:logging].each do |channel|
@bot.loggers << Cinch::Logger::CanonicalLogger.new(channel, @bot)
end
end
@bot.start