SHOW:
|
|
- or go back to the newest paste.
1 | - | # When testing changes, the easiest way to reload the theme is with /RELOAD. |
1 | + | # Simple script for removing colours in public channels :) |
2 | - | # This reloads the configuration file too, so if you did any changes remember |
2 | + | |
3 | - | # to /SAVE it first. Remember also that /SAVE overwrites the theme file with |
3 | + | use strict; |
4 | - | # old data so keep backups :) |
4 | + | use Irssi; |
5 | use vars qw($VERSION %IRSSI); | |
6 | - | # TEMPLATES: |
6 | + | |
7 | # Dev. info ^_^ | |
8 | - | # The real text formats that irssi uses are the ones you can find with |
8 | + | $VERSION = "0.3"; |
9 | - | # /FORMAT command. Back in the old days all the colors and texts were mixed |
9 | + | %IRSSI = ( |
10 | - | # up in those formats, and it was really hard to change the colors since you |
10 | + | authors => "Jørgen Tjernø", |
11 | - | # might have had to change them in tens of different places. So, then came |
11 | + | contact => "darkthorne\@samsen.com", |
12 | - | # this templating system. |
12 | + | name => "CleanPublic", |
13 | description => "Simple script that removes colors and other formatting (bold, etc) from public channels", | |
14 | - | # Now the /FORMATs don't have any colors in them, and they also have very |
14 | + | license => "GPL", |
15 | - | # little other styling. Most of the stuff you need to change is in this |
15 | + | url => "http://mental.mine.nu", |
16 | - | # theme file. If you can't change something here, you can always go back |
16 | + | changed => "Wed Sep 24 13:17:15 CEST 2003" |
17 | - | # to change the /FORMATs directly, they're also saved in these .theme files. |
17 | + | ); |
18 | ||
19 | - | # So .. the templates. They're those {blahblah} parts you see all over the |
19 | + | # All the works |
20 | - | # /FORMATs and here. Their usage is simply {name parameter1 parameter2}. |
20 | + | sub strip_formatting { |
21 | - | # When irssi sees this kind of text, it goes to find "name" from abstracts |
21 | + | my ($server, $data, $nick, $mask, $target) = @_; |
22 | - | # block below and sets "parameter1" into $0 and "parameter2" into $1 (you |
22 | + | # Channel *allowed* to be colorful? |
23 | - | # can have more parameters of course). Templates can have subtemplates. |
23 | + | foreach my $chan (split(' ', Irssi::settings_get_str('colored_channels'))) { |
24 | - | # Here's a small example: |
24 | + | if ($target eq $chan) { return } |
25 | - | # /FORMAT format hello {colorify {underline world}} |
25 | + | } |
26 | - | # abstracts = { colorify = "%G$0-%n"; underline = "%U$0-%U"; } |
26 | + | |
27 | - | # When irssi expands the templates in "format", the final string would be: |
27 | + | # Ruthlessly_ripped_from_Garion { |
28 | - | # hello %G%Uworld%U%n |
28 | + | my $twin = Irssi::window_find_name($target); |
29 | - | # ie. underlined bright green "world" text. |
29 | + | # Beam it to window 1 if we cant find any other suitable target. |
30 | - | # and why "$0-", why not "$0"? $0 would only mean the first parameter, |
30 | + | if (!defined($twin)) { $twin = Irssi::window_find_refnum(1); } |
31 | - | # $0- means all the parameters. With {underline hello world} you'd really |
31 | + | # } |
32 | - | # want to underline both of the words, not just the hello (and world would |
32 | + | |
33 | - | # actually be removed entirely). |
33 | + | # Remove formatting |
34 | $data =~ s/\x03\d?\d?(,\d?\d?)?|\x02|\x1f|\x1d|\x16|\x06|\x07//g; | |
35 | - | # COLORS: |
35 | + | # Let it flow |
36 | Irssi::signal_continue($server, $data, $nick, $mask, $target); | |
37 | - | # You can find definitions for the color format codes in docs/formats.txt. |
37 | + | } |
38 | ||
39 | - | # There's one difference here though. %n format. Normally it means the |
39 | + | # Hook me up |
40 | - | # default color of the terminal (white mostly), but here it means the |
40 | + | Irssi::signal_add('message public', 'strip_formatting'); |
41 | - | # "reset color back to the one it was in higher template". For example |
41 | + | Irssi::settings_add_str('lookandfeel', 'colored_channels', ''); |
42 | - | # if there was /FORMAT test %g{foo}bar, and foo = "%Y$0%n", irssi would |
42 | + | |
43 | - | # print yellow "foo" (as set with %Y) but "bar" would be green, which was |
43 | + |