2 # Announce and Talk Handling routines
4 # Copyright (c) 2000 Dirk Koopman
16 use vars qw(%dup $duplth $dupage);
18 %dup = (); # the duplicates hash
19 $duplth = 60; # the length of text to use in the deduping
20 $dupage = 24*3600; # the length of time to hold spot dups
22 # enter the spot for dup checking and return true if it is already a dup
25 my ($call, $to, $text) = @_;
26 my $d = $main::systime / 60;
30 $text = substr($text, 0, $duplth) if length $text > $duplth;
31 my $dupkey = "$call|$to|$text";
32 return 1 if exists $dup{$dupkey};
33 $dup{$dupkey} = $d * 60; # in seconds (to the nearest minute)
37 # called every hour and cleans out the dup cache
40 my $cutoff = $main::systime - $dupage;
41 while (my ($key, $val) = each %dup) {
42 delete $dup{$key} if $val < $cutoff;
49 for (sort { $dup{$a} <=> $dup{$b} } keys %dup) {
51 push @out, "$_ = $val (" . cldatetime($val) . ")";