# Irssi (简体中文)

From ArchWiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

相关文章

- IRC channels
- IRC
- WeeChat
- HexChat

翻译状态：本文是 Irssi 的翻译。上次翻译日期：2021-05-28。如果英文版本有所更改，则您可以帮助同步翻译。

Irssi is a modular, ncurses based IRC (Internet Relay Chat) client. It also supports SILC and ICB protocols via plugins. Irssi 是一个基于 ncurse 的模块化 IRC (Internet Relay Chat) 客户端。也能通过插件提供 SILC and ICB 协议支持。

## 安装

安装 软件包 irssi 。

在 AUR 的 irssi-script 下和 Irssi's Script Repository 有一些脚本。

## 使用

更详细的介绍请阅读官方文档。

注意： 这部分假定您了解 IRC 的基本知识并过去用过其他客户端。

推荐使用终端复用器，例如 tmux 或者 GNU Screen 等。它能让用户轻松地断开和重新连接一个会话，并且能够运行如 nicklist.pl 这类依赖次要窗口的脚本。要运行 irssi ，执行：

    $ irssi

参见 irssi(1)。

### 命令

Irssi 的命令以反斜杠为开始，并且大小写不敏感。您可以输入 `/help` 来获得内建的命令列表。这份列表也能在线查阅。

命令 | 说明
--- | ---
/help | 列出所有命令或者解释给定的命令。
/network | 管理您的 IRC 网络。
/server | 管理您的 IRC 服务器。
/connect | 连接一个服务器或者网络。
/disconnect | 断开目前的服务器连接。
`ALT+(1-0,q-p,etc)` | 切换活动窗口。`Ctrl+n` 循环到下一个窗口，`Ctrl+p` 循环到前一个。
/window | 管理 irssi 窗口。
/layout | 保存或者关闭窗口配置。
/statusbar | 管理状态栏。
/set | 查看或者变更设置。
/alias | 管理您的别名。

## 设置

个人设置文件应当位于 `~/.irssi/config`。在 `/etc/irssi.conf` 有一份模板。使用 `--config` 参数也能使用代替的配置文件启动 irssi。

- 您可以使用 `/save` 来把当前的配置保存到配置文件中。
- 您可以使用 `/layout save` 来保存当前打开的窗口的位置。

### Authenticating with SASL

This article or section needs language, wiki syntax or style improvements. See Help:Style for reference.

