File: chanact-ignore-level.diff

package info (click to toggle)
irssi-scripts 20100512
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 3,420 kB
  • ctags: 2,479
  • sloc: perl: 58,204; sh: 171; makefile: 33
file content (53 lines) | stat: -rw-r--r-- 1,947 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
--- a/scripts/chanact.pl
+++ b/scripts/chanact.pl
@@ -207,6 +207,13 @@
 	$item->default_handler($get_size_only, $actString, undef, 1);
 }
 
+sub chan_sort {
+       my ($an, $bn) = ($a->get_active_name, $b->get_active_name);
+       return -1 if $an !~ /^[#&]/ and $bn =~ /^[#&]/;
+       return 1 if $an =~ /^[#&]/ and $bn !~ /^[#&]/;
+       return $a->{refnum} <=> $b->{refnum};
+}
+
 # this is the real creation method
 sub remake() {
 	my ($afternumber,$finish,$hilight,$mode,$number,$display,@windows);
@@ -214,12 +221,15 @@
 	my $abbrev = Irssi::settings_get_int('chanact_abbreviate_names');
 	my $remove_prefix = Irssi::settings_get_str('chanact_remove_prefix');
 	my $remove_hash = Irssi::settings_get_bool('chanact_remove_hash');
+        my %level_list = map { /(.*):(.*)/ ? ($1, $2) : ($_, 1) }
+          split (/\s+/, Irssi::settings_get_str("chanact_ignore_level"));
+        my $data_level = Irssi::settings_get_int('chanact_data_level');
 
  	if (Irssi::settings_get_bool('chanact_sort_by_activity')) {
 		@windows = sort { ($b->{last_line} <=> $a->{last_line}) }
 			Irssi::windows;
 	} else {
-		@windows = sort { ($a->{refnum}) <=> ($b->{refnum}) }
+		@windows = sort chan_sort
 			Irssi::windows;
 	}
 
@@ -229,6 +239,10 @@
 		# since irssi is single threaded this shouldn't happen
 		!ref($win) && next;
 
+                if ($win->{data_level} < ($level_list{$name} || $data_level)) {
+                  next;
+                }
+
 		my $active = $win->{active};
 		!ref($active) && next;
 
@@ -438,6 +452,8 @@
 Irssi::settings_add_bool('chanact', 'chanact_chop_status', 1);
 Irssi::settings_add_bool('chanact', 'chanact_sort_by_activity', 1);
 Irssi::settings_add_int('chanact', 'chanact_filter', 0);
+Irssi::settings_add_int('chanact', 'chanact_data_level', 1);
+Irssi::settings_add_str('chanact', 'chanact_ignore_level', '');
 
 # register the statusbar item
 Irssi::statusbar_item_register('chanact', '$0', 'chanact');