I made my first irssi perl script, but it doesn't work. I don't understand why not.
When I type !dccstat
on the channel, my home PC just responds with all DCC connections, like when I type /dcc stat
on irssi.
use Irssi;
use vars qw($VERSION %IRSSI);
$VERSION = "1.0";
%IRSSI = (
Test
);
sub event_privmsg {
my ($server, $data, $nick, $mask) =@_;
my ($target, $text) = $data =~ /^(\S*)\s:(.*)/;
return if ( $text !~ /^!dccstat$/i );
if ($text =~ /^!dccstat$/ ) {
my $dcc = dccs();
$server->command ( "msg $target $dcc" )
}
}
Irssi::signal_add('event privmsg', 'event_privmsg');
One problem may be the
dccs()
command itself, it's not recognized in my Irssi v0.8.15, so I usedIrssi::Irc::dccs()
. It returns the array of dcc connections, so it won't (pardon my sarcasm) "magically" turn into string of current dccs status, as "/dcc list" (you used "/dcc stat" term which i beleive is either a mistake or a command of a script which is unknown to me). You need to loop through the array of dccs and pick up the all the data you want. A sketchy (but working) code is given below, so you could use it as a template. Have fun with Irssi scripts.Also, you use "event privmsg" which triggers also for (surprise!) private messages, not only channel ones, yet it works for those too (the response would be sent as a private message to the user). If it's not desired, i suggest use of "message public" signal, as below: