public
Description: An IRC bot that keeps track of who is who and makes links between users.
Homepage:
Clone URL: git://github.com/seadog/ybttre.git
Click here to lend your support to: ybttre and make a donation at www.pledgie.com !
ybttre / main.rb
100755 48 lines (41 sloc) 1.223 kb
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/ruby -w
 
#outside requirements
require 'thread'
 
#our files
require 'Configuration.rb'
require 'Bot.rb'
require 'Database.rb'
 
config = Configuration.new
bots = Array.new
threads = Array.new
db_type = config.database_type
username, password, database = config.username_password_database
database = Database.new(username, password, database, db_type) #these only work on my localhost!
 
config.number_nodes.times do |i|
  bot = Bot.new(database)
  bot.nick = config.nick(i) if !config.nick(i).nil?
  bot.ident = config.ident(i) if !config.ident(i).nil?
  bot.real = config.real(i) if !config.real(i).nil?
  bot.server = config.server(i) if !config.server(i).nil?
  bot.ssl = config.ssl(i) if !config.ssl(i).nil?
  bot.port = config.port(i) if !config.port(i).nil?
  bot.listener = config.listener(i) if !config.listener(i).nil?
  bot.channels = config.channels(i) #next two can never be nil
  bot.admins = config.admins(i)
  bots << bot
end
 
bots.each do |bot|
  threads << Thread.new do
    while 1
      begin
        bot.connect
      rescue Exception => e
        puts e
      end
      sleep 60
    end
end
end
 
threads.each do |thread|
  thread.join
end