]>
Commit | Line | Data |
---|---|---|
3f24f7e4 | 1 | # |
2 | # This script will print hilighted messages into a window called 'hilight'. | |
3 | # | |
4 | # Originally written by Timo Sirainen <tss@iki.fi> | |
5 | # - Places all hilighted messages into a window called "hilight" | |
6 | # Amended by Mark Sangster <znxster@gmail.com> | |
7 | # - Prints a timestamp with the messages | |
8 | # - Now allows toggling private messages to show or not. | |
9 | # - Using formats to print (allows basic theme adjustment) | |
10 | # | |
11 | # This script is released in the Public Domain. | |
12 | # | |
13 | # Basic Usage: | |
14 | # /window new split | |
15 | # /window name hilight | |
16 | # /script load hilightwin.pl | |
17 | # | |
18 | # Suggested usage: | |
19 | # /window new split | |
20 | # /window name hilight | |
21 | # /window size 10 | |
22 | # /statusbar topic type window | |
23 | # /statusbar topic visible active | |
24 | # /statusbar window_inact disable | |
25 | # /script load hilightwin.pl | |
26 | # | |
27 | # Toggle private messages with: | |
28 | # /toggle hilightwin_showprivmsg | |
29 | # | |
30 | ||
31 | use Irssi; | |
32 | use POSIX; | |
33 | use vars qw($VERSION %IRSSI); | |
34 | ||
35 | $VERSION = "0.03"; | |
36 | %IRSSI = ( | |
37 | authors => "John Runyon", | |
38 | contact => "https://github.com/zonidjan", | |
39 | name => "hilightwin", | |
40 | description => "Print arbitrary-level messages to window named \"hilight\"", | |
41 | license => "Public Domain", | |
42 | url => "http://github.com/zonidjan/irssi-scripts/", | |
43 | changed => "2018-01-02", | |
44 | ); | |
45 | ||
46 | # Setup the theme for the script | |
47 | Irssi::theme_register([ | |
48 | 'hilightwin_loaded', '%R>>%n %_hilightwin:%_ Version $0 by $1.', | |
49 | 'hilightwin_missing', '%R>>%n %_hilightwin:%_ No window named "hilight" was found, please create it', | |
50 | 'hilightwin_output', '$0 $1', | |
51 | 'hilightwin_public_output', '$0 $1: $2', | |
52 | ]); | |
53 | ||
54 | # Main | |
55 | sub hilightwin_signal { | |
56 | my ($dest, $text, $ignored) = @_; | |
57 | $window = Irssi::window_find_name('hilight'); | |
58 | ||
59 | # Skip if the named window doesn't exist | |
60 | if($window) { | |
61 | my $opt = Irssi::settings_get_level('hilightwin_show'); | |
62 | ||
63 | if( ($dest->{level} & ($opt)) && ($dest->{level} & MSGLEVEL_NOHILIGHT) == 0 ) { | |
64 | $time = strftime( Irssi::settings_get_str('timestamp_format')." ", localtime ); | |
65 | if($dest->{level} & MSGLEVEL_PUBLIC) { | |
66 | $window->printformat(MSGLEVEL_NEVER, 'hilightwin_public_output', $time, $dest->{target}, $text); | |
67 | } | |
68 | else { | |
69 | $window->printformat(MSGLEVEL_NEVER, 'hilightwin_output', $time, $text); | |
70 | } | |
71 | } | |
72 | } | |
73 | } | |
74 | ||
75 | # Settings | |
76 | Irssi::settings_add_level('hilightwin','hilightwin_show','HILIGHT MSGS'); | |
77 | ||
78 | # Signals | |
79 | Irssi::signal_add('print text', 'hilightwin_signal'); | |
80 | ||
81 | # On load | |
82 | $window = Irssi::window_find_name('hilight'); | |
83 | Irssi::printformat(MSGLEVEL_CLIENTCRAP, 'hilightwin_missing') if (!$window); | |
84 | Irssi::printformat(MSGLEVEL_CLIENTCRAP, 'hilightwin_loaded', $VERSION, $IRSSI{authors}); | |
85 | ||
86 | # vim:set ts=4 sw=4 noet: |