File: insertDB.pl

package info (click to toggle)
blootbot 1.2.0-6.3
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 1,368 kB
  • ctags: 603
  • sloc: perl: 16,607; sh: 147; makefile: 54; sql: 47
file content (36 lines) | stat: -rw-r--r-- 627 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/perl -w

$| = 1;

use strict;

require "src/core.pl";
require "src/logger.pl";
require "src/modules.pl";
require "src/Factoids/DBCommon.pl";

&loadConfig($bot_config_dir."/blootbot.config");
&loadDBModules();

unless (@_) {
    print "hrm.. usage\n";
    exit 0;
}

foreach (@_) {
    next unless ( -f $_);

    open(IN, $_) or die "error: cannot open $_\n";
    print "Opened $_ for input...\n";

    print "inserting... ";
    while (<IN>) {
	next unless (/^(.*?) => (.*)$/);

	### TODO: check if it already exists. if so, don't add.
	&setFactInfo($1, "factoid_value", $2);
	print ":: $1 ";
    }

    close IN;
}