#!/usr/bin/perl use strict; use Irssi; use vars qw($VERSION %IRSSI); # global variables $VERSION = sprintf("%d.%02d", q$Revision: 0.0.1 $ =~ /^.+?(\d+)\.(\d+)/); %IRSSI = ( authors => 'brimstone', contact => 'my@my.isp.com', name => 'ClientServer Info script', description => '/mp3 and whatnot', license => 'GPLv2', url => 'http://127.0.0.1:16667/', changed => '2005-0717T21:53-0500', ); our %global = {'attached' => 1}; if(runningUnderIrssi()) { Irssi::print("$IRSSI{name} $VERSION loaded"); Irssi::timeout_add(10000, \&timer_screen_check, ''); } else { (my $s = $0) =~ s/.*\///; $ARGV[0] || die("Usage: $s \n"); } sub runningUnderIrssi { $0 eq '-e'; } sub timer_screen_check { my $status = `screen -ls | grep main`; if ($status =~ /Attached/ && $global{attached} == 0) { if (Irssi::active_server()->{'tag'} eq "bitlbee") { Irssi::active_server()->command("/away"); } $global{attached} = 1; } elsif ($status =~ /Detached/ && $global{attached} == 1) { if (Irssi::active_server()->{'tag'} eq "snapl") { Irssi::active_server()->command("/action #anime [detaches]"); } elsif (Irssi::active_server()->{'tag'} eq "bitlbee") { Irssi::active_server()->command("/away " . `cat ~/away`); } $global{attached} = 0; } } # END OF SCRIPT