SHOW:
|
|
- or go back to the newest paste.
| 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('
|
| 8 | + | Xchat::hook_print('Channel Msg Hilight', 'chanmsghilight');
|
| 9 | Xchat::hook_print('Channel Action Hilight', 'chanacthilight');
| |
| 10 | Xchat::hook_print('Private Action to Dialog', 'actionhook');
| |
| 11 | Xchat::hook_print('Private Message to Dialog', 'pvt_hook');
| |
| 12 | Xchat::hook_print('Notice', 'notchook');
| |
| 13 | - | open my $fh, '<', (Xchat::get_info('xchatdir') . '/.xhilight');
|
| 13 | + | Xchat::hook_print('Part', 'parthook');
|
| 14 | - | my $scope; |
| 14 | + | Xchat::hook_print('Part with Reason', 'parthook');
|
| 15 | Xchat::hook_print('Join', 'join_chan');
| |
| 16 | - | while (<$fh>) {
|
| 16 | + | |
| 17 | - | chomp; |
| 17 | + | |
| 18 | - | if (/^\[(.+?)\]/) {
|
| 18 | + | |
| 19 | - | my $result = $1; |
| 19 | + | open my $fh, '<', (Xchat::get_info('xchatdir') . '/.xhilight');
|
| 20 | - | $result =~ s/\s+|\t+//g; |
| 20 | + | my $scope; |
| 21 | - | $scope = $result; |
| 21 | + | |
| 22 | - | $hilights{$scope} = {};
|
| 22 | + | while (<$fh>) {
|
| 23 | - | next; |
| 23 | + | chomp; |
| 24 | - | } |
| 24 | + | if (/^\[(.+?)\]$/) {
|
| 25 | - | m/^(.+?)=(.+?)$/ or next; |
| 25 | + | my $result = $1; |
| 26 | - | $1 =~ s/\s+|\t+//g; |
| 26 | + | $result =~ s/\s+|\t+//g; |
| 27 | - | $hilights{$scope}->{$1} = $2;
|
| 27 | + | $scope = $result; |
| 28 | $hilights{$scope} = {};
| |
| 29 | next; | |
| 30 | } | |
| 31 | m/^(.+?)=(.+?)$/ or next; | |
| 32 | - | foreach my $key (keys(%hilights)) {
|
| 32 | + | $1 =~ s/\s+|\t+//g; |
| 33 | - | $_[0][0] =~ s/\s|\t//g; |
| 33 | + | $hilights{$scope}->{$1} = $2;
|
| 34 | - | if($_[0][0] eq $key) {
|
| 34 | + | } |
| 35 | - | my $format = $hilights{$key}{ChanMsg};
|
| 35 | + | |
| 36 | - | return Xchat::EAT_NONE unless $format; |
| 36 | + | |
| 37 | - | $format =~ s/\%C/\x03/g; |
| 37 | + | |
| 38 | - | $format =~ s/\%B/\x02/g; |
| 38 | + | foreach my $key (keys(%hilights)) {
|
| 39 | - | $format =~ s/\%O/\x0f/g; |
| 39 | + | $_[0][0] =~ s/\s|\t//g; |
| 40 | - | if($_[0][2]) {
|
| 40 | + | if($_[0][0] eq $key) {
|
| 41 | - | $format =~ s/\%prefix\%/$_[0][2]/g; |
| 41 | + | my $format = $hilights{$key}{ChanMsg};
|
| 42 | - | } |
| 42 | + | return Xchat::EAT_NONE unless $format; |
| 43 | - | else {
|
| 43 | + | $format =~ s/\%C/\x03/g; |
| 44 | - | $format =~ s/\%prefix\%//g; |
| 44 | + | $format =~ s/\%B/\x02/g; |
| 45 | - | } |
| 45 | + | $format =~ s/\%O/\x0f/g; |
| 46 | - | $format =~ s/\%nick\%/$key/g; |
| 46 | + | if($_[0][2]) {
|
| 47 | - | $format =~ s/\%div\%/\t/g; |
| 47 | + | $format =~ s/\%prefix\%/$_[0][2]/g; |
| 48 | - | $format =~ s/\%message\%/$_[0][1]/g; |
| 48 | + | } |
| 49 | - | Xchat::print( $format ); |
| 49 | + | else {
|
| 50 | - | return Xchat::EAT_ALL; |
| 50 | + | $format =~ s/\%prefix\%//g; |
| 51 | } | |
| 52 | - | } |
| 52 | + | $format =~ s/\%nick\%/$key/g; |
| 53 | $format =~ s/\%div\%/\t/g; | |
| 54 | $format =~ s/\%message\%/$_[0][1]/g; | |
| 55 | Xchat::print( $format ); | |
| 56 | - | foreach my $key (keys(%hilights)) {
|
| 56 | + | return Xchat::EAT_ALL; |
| 57 | - | $_[0][0] =~ s/\s|\t//g; |
| 57 | + | |
| 58 | - | if($_[0][0] eq $key) {
|
| 58 | + | } |
| 59 | - | my $format = $hilights{$key}{ChanAction};
|
| 59 | + | |
| 60 | - | return Xchat::EAT_NONE unless $format; |
| 60 | + | |
| 61 | - | $format =~ s/\%C/\x03/g; |
| 61 | + | |
| 62 | - | $format =~ s/\%B/\x02/g; |
| 62 | + | foreach my $key (keys(%hilights)) {
|
| 63 | - | if($_[0][2]) {
|
| 63 | + | $_[0][0] =~ s/\s|\t//g; |
| 64 | - | $format =~ s/\%prefix\%/$_[0][2]/g; |
| 64 | + | if($_[0][0] eq $key) {
|
| 65 | - | } |
| 65 | + | my $format = $hilights{$key}{Action};
|
| 66 | - | else {
|
| 66 | + | return Xchat::EAT_NONE unless $format; |
| 67 | - | $format =~ s/\%prefix\%//g; |
| 67 | + | $format =~ s/\%C/\x03/g; |
| 68 | - | } |
| 68 | + | $format =~ s/\%B/\x02/g; |
| 69 | - | $format =~ s/\%nick\%/$key/g; |
| 69 | + | if($_[0][2]) {
|
| 70 | - | $format =~ s/\%div\%/\t/g; |
| 70 | + | $format =~ s/\%prefix\%/$_[0][2]/g; |
| 71 | - | $format =~ s/\%message\%/$_[0][1]/g; |
| 71 | + | } |
| 72 | - | Xchat::print( $format ); |
| 72 | + | else {
|
| 73 | - | return Xchat::EAT_ALL; |
| 73 | + | $format =~ s/\%prefix\%//g; |
| 74 | } | |
| 75 | - | } |
| 75 | + | $format =~ s/\%nick\%/$key/g; |
| 76 | $format =~ s/\%div\%/\t/g; | |
| 77 | $format =~ s/\%message\%/$_[0][1]/g; | |
| 78 | Xchat::print( $format ); | |
| 79 | return Xchat::EAT_ALL; | |
| 80 | } | |
| 81 | } | |
| 82 | } | |
| 83 | sub pvt_hook {
| |
| 84 | foreach my $key (keys(%hilights)) {
| |
| 85 | $_[0][0] =~ s/\s|\t//g; | |
| 86 | if($_[0][0] eq $key) {
| |
| 87 | my $format = $hilights{$key}{PvtMsg};
| |
| 88 | return Xchat::EAT_NONE unless $format; | |
| 89 | $format =~ s/\%C/\x03/g; | |
| 90 | $format =~ s/\%B/\x02/g; | |
| 91 | $format =~ s/\%O/\x0f/g; | |
| 92 | $format =~ s/\%nick\%/$key/g; | |
| 93 | $format =~ s/\%div\%/\t/g; | |
| 94 | $format =~ s/\%message\%/$_[0][1]/g; | |
| 95 | Xchat::print( $format ); | |
| 96 | return Xchat::EAT_ALL; | |
| 97 | } | |
| 98 | } | |
| 99 | } | |
| 100 | ||
| 101 | sub notchook {
| |
| 102 | foreach my $key (keys(%hilights)) {
| |
| 103 | $_[0][0] =~ s/\s|\t//g; | |
| 104 | if($_[0][0] eq $key) {
| |
| 105 | my $format = $hilights{$key}{Notice};
| |
| 106 | return Xchat::EAT_NONE unless $format; | |
| 107 | $format =~ s/\%C/\x03/g; | |
| 108 | $format =~ s/\%B/\x02/g; | |
| 109 | $format =~ s/\%O/\x0f/g; | |
| 110 | $format =~ s/\%nick\%/$key/g; | |
| 111 | $format =~ s/\%div\%/\t/g; | |
| 112 | $format =~ s/\%message\%/$_[0][1]/g; | |
| 113 | Xchat::print( $format ); | |
| 114 | return Xchat::EAT_ALL; | |
| 115 | } | |
| 116 | } | |
| 117 | } | |
| 118 | ||
| 119 | sub parthook {
| |
| 120 | foreach my $key (keys(%hilights)) {
| |
| 121 | $_[0][0] =~ s/\s|\t//g; | |
| 122 | if($_[0][0] eq $key) {
| |
| 123 | my $format = $hilights{$key}{ChanPart};
| |
| 124 | return Xchat::EAT_NONE unless $format; | |
| 125 | $format =~ s/\%C/\x03/g; | |
| 126 | $format =~ s/\%B/\x02/g; | |
| 127 | $format =~ s/\%O/\x0f/g; | |
| 128 | $format =~ s/\%host\%/$_[0][1]/g; | |
| 129 | $format =~ s/\%nick\%/$key/g; | |
| 130 | $format =~ s/\%div\%/\t/g; | |
| 131 | $format =~ s/\%channel\%/$_[0][2]/g; | |
| 132 | defined($_[0][3]) ? $format =~ s/\%message\%/$_[0][3]/g : $format =~ s/\%message\%//g; | |
| 133 | Xchat::print( $format ); | |
| 134 | return Xchat::EAT_ALL; | |
| 135 | } | |
| 136 | } | |
| 137 | } | |
| 138 | ||
| 139 | sub chanmsghilight {
| |
| 140 | foreach my $key (keys(%hilights)) {
| |
| 141 | $_[0][0] =~ s/\s|\t//g; | |
| 142 | if($_[0][0] eq $key) {
| |
| 143 | my $format = $hilights{$key}{ChanMsgHilight};
| |
| 144 | return Xchat::EAT_NONE unless $format; | |
| 145 | $format =~ s/\%C/\x03/g; | |
| 146 | $format =~ s/\%B/\x02/g; | |
| 147 | $format =~ s/\%O/\x0f/g; | |
| 148 | $format =~ s/\%message\%/$_[0][1]/g; | |
| 149 | $format =~ s/\%nick\%/$key/g; | |
| 150 | $format =~ s/\%div\%/\t/g; | |
| 151 | defined($_[0][2]) ? $format =~ s/\%prefix\%/$_[0][2]/g : $format =~ s/\%prefix\%//g; | |
| 152 | Xchat::print( $format ); | |
| 153 | return Xchat::EAT_ALL; | |
| 154 | } | |
| 155 | } | |
| 156 | } | |
| 157 | ||
| 158 | sub chanacthilight {
| |
| 159 | foreach my $key (keys(%hilights)) {
| |
| 160 | $_[0][0] =~ s/\s|\t//g; | |
| 161 | if($_[0][0] eq $key) {
| |
| 162 | my $format = $hilights{$key}{ChanActHilight};
| |
| 163 | return Xchat::EAT_NONE unless $format; | |
| 164 | $format =~ s/\%C/\x03/g; | |
| 165 | $format =~ s/\%B/\x02/g; | |
| 166 | $format =~ s/\%O/\x0f/g; | |
| 167 | $format =~ s/\%message\%/$_[0][1]/g; | |
| 168 | $format =~ s/\%nick\%/$key/g; | |
| 169 | $format =~ s/\%div\%/\t/g; | |
| 170 | $format =~ s/\%channel\%/$_[0][2]/g; | |
| 171 | defined($_[0][2]) ? $format =~ s/\%prefix\%/$_[0][2]/g : $format =~ s/\%prefix\%//g; | |
| 172 | Xchat::print( $format ); | |
| 173 | return Xchat::EAT_ALL; | |
| 174 | } | |
| 175 | } | |
| 176 | } | |
| 177 | ||
| 178 | sub join_chan {
| |
| 179 | foreach my $key (keys(%hilights)) {
| |
| 180 | $_[0][0] =~ s/\s|\t//g; | |
| 181 | if($_[0][0] eq $key) {
| |
| 182 | my $format = $hilights{$key}{JoinChan};
| |
| 183 | return Xchat::EAT_NONE unless $format; | |
| 184 | $format =~ s/\%C/\x03/g; | |
| 185 | $format =~ s/\%B/\x02/g; | |
| 186 | $format =~ s/\%O/\x0f/g; | |
| 187 | $format =~ s/\%host%/$_[0][2]/g; | |
| 188 | $format =~ s/\%nick\%/$key/g; | |
| 189 | $format =~ s/\%div\%/\t/g; | |
| 190 | $format =~ s/\%channel\%/$_[0][1]/g; | |
| 191 | Xchat::print( $format ); | |
| 192 | return Xchat::EAT_ALL; | |
| 193 | } | |
| 194 | } | |
| 195 | } | |
| 196 | ||
| 197 | sub quit_msg {
| |
| 198 | foreach my $key (keys(%hilights)) {
| |
| 199 | $_[0][0] =~ s/\s|\t//g; | |
| 200 | if($_[0][0] eq $key) {
| |
| 201 | my $format = $hilights{$key}{Quit};
| |
| 202 | return Xchat::EAT_NONE unless $format; | |
| 203 | $format =~ s/\%C/\x03/g; | |
| 204 | $format =~ s/\%B/\x02/g; | |
| 205 | $format =~ s/\%O/\x0f/g; | |
| 206 | $format =~ s/\%host%/$_[0][2]/g; | |
| 207 | $format =~ s/\%nick\%/$key/g; | |
| 208 | $format =~ s/\%div\%/\t/g; | |
| 209 | $format =~ s/\%message\%/$_[0][1]/g; | |
| 210 | Xchat::print( $format ); | |
| 211 | return Xchat::EAT_ALL; | |
| 212 | } | |
| 213 | } | |
| 214 | } |