5 my ($state, $map, $pro, $total, $who) = @_;
6 open my $fh, '>>', "$ENV{HOME}/.nexuiz/__votelog.$config{irc_nick}.txt"
7 or die "votelog open: $!";
8 print $fh "@{[time()]} $config{irc_nick} $state $map $pro $total" . (defined $who ? " $who" : "") . "\n";
13 [ dp => q{\001(.*?)\^7: d} => sub {
14 my $aoltime = time() - 746748000;
15 my $day = int($aoltime / 86400);
16 my $wday = [qw[Tue Wed Thu Fri Sat Sun Mon]]->[$day % 7];
17 my $hour = int($aoltime / 3600) % 24;
18 my $minute = int($aoltime / 60) % 60;
19 my $second = int($aoltime / 1) % 60;
20 out dp => 0, sprintf 'rcon2irc_say_as "AOL service" "The time is %3s Sep %2d %02d:%02d:%02d 1993"',
21 $wday, $day, $hour, $minute, $second;
26 [ dp => q{:vote:suggestion_accepted:(.*)} => sub {
28 markmap suggestion_accepted => $map, $store{rbi_winvotes}, $store{rbi_totalvotes};
31 [ dp => q{:vote:suggested:(.*?):\d+:(.*)} => sub {
33 markmap suggested => $map, 1, 1, $who;
36 [ dp => q{\001\^2\* .*'s vote for \^1gotomap (.*)\^2 was accepted} => sub {
38 markmap voted => $map, 1, 1;
41 [ dp => q{\001\^2\* .*'s vote for \^1timelimit -1\^2 was accepted} => sub {
42 markmap cancelled => $store{map}, 1, 1;
45 [ dp => q{:vote:(keeptwo|finished):(.*)} => sub {
46 my ($status, $result) = @_;
47 my @result = split /:/, $result;
52 $cutoff = $_ if $result[2*$_] eq '';
53 $totalvotes += int($result[2*$_+1] || 0);
54 [$result[2*$_], int($result[2*$_+1] || 0)]
56 die "Invalid vote result: $result" unless $cutoff >= 0;
57 my @winners = @allmaps[0..($cutoff-1)];
58 my @losers = @allmaps[($cutoff+1)..(@allmaps-1)];
60 $winvotes += $_->[1] for @winners;
61 if($status eq 'keeptwo')
63 markmap irrelevant_relative => $_->[0], $winvotes, $totalvotes
66 elsif($status eq 'finished')
68 markmap((@losers == 1 ? 'duel_winner' : 'winner_absolute') => $_->[0], $_->[1], $totalvotes)
70 markmap((@losers == 1 ? 'duel_loser' : 'irrelevant_absolute') => $_->[0], $winvotes, $totalvotes)
73 $store{rbi_winvotes} = $winvotes;
74 $store{rbi_totalvotes} = $totalvotes;
77 [ dp => q{pure: -(\S+) (.*)} => sub {
78 my ($status, $nick) = @_;
79 $nick = color_dp2irc $nick;
80 out irc => 0, "PRIVMSG $config{irc_channel} :\001ACTION thinks $nick is $status\001";
83 [ dp => q{:recordset:(\d+):.*} => sub {
85 my $ip = $store{"playerip_$id"};
86 my $slot = $store{"playerslot_$id"};
87 my $name = $config{irc_nick};
88 $name =~ s/Nex//; # haggerNexCTF -> haggerCTF
90 my $pattern = "/nexuiz/data/home/.nexuiz/extramaps-$name/sv_autodemos/????-??-??_??-??_$store{map}_${slot}_$ip-*.dem";
91 if(my @result = glob $pattern)
93 print "Cleaning up demos: protecting $result[0]\n";
98 print "Record set but could not find the demo.\n";
102 # delete demos at the end of the match
103 [ dp => q{:end} => sub {
104 my $name = $config{irc_nick};
105 $name =~ s/Nex//; # haggerNexCTF -> haggerCTF
106 my $pattern = "/nexuiz/data/home/.nexuiz/extramaps-$name/sv_autodemos/*.dem";
109 next if not -w $_; # protected demo (by record, or other markers)
110 next if -M $_ > 0.1; # not old enough yet
111 print "Cleaning up demos: deleting $_\n";