forked from kragen/kropotkin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkropotkin.rb
executable file
·49 lines (41 loc) · 1.19 KB
/
kropotkin.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
# encoding: utf-8
require 'yaml'
require 'cinch'
require './lib/humanize'
require './lib/url_title'
require './lib/empathy'
require './lib/invite'
require './lib/adhocracia'
require './lib/remember'
# Carga de la configuracion
config = YAML.load_file('config.yml')
instances = []
# Por cada red generar una instancia del cyborg
config['networks'].each do |n|
n[:bot] = Cinch::Bot.new do
configure do |c|
c.nick = config['nick']
c.user = config['nick']
c.password = n['password'] if n['password']
c.server = n['server']
c.port = n['port']
c.channels = n['channels']
c.ssl.use = n['ssl'] unless n['ssl'].nil?
c.plugins.plugins = [Empathy, UrlTitle, AcceptInvite, Adhocracia, Remember]
end
on :message, /\bbugs?\b/i do |m|
m.reply 'patches welcome', true
end
# Corregir
on :message, /open ?source/i do |m|
m.reply 'no querrás decir software libre?', true
end
on :message, /^[!,]\w+/ do |m|
m.reply ['a quién le habla?', 'hay un bot por acá? :O', '¬¬'].sample
end
end
# Correr cada instancia en un thread nuevo
instances << Thread.new { n[:bot].start }
end
# Esperar que terminen!
instances.each(&:join)