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 / Configuration.rb
100644 58 lines (56 sloc) 1.517 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
49
50
51
52
53
54
55
56
57
58
require 'yaml'
 
class Configuration
  def initialize(ymlfile = "conf.yml")
    @document = YAML::parse(File.new(ymlfile))
  end
  def number_nodes
    @document.select("servers/*").size
  end
  def nick(index)
    @document.select("/servers/*/nick")[index].value
  end
  def ident(index)
    @document.select("/servers/*/ident")[index].value
  end
  def real(index)
    @document.select("/servers/*/real")[index].value
  end
  def ssl(index)
    @document.select("/servers/*/ssl")[index].value.to_i
  end
  def server(index)
    @document.select("/servers/*/server")[index].value
  end
  def port(index)
    @document.select("/servers/*/port")[index].value.to_i
  end
  def listener(index)
    @document.select("/servers/*/listener")[index].value
  end
  def version(index)
    @document.select("/servers/*/version")[index].value
  end
  def channels(index)
    channels = Array.new
    @document.select("/servers/*/channels")[index].value.each do |chan|
      channels << chan.value
    end
    channels
  end
def database_type
@document.select("/database/type")[0].value.to_sym
end
def username_password_database
username = @document.select("/database/username")[0].value
password = @document.select("/database/password")[0].value
database = @document.select("/database/database")[0].value
return username, password, database
end
  def admins(index)
    admins = Array.new
    @document.select("/servers/*/admins")[index].value.each do |admin|
      admins << admin.value
    end
    admins
  end
end