Reason: Is `-ssl_capath` actually needed? (Discuss in Talk:Irssi (简体中文)#)

Irssi supports the Simple Authentication and Security Layer (SASL).

You can add a network with SASL mechanism as follows:

    /SERVER ADD -ssl -ssl_verify -ssl_capath /etc/ssl/certs -network liberachat -port 6697 irc.libera.chat
    /NETWORK ADD -sasl_mechanism plain -sasl_username username -sasl_password password liberachat

注意：

- Make sure to use the correct capitalization for the network name.
- First command line is for adding server with #TLS Connection
- If you have an existing network, then type second command line only.
- If your password contains `$`, you have to prefix it with another `$` for irssi to properly parse it.

Restart Irssi, connect network and look for SASL authentication succeeded.

### 启动时自动连接到 #archlinux

启动 irssi 并输入以下命令：

    /server add -auto -network liberachat irc.libera.chat

`liberachat` 可以用任何喜欢的词代替，例如常用缩写 `fn`。

保证 SASL 设置正确。也可以配合 `-autosendcmd` 命令使用 NickServ 代替 SASL，但是这会导致在自动加入频道时的竞争状态。如果愿意的话，用 SSL 证书代替给 NickServ 发送密码认证。

    /channel add -auto #archlinux liberachat
    /channel add -auto #archlinux-offtopic liberachat

### TLS Connection

Libera.chat uses port 6697 for SSL/TLS connections (not 6667). To connect to Libera.chat IRC network via TLS you have to setup a new connection. Start irssi and run:

    /server add -auto -tls -tls_verify -network liberachat -port 6697 irc.libera.chat

Save your new settings with:

    /save

If everything works you will see the "Z" mode set. It should look like this: "Mode change (+Zi) for user your-nick"

#### Client certificates

Libera Chat and OFTC support authentication using SSL certificates, providing an alternative to plaintext passwords. See Libera Chat's Using CertFP for more extensive details.

To create a password-less certificate that is valid for 730 days (when requested to enter details like state or even Common Name (CN), you can fill anything you want):

    $ openssl req -newkey rsa:4096 -days 730 -x509 -keyout irssi.key -out irssi.crt -nodes
    $ cat irssi.crt irssi.key > ~/.irssi/irssi.pem
    $ chmod 600 ~/.irssi/irssi.pem
    $ rm irssi.crt irssi.key

Next, find out the corresponding fingerprint:

    $ openssl x509 -sha512 -fingerprint -noout -in ~/.irssi/irssi.pem | sed -e 's/^.*=//;s/://g;y/ABCDEF/abcdef/'

This will write the SHA512 fingerprint to stdout. If you need the SHA1 fingerprint, replace `-sha512` with `-sha1`. The sed command is there to format the fingerprint correctly by removing unwanted text and characters.

Copy the fingerprint string as you will register it in Irssi shortly.

In irssi, disconnect from the network and add the client certificate and keys. Omit the `-ssl_pass` option if your certificate was built without a password:

    /disconnect liberachat
    /server add -ssl_cert ~/.irssi/irssi.pem  -ssl_pass irssi.pem_password -network liberachat irc.libera.chat 6697

Now connect (not `/reconnect`) and register your fingerprint

    /connect liberachat
    /msg NickServ identify YOUR_PASSWORD
    /msg NickServ cert add YOUR_FINGERPRINT

At this point, you can remove your password from the configuration file (if you saved it in there) and save your config with:

    /save

### Automatic logging

    /SET autolog ON
    /save

### Hide joins, parts, and quits

In order to ignore showing of joining, leaving and quiting of users for all channels type the following in irssi:

    /ignore * joins parts quits

See smartfilter to restrict join messages to active users.

### Mouse scrolling

To enable the mouse, type the following in irssi:

     /run scriptassist
     /script install mouse.pl

To permanently enable it at startup:

     /script autorun mouse.pl

If the above does not work, you can manually load scripts from `~/.irssi/scripts` or `~/.irssi/scripts/autorun` with the following:

     /script load mouse.pl

## 技巧

### HTTP Proxy

To use irssi behind a HTTP proxy, the following commands are required:

    /SET use_proxy ON
    /SET proxy_address <Proxy host address>
    /SET proxy_port <Proxy port>
    /SET -clear proxy_string
    /SET proxy_string_after conn %s %d
    /EVAL SET proxy_string CONNECT %s:%d HTTP/1.0\n\n

irssi should then alter its config file correspondingly; if the proxy is not required, just set use_proxy to OFF.

Should the proxy require a password, try:

    /SET proxy_password your_pass

Otherwise:

    /SET -clear proxy_password

注意： SSL behind a proxy will fail with these settings.

### Irssi with nicklist in tmux

The irssi plugin 'nicklist' offers to add a pane listing the users on the channel currently viewed. It has two methods to do this:

- screen, which simply adds the list to the right of irssi, but brings the disadvantage that the entire window gets redrawn every time irssi prints a line.

- fifo, which like the name suggests writes the list into a fifo that can then be continuously read with e. g. cat ~/.irssi/nicklistfifo.

nicklist will use the more efficient fifo with:

    /NICKLIST FIFO

This fifo can be used in a tmux window split vertically with irssi in its left pane and the cat from above in a small one in its right. Since the pane is dependent on its creating tmux session's geometry, a subsequent session with a different one needs to recreate it (which also implies a switch in irssi windows to refill the fifo).

E.g., the following script first checks for a running irssi, presumed to have been run by a previous execution of itself. Unless found it creates a new tmux session, a window named after and running irssi and then the pane with cat. If however irssi was found it merely attaches to the session and recreates the cat pane.

    #!/bin/bash

    T3=$(pgrep -u $USER -x irssi)

    irssi_nickpane() {
        tmux setw main-pane-width $(( $(tput cols) - 21));
        tmux splitw -v "cat ~/.irssi/nicklistfifo";
        tmux selectl main-vertical;
        tmux selectw -t irssi;
        tmux selectp -t 0;
    }

    irssi_repair() {
        tmux selectw -t irssi
        (( $(tmux lsp | wc -l) > 1 )) && tmux killp -a -t 0
        irssi_nickpane
    }

    if [ -z "$T3" ]; then
        tmux new-session -d -s main;
        tmux new-window -t main -n irssi irssi;
        irssi_nickpane ;
    fi
        tmux attach-session -d -t main;
        irssi_repair ;
    exit 0

提示： Instead of doing all this work, this plugin does all the work needed for a nice nicklist inside tmux.

### Virtual hostname (vhost)

A vhost can be used to change your hostname when connected to an IRC-server, commonly viewed when joining/parting or doing a whois. This is most commonly done on a server that has a static IP address. Without a vhost it would commonly look like so when doing a 'whois':

    nick@123.456.78.90.isp.com

The result of a successful vhost could be like so if you have the domain example.com available:

    nick@example.com

Keep in mind that not every IRC-server supports the use of vhost. This might be individually set between the servers and not the network, so if you are experiencing issues with one server try another on the same network.

#### Required preconfigurations

Irssi supports using a vhost as long as the required configurations has been set. This includes especially that your host supports Recursive DNS Lookup (rDNS) using Pointer record (PTR). Additionally you should add an appropriate line to your `/etc/hosts` file.

To see if this is working, test with the 'host' DNS lookup utility included in bind like so (where ip is a normal IPv4 address):

    host ip

If this returns something in the lines of this then you know that your rDNS is working.

    ip.in-addr.arpa domain name pointer example.com

#### Enabling the vhost

There are a couple of ways to connect to a server with a given hostname. One is using the 'server' command with a -host argument like so:

    /server -host example.com irc.libera.chat

Another way would be to set your hostname (vhost) with the 'set' command which will save your hostname to `~/.irssi/config`:

    /set hostname example.com
    /save
    /server irc.libera.chat

## 更多内容

- Official website
- Official Irssi script repository
- Setting up Irssi
- Guide to efficiently using Irssi and screen by Matt Sparks
- IRC notifications with dzen2 by Jason Ryan
- Irssi’s /channel, /network, /server and /connect – What it means by Aaron Toponce
- awesome Wiki Irssi tips (Wayback Machine)
- irssi systemd unit GitHub gist

Category:

- Internet Relay Chat (简体中文)

Hidden category:

- Pages or sections flagged with Template:Style