1

我在 Windows 上,使用 Irssi 客户端 irssi-win32-0.8.12.exe。

我在接收名称无效的文件时遇到问题:

..nameo_\u2605_name.. (err: DCC can't create file)

如何使用脚本从文件名中删除这个无效部分“\u2605”?

此页面没有帮助

我认为Irssi 源的这一部分与它有关。从第 195 行开始

/* if some plugin wants to change the file name/path here.. */
signal_emit("dcc get receive", 1, dcc);    
4

1 回答 1

0

我当然希望 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

我希望它有帮助!

于 2016-03-15T15:50:29.443 回答