From 31ae34e17efd2333d65085a014a5cf310790d03d Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Sun, 15 Aug 2021 19:44:21 -0700 Subject: [PATCH] Remove obsolete generate_undos.pl script --- data/generate_undos.pl | 63 ------------------------------------------ 1 file changed, 63 deletions(-) delete mode 100755 data/generate_undos.pl diff --git a/data/generate_undos.pl b/data/generate_undos.pl deleted file mode 100755 index df2b5d0b..00000000 --- a/data/generate_undos.pl +++ /dev/null @@ -1,63 +0,0 @@ -#!/usr/bin/env perl - -# generate initial .undo file for existing factoids -# FIXME all paths throughout this file are hardcoded... - -use warnings; -use strict; - -use Storable; - -require "../PBot/DualIndexHashObject.pm"; - - -sub safe_filename { - my $name = shift; - my $safe = ''; - - while ($name =~ m/(.)/gms) { - if ($1 eq '&') { - $safe .= '&'; - } elsif ($1 eq '/') { - $safe .= '&fslash;'; - } else { - $safe .= $1; - } - } - - return $safe; -} - - -my $factoids = PBot::DualIndexHashObject->new(name => 'Factoids', filename => 'factoids'); - -$factoids->load; - -foreach my $channel (sort keys %{ $factoids->hash }) { - foreach my $trigger (sort keys %{ $factoids->hash->{$channel} }) { - my $channel_path = $channel; - $channel_path = 'global' if $channel_path eq '.*'; - - print "Checking [$channel_path] [$trigger] ... "; - - my $channel_path_encoded = safe_filename $channel_path; - my $trigger_encoded = safe_filename $trigger; - - my $undo = eval { retrieve("factlog/$trigger_encoded.$channel_path_encoded.undo"); }; - - if (not $undo) { - print "creating initial undo state to [$channel_path_encoded] [$trigger_encoded]\n"; - $undo = { idx => 0, list => [ $factoids->hash->{$channel}->{$trigger} ] }; - eval { - store($undo, "factlog/$trigger_encoded.$channel_path_encoded.undo"); - }; - if ($@) { - print "error: $@\n"; - } - } else { - print "good.\n"; - } - } -} - -print "Done.\n";