use strict; use warnings; use Xchat qw( :all ); my $name = 'Oink Script'; my $version = '0.4'; register($name, $version, 'Oink at the channel'); prnt("Loaded $name $version"); foreach ('Channel Message', 'Channel Msg Hilight') { hook_print($_, \&check_oink); } hook_command('oink', \&force_oink, { help_message => 'Usage: /oink [at] : Oink in the current context' }); sub check_oink { my ($first_word, $other_words) = split(/\s/, $_[0][1], 2); if (uc $first_word ne 'OINK') { return EAT_NONE; } my $userinfo = user_info($_[0][0]); if ($userinfo->{prefix} && $userinfo->{prefix} ne '+') { delaycommand("me oinks"); } else { hook_timer( 0, sub { prnt("No oink sent for peons"); return REMOVE; }); } if (find_context() == get_context()) { emit_print('Generic Message', '*INFO*', 'I am here to see the next line happen'); } return EAT_NONE; } sub force_oink { if ($_[1][1]) { command("me oinks at $_[1][1]"); } else { command("me oinks in ".get_info('channel')); } return EAT_XCHAT; } sub delaycommand { my $command = $_[0]; hook_timer( 0, sub { command($command); return REMOVE; } ); return EAT_NONE; }