use strict;
use warnings;
 
use Irssi;
use Irssi::Irc;
 
my $VERSION = "1.0.0";
my %IRSSI = (
        author  => "ardnew",
        contact => "andrew\@ardnew.com",
        name    => "wat",
        description => "wat",
        license => "dwtfywwi",
);
 
use vars qw($VERSION %IRSSI);

sub handle_sajoin {
    my ($server, $data) = @_;
    my ($target, $text) = split(/ :/, $data, 2);
 
    if(my ($src, $targ, $dest) =
            ($text =~ /\s(\S+)\sused\sSAJOIN\sto\smake\s(\S+)\sjoin\s(\S+)/))
    {   
        #Irssi::print("CAUGHT SAJOIN: $src: $targ -> $dest");
	if ($targ eq "#Testing") { Server::send_raw("sapart $targ 
$dest"); }
    }
}
 
Irssi::signal_add("event notice", \&handle_sajoin);

sub handle_sapart {
    my ($server, $data) = @_;
    my ($target, $text) = split(/ :/, $data, 2);
 
    if(my ($src, $targ, $dest) =
            ($text =~ /\s(\S+)\sused\sSAPART\sto\smake\s(\S+)\sjoin\s(\S+)/))
    {   
        #Irssi::print("CAUGHT SAPART: $src: $targ -> $dest");
	if ($targ eq "#Testing") { Server::send_raw("sajoin $targ 
$dest"); }
    }
}

Irssi::signal_add("event notice", \&handle_sapart);
