html/act.pl


   1 #!/usr/bin/perl -w
   2 # resets window activity status
   3 #  by c0ffee 
   4 #    - http://www.penguin-breeder.org/irssi/
   5 
   6 #<scriptinfo>
   7 use vars qw($VERSION %IRSSI);
   8 
   9 use Irssi 20020120;
  10 $VERSION = "0.13";
  11 %IRSSI = (
  12     authors	=> "c0ffee",
  13     contact	=> "c0ffee\@penguin-breeder.org",
  14     name	=> "Reset window activity status",
  15     description	=> "Reset window activity status. defines command /act",
  16     license	=> "Public Domain",
  17     url		=> "http://www.penguin-breeder.org/irssi/",
  18     changed	=> "Wed Jun 23 08:34:53 CEST 2004",
  19 );
  20 #</scriptinfo>
  21 
  22 
  23 #
  24 # /ACT [PUBLIC|ALL]
  25 #
  26 # /ACT without parameters marks windows as non-active where no
  27 # public talk occured.
  28 #
  29 # /ACT PUBLIC also removes those where no nick hilight was triggered
  30 #
  31 # /ACT ALL sets all windows as non-active
  32 sub cmd_act {
  33     my ($data, $server, $channel) = @_;
  34 
  35     if ($data eq "") {
  36       $level = 1;
  37     } elsif ($data =~ /^public$/i) {
  38       $level = 2;
  39     } elsif ($data =~ /^all$/i) {
  40       $level = 3;
  41     } else {
  42       Irssi::signal_emit("error command", -3, $data);
  43       return;
  44     }
  45 
  46     foreach (Irssi::windows()) {
  47 
  48       if ($_->{data_level} <= $level) {
  49 
  50         Irssi::signal_emit("window dehilight", $_);
  51 
  52       }
  53 
  54     }
  55 }
  56 
  57 my @arguments = ('public', 'all');
  58 sub sig_complete ($$$$$) {
  59     my ($list, $window, $word, $linestart, $want_space) = @_;
  60     return unless $linestart =~ /^.act/;
  61     foreach my $arg (@arguments) {
  62       if ($arg =~ /^$word/i) {
  63         $$want_space = 0;
  64         push @$list, $arg;
  65       }
  66     }
  67     Irssi::signal_stop();
  68 }
  69 
  70 
  71 Irssi::command_bind("act", "cmd_act");
  72 Irssi::signal_add_first('complete word', \&sig_complete);