的一個問題可能是dccs()
命令本身,它不是在我的irssi v0.8.15的認可,所以我用Irssi::Irc::dccs()
。它返回dcc連接數組,所以它不會(原諒我的諷刺)「神奇地」變成當前dccs狀態的字符串,因爲「/ dcc list」(你使用的「/ dcc stat」這個術語,我相信是要麼是我不知道的腳本的錯誤或命令)。您需要循環訪問dccs數組並獲取所需的所有數據。粗略的(但工作)的代碼如下,所以你可以使用它作爲模板。玩Irssi腳本。
use Irssi;
use vars qw($VERSION %IRSSI);
$VERSION = "1.0";
%IRSSI = (
Test
);
sub event_privmsg {
my ($server, $data, $nick, $mask) [email protected]_;
my ($target, $text) = $data =~ /^(\S*)\s:(.*)/;
return if ($text !~ /^!dccstat$/i); # this line could be removed as the next one checks for the same
if ($text =~ /^!dccstat$/) {
# get array of dccs and store it in @dccs
my @dccs = Irssi::Irc::dccs();
# iterate through array
foreach my $dcc (@dccs) {
# get type of dcc (SEND, GET or CHAT)
my $type = $dcc->{type};
# process only SEND and GET types
if ($type eq "SEND" || $type eq "GET") {
my $filename = $dcc->{arg}; # name of file
my $nickname = $dcc->{nick}; # nickname of sender/receiver
my $filesize = $dcc->{size}; # size of file in bytes
my $transfered = $dcc->{transfd}; # bytes transfered so far
# you probably want to format file size and bytes transfered nicely, i'll leave it to you
$server->command("msg $target nick: $nickname type: $type file: $filename size: $filesize transfered: $transfered");
}
}
}
}
Irssi::signal_add('event privmsg', 'event_privmsg');
而且,你用「事件PRIVMSG」,這也引發了(驚喜!)私人信息,不僅渠道的,但它適用於那些太(響應會被送到一個私人消息給用戶)。如果不需要,我建議使用「message public」信號,如下所示:
# ..
sub event_message_public {
my ($server, $msg, $nick, $mask, $target) = @_;
# .. the rest of code
}
Irssi::signal_add("message public", event_message_public);