]> git.donarmstrong.com Git - infobot.git/blob - scripts/insertDB.pl
1206414f4fb904726e52586357fbb8310e09bf8f
[infobot.git] / scripts / insertDB.pl
1 #!/usr/bin/perl -w
2
3 $| = 1;
4
5 use strict;
6
7 require "src/core.pl";
8 require "src/logger.pl";
9 require "src/modules.pl";
10 require "src/Factoids/DBCommon.pl";
11
12 &loadConfig( $bot_config_dir . "/infobot.config" );
13 &loadDBModules();
14
15 unless (@_) {
16     print "hrm.. usage\n";
17     exit 0;
18 }
19
20 foreach (@_) {
21     next unless ( -f $_ );
22
23     open( IN, $_ ) or die "error: cannot open $_\n";
24     print "Opened $_ for input...\n";
25
26     print "inserting... ";
27     while (<IN>) {
28         next unless (/^(.*?) => (.*)$/);
29
30         ### TODO: check if it already exists. if so, don't add.
31         &setFactInfo( $1, "factoid_value", $2 );
32         print ":: $1 ";
33     }
34
35     close IN;
36 }
37
38 # vim:ts=4:sw=4:expandtab:tw=80