Advertisement
swarley

xHilight.pl

Jan 30th, 2012
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.03 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.  
  8. my %hilights;
  9.  
  10. sub init {
  11.    Xchat::print('K');
  12.     open my $fh, '<', (Xchat::get_info('xchatdir') . '/.xhilight');
  13.     my $scope;
  14.  
  15.     while (<$fh>) {
  16.         chomp;
  17.         if (/^\[(.+?)\]/) {
  18.         my $result = $1;
  19.             $result =~ s/\s+|\t+//g;
  20.             $scope = $result;
  21.             $hilights{$scope} = {};
  22.             next;
  23.         }
  24.         m/^(.+?)=(.+?)$/ or next;
  25.     $1 =~ s/\s+|\t+//g;
  26.         $hilights{$scope}->{$1} = $2;      
  27.     }
  28. }
  29. sub chanhook {
  30.    foreach my $key (keys(%hilights)) {
  31.       $_[0][0] =~ s/\s|\t//g;
  32.       if($_[0][0] eq $key) {
  33.      Xchat::print(keys(%{$hilights{$key}}));
  34.      my $format = $hilights{$key}{CHANNEL};
  35.      $format =~ s/\%C/\x03/g;
  36.      $format =~ s/\%prefix\%/$_[0][2]/g;
  37.      $format =~ s/\%nick\%/$key/g;
  38.      $format =~ s/\%div\%/\t/g;
  39.      $format =~ s/\%message\%/$_[0][1]/g;
  40.      Xchat::print( $format );
  41.      return Xchat::EAT_ALL;
  42.       }
  43.    }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement