forked from mcginty/InternBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.rb
45 lines (39 loc) · 916 Bytes
/
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
require 'internbot'
require 'rubygems'
require 'sqlite3'
require 'trollop'
opts = Trollop::options do
version "InternBot 0.5.0 by Jake McGinty"
banner <<-EOS
InternBot is the bot that maintains both sanity and insanity in the #intern chatroom.
Usage:
ruby bot.rb [options]
where [options] are:
EOS
opt :createdb, "Initialize InternBot's SQLite db", :default => false
opt :db, "Location of SQLite3 db to use", :default => "ib.db"
end
# code time
if opts[:createdb]
db = SQLite3::Database.new(opts[:db])
sql = <<SQL
create table ops (
op_id INTEGER PRIMARY KEY,
nick TEXT,
host TEXT
);
create table voices (
voice_id INTEGER PRIMARY KEY,
nick TEXT,
host TEXT
);
create table bros (
bro_id INTEGER PRIMARY KEY,
bro TEXT
);
insert into ops (nick, host) values ( 'jakemc', 'jakemc' );
SQL
db.execute_batch(sql)
else
InternBot.start(opts[:db])
end