Skip to content

Instantly share code, notes, and snippets.

@Caaz
Created December 30, 2015 19:02
Show Gist options
  • Save Caaz/1946e7df1de7a9f8d376 to your computer and use it in GitHub Desktop.
Save Caaz/1946e7df1de7a9f8d376 to your computer and use it in GitHub Desktop.
my %last = ();
for('Channel Message', 'Private Message to Dialog', 'Your Message') { hook_print($_,\&handle_text,{'data'=>[$_]}); }
for('Channel Msg Hilight','Channel Action','Join','Quit','Part') { hook_print($_,\&reset_last); }
sub reset_last {
my $where = get_info('channel');
delete $last{$where};
return EAT_NONE;
}
sub handle_text {
my ($event,$where,$nick,$msg) = ($_[1][0],get_info('channel'),@{$_[0]});
if(($last{$where}) && ($last{$where} eq $nick)) {
emit_print($event, "\cC20$nick\cO", $msg);
return EAT_ALL;
}
else { $last{$where} = $nick; return EAT_NONE; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment