Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use Xchat ':all';
- use warnings;
- use strict;
- Xchat::register('xHilight', '0.1', 'Script made for Tabibibles', &init);
- Xchat::hook_print('Channel Message', 'chanhook');
- Xchat::hook_print('Channel Action', 'actionhook');
- Xchat::hook_print('Channel Msg Hilight', 'chanmsghilight');
- Xchat::hook_print('Channel Action Hilight', 'chanacthilight');
- Xchat::hook_print('Private Action to Dialog', 'actionhook');
- Xchat::hook_print('Private Message to Dialog', 'pvt_hook');
- Xchat::hook_print('Notice', 'notchook');
- Xchat::hook_print('Part', 'parthook');
- Xchat::hook_print('Part with Reason', 'parthook');
- Xchat::hook_print('Join', 'join_chan');
- my %hilights;
- sub init {
- open my $fh, '<', (Xchat::get_info('xchatdir') . '/.xhilight');
- my $scope;
- while (<$fh>) {
- chomp;
- if (/^\[(.+?)\]$/) {
- my $result = $1;
- $result =~ s/\s+|\t+//g;
- $scope = $result;
- $hilights{$scope} = {};
- next;
- }
- m/^(.+?)=(.+?)$/ or next;
- $1 =~ s/\s+|\t+//g;
- $hilights{$scope}->{$1} = $2;
- }
- }
- sub chanhook {
- foreach my $key (keys(%hilights)) {
- $_[0][0] =~ s/\s|\t//g;
- if($_[0][0] eq $key) {
- my $format = $hilights{$key}{ChanMsg};
- return Xchat::EAT_NONE unless $format;
- $format =~ s/\%C/\x03/g;
- $format =~ s/\%B/\x02/g;
- $format =~ s/\%O/\x0f/g;
- if($_[0][2]) {
- $format =~ s/\%prefix\%/$_[0][2]/g;
- }
- else {
- $format =~ s/\%prefix\%//g;
- }
- $format =~ s/\%nick\%/$key/g;
- $format =~ s/\%div\%/\t/g;
- $format =~ s/\%message\%/$_[0][1]/g;
- Xchat::print( $format );
- return Xchat::EAT_ALL;
- }
- }
- }
- sub actionhook {
- foreach my $key (keys(%hilights)) {
- $_[0][0] =~ s/\s|\t//g;
- if($_[0][0] eq $key) {
- my $format = $hilights{$key}{Action};
- return Xchat::EAT_NONE unless $format;
- $format =~ s/\%C/\x03/g;
- $format =~ s/\%B/\x02/g;
- if($_[0][2]) {
- $format =~ s/\%prefix\%/$_[0][2]/g;
- }
- else {
- $format =~ s/\%prefix\%//g;
- }
- $format =~ s/\%nick\%/$key/g;
- $format =~ s/\%div\%/\t/g;
- $format =~ s/\%message\%/$_[0][1]/g;
- Xchat::print( $format );
- return Xchat::EAT_ALL;
- }
- }
- }
- sub pvt_hook {
- foreach my $key (keys(%hilights)) {
- $_[0][0] =~ s/\s|\t//g;
- if($_[0][0] eq $key) {
- my $format = $hilights{$key}{PvtMsg};
- return Xchat::EAT_NONE unless $format;
- $format =~ s/\%C/\x03/g;
- $format =~ s/\%B/\x02/g;
- $format =~ s/\%O/\x0f/g;
- $format =~ s/\%nick\%/$key/g;
- $format =~ s/\%div\%/\t/g;
- $format =~ s/\%message\%/$_[0][1]/g;
- Xchat::print( $format );
- return Xchat::EAT_ALL;
- }
- }
- }
- sub notchook {
- foreach my $key (keys(%hilights)) {
- $_[0][0] =~ s/\s|\t//g;
- if($_[0][0] eq $key) {
- my $format = $hilights{$key}{Notice};
- return Xchat::EAT_NONE unless $format;
- $format =~ s/\%C/\x03/g;
- $format =~ s/\%B/\x02/g;
- $format =~ s/\%O/\x0f/g;
- $format =~ s/\%nick\%/$key/g;
- $format =~ s/\%div\%/\t/g;
- $format =~ s/\%message\%/$_[0][1]/g;
- Xchat::print( $format );
- return Xchat::EAT_ALL;
- }
- }
- }
- sub parthook {
- foreach my $key (keys(%hilights)) {
- $_[0][0] =~ s/\s|\t//g;
- if($_[0][0] eq $key) {
- my $format = $hilights{$key}{ChanPart};
- return Xchat::EAT_NONE unless $format;
- $format =~ s/\%C/\x03/g;
- $format =~ s/\%B/\x02/g;
- $format =~ s/\%O/\x0f/g;
- $format =~ s/\%host\%/$_[0][1]/g;
- $format =~ s/\%nick\%/$key/g;
- $format =~ s/\%div\%/\t/g;
- $format =~ s/\%channel\%/$_[0][2]/g;
- defined($_[0][3]) ? $format =~ s/\%message\%/$_[0][3]/g : $format =~ s/\%message\%//g;
- Xchat::print( $format );
- return Xchat::EAT_ALL;
- }
- }
- }
- sub chanmsghilight {
- foreach my $key (keys(%hilights)) {
- $_[0][0] =~ s/\s|\t//g;
- if($_[0][0] eq $key) {
- my $format = $hilights{$key}{ChanMsgHilight};
- return Xchat::EAT_NONE unless $format;
- $format =~ s/\%C/\x03/g;
- $format =~ s/\%B/\x02/g;
- $format =~ s/\%O/\x0f/g;
- $format =~ s/\%message\%/$_[0][1]/g;
- $format =~ s/\%nick\%/$key/g;
- $format =~ s/\%div\%/\t/g;
- defined($_[0][2]) ? $format =~ s/\%prefix\%/$_[0][2]/g : $format =~ s/\%prefix\%//g;
- Xchat::print( $format );
- return Xchat::EAT_ALL;
- }
- }
- }
- sub chanacthilight {
- foreach my $key (keys(%hilights)) {
- $_[0][0] =~ s/\s|\t//g;
- if($_[0][0] eq $key) {
- my $format = $hilights{$key}{ChanActHilight};
- return Xchat::EAT_NONE unless $format;
- $format =~ s/\%C/\x03/g;
- $format =~ s/\%B/\x02/g;
- $format =~ s/\%O/\x0f/g;
- $format =~ s/\%message\%/$_[0][1]/g;
- $format =~ s/\%nick\%/$key/g;
- $format =~ s/\%div\%/\t/g;
- $format =~ s/\%channel\%/$_[0][2]/g;
- defined($_[0][2]) ? $format =~ s/\%prefix\%/$_[0][2]/g : $format =~ s/\%prefix\%//g;
- Xchat::print( $format );
- return Xchat::EAT_ALL;
- }
- }
- }
- sub join_chan {
- foreach my $key (keys(%hilights)) {
- $_[0][0] =~ s/\s|\t//g;
- if($_[0][0] eq $key) {
- my $format = $hilights{$key}{JoinChan};
- return Xchat::EAT_NONE unless $format;
- $format =~ s/\%C/\x03/g;
- $format =~ s/\%B/\x02/g;
- $format =~ s/\%O/\x0f/g;
- $format =~ s/\%host%/$_[0][2]/g;
- $format =~ s/\%nick\%/$key/g;
- $format =~ s/\%div\%/\t/g;
- $format =~ s/\%channel\%/$_[0][1]/g;
- Xchat::print( $format );
- return Xchat::EAT_ALL;
- }
- }
- }
- sub quit_msg {
- foreach my $key (keys(%hilights)) {
- $_[0][0] =~ s/\s|\t//g;
- if($_[0][0] eq $key) {
- my $format = $hilights{$key}{Quit};
- return Xchat::EAT_NONE unless $format;
- $format =~ s/\%C/\x03/g;
- $format =~ s/\%B/\x02/g;
- $format =~ s/\%O/\x0f/g;
- $format =~ s/\%host%/$_[0][2]/g;
- $format =~ s/\%nick\%/$key/g;
- $format =~ s/\%div\%/\t/g;
- $format =~ s/\%message\%/$_[0][1]/g;
- Xchat::print( $format );
- return Xchat::EAT_ALL;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement