1# This is not a well written script, but it works. I hope.
2use strict;
3use Irssi;
4use vars qw($VERSION %IRSSI);
5
6$VERSION = '0.1';
7%IRSSI = (
8  authors	=> 'optical',
9  contact	=> 'optical@linux.nu',
10  name		=> 'SETI@home info',
11  description	=> 'Tell ppl how far you\'ve gotten with you SETI\@home workunit.',
12  license	=> 'GPL',
13  url		=> 'http://optical.kapitalet.org/seti/',
14  changed	=> 'Sat Jul 13 12:03:42 CEST 2002',
15  commands	=> '/seti <#channel>|<nick>',
16  note		=> 'Make sure you set the seti_state_sah with /set'
17);
18
19sub seti_info {
20
21  my $WHERES_SETI_STATE_SAH = Irssi::settings_get_str('seti_state_sah');
22
23  my ($data, $server, $witem) = @_;
24
25  my $line;
26  open(INFO, "<", $WHERES_SETI_STATE_SAH);
27  for(my $tmp = 0; $tmp < 5; $tmp++) {
28    $line = <INFO>;
29  }
30  close(INFO);
31  my $proc = substr($line, 7, 4)/100;
32  my $output = "progress of this SETI\@home workunit: $proc%";
33
34  if($data)
35  {
36    $server->command("MSG $data $output");
37  }
38  elsif($witem && ($witem->{type} == "QUERY" ||
39		   $witem->{type} == "CHANNEL"))
40  {
41    $witem->command("MSG ".$witem->{name}." $output");
42  }
43  else
44  {
45    Irssi::print("$output");
46  }
47}
48
49Irssi::command_bind('seti', 'seti_info');
50Irssi::settings_add_str('misc', 'seti_state_sah', '~/setiathome-3.03.i386-pc-linux-gnu-gnulibc2.1/state.sah');
51