Advertisement
swarley

xHilight

Jan 31st, 2012
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.79 KB | None | 0 0
  1. use Xchat ':all';
  2. use warnings;
  3. use strict;
  4.  
  5. Xchat::register('xHilight', '0.1', 'Script made for Tabibibles', &init);
  6. Xchat::hook_print('Channel Message', 'chanhook');
  7. Xchat::hook_print('Channel Action', 'actionhook');
  8. Xchat::hook_print('
  9.  
  10. my %hilights;
  11.  
  12. sub init {
  13.    open my $fh, '<', (Xchat::get_info('xchatdir') . '/.xhilight');
  14.    my $scope;
  15.  
  16.    while (<$fh>) {
  17.        chomp;
  18.        if (/^\[(.+?)\]/) {
  19.         my $result = $1;
  20.            $result =~ s/\s+|\t+//g;
  21.            $scope = $result;
  22.            $hilights{$scope} = {};
  23.            next;
  24.        }
  25.        m/^(.+?)=(.+?)$/ or next;
  26.     $1 =~ s/\s+|\t+//g;
  27.        $hilights{$scope}->{$1} = $2;      
  28.    }
  29. }
  30.  
  31. sub chanhook {
  32.   foreach my $key (keys(%hilights)) {
  33.      $_[0][0] =~ s/\s|\t//g;
  34.      if($_[0][0] eq $key) {
  35.      my $format = $hilights{$key}{ChanMsg};
  36.      return Xchat::EAT_NONE unless $format;
  37.      $format =~ s/\%C/\x03/g;
  38.      $format =~ s/\%B/\x02/g;
  39.      $format =~ s/\%O/\x0f/g;
  40.      if($_[0][2]) {
  41.         $format =~ s/\%prefix\%/$_[0][2]/g;
  42.      }
  43.      else {
  44.         $format =~ s/\%prefix\%//g;    
  45.      }
  46.      $format =~ s/\%nick\%/$key/g;
  47.      $format =~ s/\%div\%/\t/g;
  48.      $format =~ s/\%message\%/$_[0][1]/g;
  49.      Xchat::print( $format );
  50.      return Xchat::EAT_ALL;
  51.      }
  52.   }
  53. }
  54.  
  55. sub actionhook {
  56.   foreach my $key (keys(%hilights)) {
  57.      $_[0][0] =~ s/\s|\t//g;
  58.      if($_[0][0] eq $key) {
  59.      my $format = $hilights{$key}{ChanAction};
  60.      return Xchat::EAT_NONE unless $format;
  61.      $format =~ s/\%C/\x03/g;
  62.      $format =~ s/\%B/\x02/g;
  63.      if($_[0][2]) {
  64.         $format =~ s/\%prefix\%/$_[0][2]/g;
  65.      }
  66.      else {
  67.         $format =~ s/\%prefix\%//g;    
  68.      }
  69.      $format =~ s/\%nick\%/$key/g;
  70.      $format =~ s/\%div\%/\t/g;
  71.      $format =~ s/\%message\%/$_[0][1]/g;
  72.      Xchat::print( $format );
  73.      return Xchat::EAT_ALL;
  74.      }
  75.   }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement