diff options
| author | bw1 | 2017-03-13 21:57:23 +0100 | 
|---|---|---|
| committer | bw1 | 2017-03-17 14:23:00 +0100 | 
| commit | d0e40ae25d2342e917d6475eac97da9abee46bc3 (patch) | |
| tree | abcdefac223f38c9aded79f11ad624e96fddbecc /scripts/hitcount.pl | |
| parent | 5ca0f825df0c593050851929b11850ce0e50b08d (diff) | |
| download | scripts.irssi.org-d0e40ae25d2342e917d6475eac97da9abee46bc3.tar.bz2 | |
[hitcount] format change
Diffstat (limited to 'scripts/hitcount.pl')
| -rw-r--r-- | scripts/hitcount.pl | 70 | 
1 files changed, 33 insertions, 37 deletions
| diff --git a/scripts/hitcount.pl b/scripts/hitcount.pl index f0acfcc..0758cff 100644 --- a/scripts/hitcount.pl +++ b/scripts/hitcount.pl @@ -5,13 +5,13 @@ use vars qw($VERSION %IRSSI);  my @rev = split(/ /, '$Revision: 1.4 $n');  $VERSION = "1.4";  %IRSSI = ( -	    authors     => 'Riku "Shrike" Lindblad', -	    contact     => 'shrike\@addiktit.net, Shrike on IRCNet/QNet/EFNet/DALNet', -	    name        => 'hitcount', -	    description => 'Add a apache page hitcounter to statusbar', -	    license     => 'Free', -	    changed     => '$Date: 2017/03/07 $ ', -	  ); +    authors     => 'Riku "Shrike" Lindblad', +    contact     => 'shrike\@addiktit.net, Shrike on IRCNet/QNet/EFNet/DALNet', +    name        => 'hitcount', +    description => 'Add a apache page hitcounter to statusbar', +    license     => 'Free', +    changed     => '$Date: 2017/03/07 $ ', +);  # Changelog:  # @@ -79,18 +79,18 @@ sub get_hitcount {      # Go through the access log and count matches to the given regexp      if(open STUFF, "<", $filename) { -		while (<STUFF>) { -			$total_hitcount++; -			#if(m#$regexp#ois) -			if(m<GET $regexp >) { -				# DEBUG -				Irssi::print("Matched $_", MSGLEVEL_CLIENTERROR) if($debug_level > 3); -				$my_hitcount++; -			} -		} -		close STUFF; +        while (<STUFF>) { +            $total_hitcount++; +            #if(m#$regexp#ois) +            if(m<GET $regexp >) { +                # DEBUG +                Irssi::print("Matched $_", MSGLEVEL_CLIENTERROR) if($debug_level > 3); +                $my_hitcount++; +            } +        } +        close STUFF;      } else { -		Irssi::print("Failed to open <$filename: $!", MSGLEVEL_CLIENTERROR); +        Irssi::print("Failed to open <$filename: $!", MSGLEVEL_CLIENTERROR);      }      return($my_hitcount,$total_hitcount); @@ -101,20 +101,20 @@ sub hitcount {      my ($item, $get_size_only) = @_;      $item->default_handler($get_size_only,  -		"{sb Hits: $last_my_hitcount/$last_total_hitcount ". -		"$my_prefix$my_change/$total_prefix$total_change}", '', 0); +        "{sb Hits: $last_my_hitcount/$last_total_hitcount ". +        "$my_prefix$my_change/$total_prefix$total_change}", '', 0);  }  # repeat refresh by interval time  sub refresh_hitcount {      my ($my_hitcount, $my_total_hitcount) = get_hitcount(); -	 +          # Calculate change since last update -	if ($last_total_hitcount >0) { -		$my_change = $my_hitcount - $last_my_hitcount; -		$total_change = $total_hitcount - $last_total_hitcount; -	} +    if ($last_total_hitcount >0) { +        $my_change = $my_hitcount - $last_my_hitcount; +        $total_change = $total_hitcount - $last_total_hitcount; +    }      # Get correct prefix for change      $my_prefix = "+" if($my_change > 0); @@ -126,13 +126,13 @@ sub refresh_hitcount {      # DEBUG      Irssi::print( -		"$last_my_hitcount/$last_total_hitcount | $my_hitcount/$total_hitcount ". -		"| $my_prefix$my_change $total_prefix$total_change",  -		MSGLEVEL_CLIENTERROR) if($debug_level > 0); +        "$last_my_hitcount/$last_total_hitcount | $my_hitcount/$total_hitcount ". +        "| $my_prefix$my_change $total_prefix$total_change",  +        MSGLEVEL_CLIENTERROR) if($debug_level > 0); -	# show it +    # show it      Irssi::statusbar_items_redraw('hitcount'); -	 +          # last hitcount = current hitcount      $last_my_hitcount = $my_hitcount;      $last_total_hitcount = $total_hitcount; @@ -148,15 +148,11 @@ sub read_settings {      return if ($time == $last_refresh);      $last_refresh = $time; -	 -	Irssi::timeout_remove($refresh_tag) if ($refresh_tag); +     +    Irssi::timeout_remove($refresh_tag) if ($refresh_tag);      $refresh_tag = Irssi::timeout_add($time*1000, 'refresh_hitcount', undef); -	refresh_hitcount(); -} - -sub UNLOAD { -	Irssi::timeout_remove($refresh_tag) if ($refresh_tag); +    refresh_hitcount();  }  # default values | 
