use strict; use warnings; sub notice_blitz { my ($args, $rests, $state) = @_; my $network = Xchat::get_info('network'); if (@$args < 3) { Xchat::print('Usage: BLITZ '); if (@$args >= 2) { splice @{$state->{recipes}}, $args->[1], 1; } foreach my $recipe (@{$state->{recipes}}) { Xchat::printf(' /%s/ (%s) %s', $recipe->[0], $recipe->[2], $recipe->[3]); } return Xchat::EAT_XCHAT; } push @{$state->{recipes}}, [ qr/$args->[1]/i, Xchat::get_context(), $network, $rests->[2] ]; return Xchat::EAT_XCHAT; } sub notice_notify_online { my ($args, $state) = @_; my ($nick, $server, $network) = @$args; foreach my $recipe (@{$state->{recipes}}) { if ($nick =~ $recipe->[0] && $network eq $recipe->[2]) { Xchat::set_context($recipe->[1]); my $command = $recipe->[3]; $command =~ s/\$nick\b/$nick/g; Xchat::command($command); } } return Xchat::EAT_NONE; } my $hook_options = { data => { recipes => [], }, }; Xchat::register('Blitzchat', '0.0.3', 'Try to catch flash-in-the-pan chatters'); Xchat::hook_command('blitz', \¬ice_blitz, $hook_options); Xchat::hook_print('Notify Online', \¬ice_notify_online, $hook_options);