#!/usr/bin/perl -w # my first perl script.. IRC::print "\0035Loading sound script\003\n"; IRC::add_command_handler("sound", "sound_command"); IRC::add_message_handler("PRIVMSG", "sound_autosend"); IRC::add_message_handler("PRIVMSG", "sound_autoget"); $lastsound = "none"; $autosend = "yes"; $autoget = "yes"; $homedir = "/home/asshead/dccpile/"; sub sound_command { $name = IRC::get_info(1); $channel = IRC::get_info(2); $sound = shift(@_); $lastsound = $sound; IRC::print "playing $sound on $channel\n"; IRC::send_raw "PRIVMSG $channel :\001SOUND $sound\001\r\n"; IRC::send_raw "PRIVMSG $name :\001SOUND $sound\001\r\n"; return 1; } sub sound_autosend { if($autosend ne "yes") { return 0; } if($lastsound eq "none") { return 0; } $myname = IRC::get_info(1); $myname = "!" . $myname; my $line = shift (@_); # ":nick!host PRIVMSG channel :message" $line =~ /:(.*)!(\S+) PRIVMSG (.*) :(.*)/i; $name = $1; $channel = $3; $text = $4; $name = "$name"; @wordlist = split(' ',$4); if($wordlist[0] eq $myname) { if($lastsound eq $wordlist[1]) { IRC::print("sending $lastsound to $name ($channel)\n"); IRC::command("/dcc SEND $name $homedir$lastsound"); return 0; } } return 0; } sub sound_autoget { if($autosend ne "yes") { return 0; } my $line = shift (@_); #:nick!host PRIVMSG channel :message $line =~ /:(.*)!(\S+) PRIVMSG (.*) :(.*)/i; $name = $1; $channel = $3; $text = $4; $name = "$name"; @wordlist = split(' ',$4); if($wordlist[0] eq "\001SOUND") { $tempsound = $wordlist[1]; $tempsound =~ s/[\r \001 \n]//; IRC::print($tempsound); if(!open(tempfile, $homedir.$tempsound)) { IRC::send_raw("PRIVMSG $name :!$name $tempsound\r\n"); } else { close(tempfile); } } return 0; }