From 2d0759e6ca5767b48bcc85bf38c2c43d5f0b63b1 Mon Sep 17 00:00:00 2001 From: Alexander Færøy Date: Sat, 31 May 2014 13:10:46 +0200 Subject: Import scripts from scripts.irssi.org --- scripts/licq.pl | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 scripts/licq.pl (limited to 'scripts/licq.pl') diff --git a/scripts/licq.pl b/scripts/licq.pl new file mode 100644 index 0000000..cc7b1ec --- /dev/null +++ b/scripts/licq.pl @@ -0,0 +1,63 @@ +$VERSION = "0.5"; +%IRSSI = ( + authors => "Jari Matilainen", + contact => "jmn98015\@student.mdh.se", + name => "licq", + description => "Licq statusbar thingy", + license => "Public Domain", + url => "http://jari.cjb.net,http://irssi.org,http://scripts.irssi.de", +); + +use Irssi::TextUI; + +my $result; +my $refresh_tag; +my $rdir = "$ENV{'HOME'}/.licq/users/"; + +sub licq { + my ($item,$get_size_only) = @_; + $result = 0; + if(-e $rdir) { + opendir(DIR, $rdir); + + while ( $_ = readdir(DIR) ) { + next if(($_ eq ".") or ($_ eq "..")); + + my $filename = "$rdir" . "$_"; + if(-e $filename) { + open(FILE, $filename); + $_ = ""; + $_ = until /NewMessages/; + my @total = split / /, $_; + if(defined $total[2]) { + $result += $total[2]; + } + } + } + } + + closedir(DIR); + + $item->default_handler($get_size_only, undef, $result, 1); +} + +sub refresh_licq { + Irssi::statusbar_items_redraw('licq'); +} + +sub init_licq { + my $time = Irssi::settings_get_int('licq_refresh_time'); + $rdir = Irssi::settings_get_str('licq_path'); + Irssi::timeout_remove($refresh_tag) if ($refresh_tag); + $refresh_tag = Irssi::timeout_add($time*1000, 'refresh_licq', undef); +} + +Irssi::settings_add_int('LICQ','licq_refresh_time',10); +Irssi::settings_add_str('LICQ','licq_path',$rdir); +Irssi::statusbar_item_register('licq', '{sb ICQ: $0-}', 'licq'); + +init_licq(); +Irssi::signal_add('setup changed','init_licq'); +refresh_licq(); + +# EOF -- cgit v1.2.3