irssi - /忽略昵称但日志中会出现消息

irssi - /忽略昵称但日志中会出现消息

我想 /忽略昵称,但仍然希望他们的消息出现在我的日志中。具体来说,我一般不想知道他们是否在频道中聊天,但如果我正在关注一段没有多大意义的对话,我希望能够查看日志以获取完整的上下文。

我并不急于学习编写新脚本,但是我有能力并且愿意修改现有脚本,使其接近我想要的功能(如果存在)。

答案1

正在寻找类似的东西,找到了这个,

https://github.com/irssi/scripts.irssi.org/blob/master/scripts/ignore_log.pl

该脚本将记录任何设置为忽略的内容。

如果链接断开,则通过https://scripts.irssi.org,目前内容如下:

#!/usr/bin/perl

# ignore_log.pl (ignore_log -- send [some] ignored events to log), Version 0.1
# this script is dedicated to bormann@IRCNET.
#
# Copyleft (>) 2004 jsn <[email protected]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# The complete text of the GNU General Public License can be found
# on the World Wide Web: <URL:http://www.gnu.org/licenses/gpl.html>

use strict;
use Irssi;

use POSIX qw/strftime/ ;

use vars qw($VERSION %IRSSI);

$VERSION = "0.1";
%IRSSI = (
    authors     => 'Dmitry "jsn" Kim',
    contact     => '[email protected]',
    name        => 'ignore_log',
    description => 'script to log ignored messages',
    license     => 'GPL',
    url     => 'http://',
    changed     => '2004-09-10',
    changes     => 'initial version'
);

Irssi::print("*****\n* $IRSSI{name} $VERSION loaded.");
Irssi::print("*  use `/set ignore_log <filename>' to configure") ;
Irssi::print("*  use `/set ignore_log none' to disable ignore logging") ;

sub handle_public {
    my  ($srv, $msg, $nick, $addr, $tgt) = @_;
    return if lc(Irssi::settings_get_str("ignore_log")) eq "none" ;
    write_log($nick, $msg, $tgt)
        if $srv->ignore_check($nick, $addr, $tgt, $msg, MSGLEVEL_PUBLIC) ;
}

sub handle_private {
    my  ($srv, $msg, $nick, $addr) = @_;
    return if lc(Irssi::settings_get_str("ignore_log")) eq "none" ;
    write_log($nick, $msg)
        if $srv->ignore_check($nick, $addr, "", $msg, MSGLEVEL_MSGS) ;
}

sub write_log {
        my  ($nick, $msg, $tgt) = @_ ;
    $tgt ||= "->" ;
    my  ($lfile) = glob Irssi::settings_get_str("ignore_log");
    if (open(LF, ">>", $lfile)) {
        my  $ts = strftime("%D %H:%M", localtime()) ;
        print LF "[$ts] $tgt $nick $msg\n" ;
        close LF ;
    } else {
        Irssi::active_win()->print("can't open file `$lfile': $!") ;
    }
}

Irssi::settings_add_str("ignore_log", "ignore_log", "~/.irssi/ignore.log");

Irssi::print("*  logging ignored users to `" .
    Irssi::settings_get_str("ignore_log") . "'") ;

Irssi::signal_add_first("message public", "handle_public") ;
Irssi::signal_add_first("message private", "handle_private") ;

相关内容