我当然希望 Windows 上的 Irssi 接受用 Perl 编写的脚本。如果是这种情况,这是解决方案:
use strict;
use warnings;
our $VERSION = "1.0";
our %IRSSI = ();
# interception made by registering signal as first + Irssi::signal_continue()
sub event_ctcp_dccsend {
my ($server, $args, $nick, $addr, $target) = @_;
# split incomming send request args into filename (either before first space or
# quoted), and the rest (IP, port, +optionally filesize)
my ($filename, $rest) = $args =~ /((?:".*")|\S*)\s+(.*)/;
# remember file name for informing sake
my $oldname = $filename;
# replace backslashes with "BSL" (change to anything you wish)
if ($filename =~ s/\\/BSL/g) {
# some info for user
Irssi::print('DCC SEND request from '.$nick.': renamed bad filename '.$oldname.' to '.$filename);
$args = $filename." ".$rest;
# propagate signal; Irssi will proceed the request with altered arguments ($args)
Irssi::signal_continue($server, $args, $nick, $addr, $target);
}
}
# register signal of incoming ctcp 'DCC SEND', before anything else
Irssi::signal_add_first('ctcp msg dcc send', 'event_ctcp_dccsend');
该脚本拦截“DCC SEND”ctcp 消息并将文件名中的所有反斜杠替换为“BSL”字符串,然后将更改的消息参数转发给任何其他脚本和 Irssi。如果要删除所有“\uXXXX”,请使用s/\\u\w{4}//g
代替s/\\/BSL/g
我希望它有帮助!