|
Revision 53, 0.8 kB
(checked in by bkuhn, 10 months ago)
|
- Added SFLC's internally developed tim bot released under AGPLv3
|
| Line | |
|---|
| 1 |
#!/usr/bin/perl |
|---|
| 2 |
use warnings; |
|---|
| 3 |
use strict; |
|---|
| 4 |
use Storable qw(retrieve nstore); |
|---|
| 5 |
use File::Copy qw( cp ); |
|---|
| 6 |
|
|---|
| 7 |
unless (-e "Infobot.storable") { |
|---|
| 8 |
die "I can't see Infobot.storable in ./\n"; |
|---|
| 9 |
} |
|---|
| 10 |
|
|---|
| 11 |
if (-e "Infobot.storable.backup") { |
|---|
| 12 |
die "There's already a backup of Infobot.storable in ./\n"; |
|---|
| 13 |
} |
|---|
| 14 |
|
|---|
| 15 |
cp("Infobot.storable", "Infobot.storable.backup") |
|---|
| 16 |
or die "Can't back up Infobot.storable: $!\n"; |
|---|
| 17 |
|
|---|
| 18 |
unless (-s "Infobot.storable" == -s "Infobot.storable.backup") { |
|---|
| 19 |
die "Infobot.storable backup isn't the same size!\n" |
|---|
| 20 |
} |
|---|
| 21 |
|
|---|
| 22 |
my $data = retrieve("Infobot.storable") |
|---|
| 23 |
or die "Can't load Infobot.storable for some reason\n"; |
|---|
| 24 |
|
|---|
| 25 |
my $new; |
|---|
| 26 |
warn "converting...\n"; |
|---|
| 27 |
for my $factoid (keys %{ $data->{infobot} }) { |
|---|
| 28 |
$new->{ "infobot_$factoid" } = delete $data->{infobot}{$factoid}; |
|---|
| 29 |
} |
|---|
| 30 |
|
|---|
| 31 |
nstore($new, "Infobot.storable"); |
|---|
| 32 |
warn "Saved new Infobot.storable\n"; |
|---|