Weechat 4.10.1 配置参数详解
Weechat 4.10.1 全量配置参数体系梳理:7 大类约 900+ 参数覆盖核心显示/网络/IRC/脚本/relay,含生产配置模板与变量注入方案。
Weechat 4.10.1 配置参数详解
目标:系统梳理 Weechat 4.10.1 全量配置参数体系,覆盖核心参数(weechat.)、IRC 插件参数、脚本与安全设置,帮助用户快速定位并修改目标参数。本文基于 Weechat 4.10.1 官方文档 +
weechat -i构建信息分析,实测验证默认值与修改方式。
一、环境信息
- 配置版本:Weechat 4.10.1(参数体系稳定,v4 以来无破坏性变更)
- 主配置文件:
~/.weechat/weechat.conf(INI 格式,自动生成) - 插件配置文件:
irc.conf、script.conf、logger.conf、relay.conf等,同目录 - 参数修改方式:Weechat 内
/set命令(即时生效 + 持久化)、直接编辑 conf 文件后/reload - 参数总量:约 900+ 项(核心约 150,IRC 插件约 200,其余脚本/插件参数分散)
- 参数分类:按插件域分为 7 大类(见第三节)
二、前置条件
- Weechat 4.10.1 已安装(详见《Ubuntu 22.04 安装 Weechat 4.10.1 指南》)
- Weechat 家目录
~/.weechat/已初始化(首次启动自动创建) - 建议先完整阅读本文,对参数分组有整体概念后再开始定制
# 查看配置目录结构
ls -la ~/.weechat/
# 回显:
# drwxr-xr-x 5 user user 4096 Oct 27 07:31 .
# drwxr-xr-x 8 user user 4096 Oct 27 07:31 ..
# -rw-r--r-- 1 user user 320 Oct 27 07:31 weechat.conf ← 主配置
# -rw-r--r-- 1 user user 512 Oct 27 07:31 irc.conf ← IRC 插件配置
# -rw-r--r-- 1 user user 0 Oct 27 07:31 script.conf ← 脚本配置
# -rw-r--r-- 1 user user 0 Oct 27 07:31 logger.conf
# ...(略)
三、参数查看与修改方式
3.1 /set 命令(推荐)
# 查看所有参数
/set
# 回显(节选,约 900 行):
# weechat.look.buffer_time_format = "%H:%M"
# weechat.color.chat = "default"
# weechat.network.connection_timeout = 30
# irc.server.libera.nicks = ""
# ...(略)
# 模糊搜索(weechat 内)
/set weechat.color.*
# 回显:列出所有 weechat.color. 开头的参数
# 在 shell 中通过 grep 过滤(需要已保存的配置文件)
grep '^weechat\.' ~/.weechat/weechat.conf | head -20
# 回显(节选):
# weechat.look.buffer_time_format = "%H:%M"
# weechat.look.prefix_action = " *"
# weechat.look.prefix_error = "!!"
3.2 参数命名规则
Weechat 参数采用 三段点分命名:域.子域.具体参数
weechat.look.buffer_time_format
│ │ │
│ │ └── 具体参数名
│ └─────────── 子域(look/color/network/...)
└─────────────────── 插件域(weechat 核心/irc/script/logger/...)
3.3 修改参数
# 即时修改并自动保存
/set weechat.look.buffer_time_format "%Y-%m-%d %H:%M:%S"
# 回显:Option "weechat.look.buffer_time_format" set to "%Y-%m-%d %H:%M:%S"
# 恢复默认值
/unset weechat.look.buffer_time_format
# 回显:Option "weechat.look.buffer_time_format" unset (default value restored)
# 修改后验证
/set weechat.look.buffer_time_format
# 回显:
# = weechat.look.buffer_time_format
# ├── value: "%Y-%m-%d %H:%M:%S"
# ├── default: "%H:%M"
# ├── type: string
# └── description: format for time in buffers (see strftime man page)
# 批量修改(/fset 命令配合过滤器)
/fset weechat.color.chat_* default
# 回显:批量恢复所有 chat color 参数为默认值
3.4 直接编辑配置文件
# 备份原始配置
cp ~/.weechat/weechat.conf ~/.weechat/weechat.conf.bak
# 编辑配置
nano ~/.weechat/weechat.conf
# Weechat 内热加载
/reload
# 回显:Configuration reloaded
四、参数总览(7 大类)
Weechat 4.10.1 参数按域分为以下 7 大类(含主要参数项数估算):
| 类别 | 域前缀 | 参数数量 | 说明 |
|---|---|---|---|
| 1. 核心显示/行为 | weechat. | ~80 | 颜色、外观、缓冲、键盘、鼠标 |
| 2. 核心网络/进程 | weechat.network. / weechat.plugin.* | ~20 | 连接超时、DNS、插件自动加载 |
| 3. IRC 协议插件 | irc. | ~200 | 服务器、频道、消息、SASL、反 flood |
| 4. 脚本语言配置 | script. / <lang>.script.* | ~30 | 脚本管理器、各语言路径 |
| 5. 日志与持久化 | logger. | ~15 | 日志文件路径、格式、自动创建 |
| 6. Relay 远程接口 | relay. | ~10 | 监听端口、密码、SSL、WebSocket |
| 7. 其他插件 | alias. / trigger. / xfer. / buflist. 等 | ~40 | 别名、触发器、DCC 文件传输等 |
五、核心参数分类详解
5.1 颜色域(weechat.color.*,约 50 项)
颜色参数控制终端渲染的色彩,支持 Weechat 颜色名、终端色号、带属性前缀。
| 参数 | 默认值 | 类型 | 说明 |
|---|---|---|---|
weechat.color.chat | default | color | 聊天消息正文颜色 |
weechat.color.chat_bg | default | color | 聊天消息背景色 |
weechat.color.chat_buffer | white | color | Buffer 名称颜色 |
weechat.color.chat_nick_guest | brown | color | 访客/未登录用户昵称颜色 |
weechat.color.chat_nick_user | lightgreen | color | 普通注册用户昵称颜色 |
weechat.color.chat_nick_op | lightred | color | OP(频道管理员)昵称颜色 |
weechat.color.chat_nick_away | gray | color | 离开(away)用户昵称颜色 |
weechat.color.input | default | color | 输入栏文字颜色 |
weechat.color.bar_more | lightmagenta | color | 滚动条 "+" 指示器颜色 |
weechat.color.status | default | color | 状态栏文字颜色 |
💡 颜色值格式:属性前缀 + 颜色名。属性包括
*(粗体)、!(反色)、.(半暗)、%(闪烁)、/(斜体)、_(下划线)。颜色名包括:default、black、white、gray、lightred、lightgreen、brown、yellow、lightblue、lightmagenta、lightcyan等。
修改示例:
# 把 OP 昵称改为黄色粗体
/set weechat.color.chat_nick_op "*yellow"
# 回显:Option "weechat.color.chat_nick_op" set to "*yellow"
5.2 外观域(weechat.look.*,约 30 项)
控制 Buffer 显示格式、时间戳、前缀、滚动行为等。
| 参数 | 默认值 | 类型 | 说明 |
|---|---|---|---|
weechat.look.buffer_time_format | %H:%M | string | 时间戳格式(strftime 语法) |
weechat.look.prefix_action | * | string | ACTION 消息前缀(/me 命令产生) |
weechat.look.prefix_error | !! | string | 错误消息前缀 |
weechat.look.prefix_join | --> | string | 加入频道消息前缀 |
weechat.look.prefix_quit | <-- | string | 离开频道消息前缀 |
weechat.look.scroll_amount | 3 | integer | PageUp/Down 滚动行数 |
weechat.look.scroll_move_next_buf_if_far | on | boolean | 远端滚动到顶/底时自动切换 Buffer |
weechat.look.show_away_once | on | boolean | 同一用户 away 状态变化只显示一次 |
weechat.look.typing_status | on | boolean | 显示对方正在输入状态 |
weechat.look.nicklist_display | on | boolean | 显示右侧昵称列表栏 |
修改示例:
# 时间戳改为完整日期时间
/set weechat.look.buffer_time_format "%Y-%m-%d %H:%M:%S"
# 关闭昵称列表栏(节省屏幕空间)
/set weechat.look.nicklist_display off
5.3 网络域(weechat.network.*,约 10 项)
| 参数 | 默认值 | 类型 | 说明 |
|---|---|---|---|
weechat.network.connection_timeout | 30 | integer | TCP 连接超时(秒) |
weechat.network.ssl_verify | on | boolean | 验证 TLS 证书 |
weechat.network.ssl_ca_file | (空) | string | CA 证书路径(空=使用系统默认) |
weechat.network.socks5_host | (空) | string | SOCKS5 代理主机 |
weechat.network.socks5_port | 1080 | integer | SOCKS5 代理端口 |
weechat.network.dns_timeout | 5 | integer | DNS 解析超时(秒) |
weechat.network.dns_use_ipv6 | on | boolean | 优先使用 IPv6 解析 |
5.4 插件自动加载(weechat.plugin.*)
| 参数 | 默认值 | 类型 | 说明 |
|---|---|---|---|
weechat.plugin.autoload | *,!doc | string | 启动时自动加载的插件(逗号分隔,! 排除) |
weechat.plugin.allow_missing | off | boolean | 允许加载中出现缺失依赖插件 |
weechat.plugin.check_sig | off | boolean | 验证插件签名 |
5.5 键盘与鼠标(weechat.key.* / weechat.mouse.*)
| 参数 | 默认值 | 类型 | 说明 |
|---|---|---|---|
weechat.key.default_bindings | on | boolean | 加载默认键位绑定 |
weechat.mouse.enable | on | boolean | 启用鼠标支持 |
weechat.mouse.alt_key | on | boolean | Alt 键点击触发特殊行为 |
六、IRC 协议插件参数详解
6.1 服务器域(irc.server.<name>.*)
每个已添加的 IRC 服务器会生成一组独立参数。以 libera 服务器为例:
| 参数 | 默认值 | 类型 | 说明 |
|---|---|---|---|
irc.server.libera.addresses | irc.libera.chat/6667 | string | 服务器地址/端口/SSL 标记 |
irc.server.libera.nicks | 自动生成 | string | 逗号分隔的昵称备选列表 |
irc.server.libera.username | 系统用户 | string | IRC USER 命令中的用户名 |
irc.server.libera.realname | WeeChat | string | IRC REALNAME 字段 |
irc.server.libera.autoconnect | on | boolean | Weechat 启动时自动连接 |
irc.server.libera.autoreconnect | on | boolean | 断线后自动重连 |
irc.server.libera.autoreconnect_delay | 10 | integer | 重连间隔(秒) |
irc.server.libera.ssl | off | boolean | 启用 TLS 加密(端口需同步改为 6697) |
irc.server.libera.ssl_verify | on | boolean | 验证 TLS 证书 |
irc.server.libera.sasl_username | (空) | string | SASL 认证用户名(空=使用 nicks 首项) |
irc.server.libera.sasl_password | (空) | string | SASL 认证密码 |
irc.server.libera.sasl_mechanism | (空) | string | SASL 机制(PLAIN/SCRAM-SHA-256/EXTERNAL) |
irc.server.libera.proxy | (空) | string | 代理(格式:socks5:user:pass@host:port) |
irc.server.libera.ipv6 | on | boolean | 优先 IPv6 连接 |
批量添加服务器示例:
# 通过 shell 直接编辑 irc.conf(或 Weechat 内 /server add)
cat >> ~/.weechat/irc.conf << 'EOF'
[server oftc]
addresses = "irc.oftc.net/6697"
nicks = "mynick,altnick2,altnick3"
autoconnect = on
autoreconnect = on
autoreconnect_delay = 15
ssl = on
ssl_verify = on
[server matrix]
addresses = "irc.matrix-org.matrix.org/6667"
nicks = "mynick"
autoconnect = off
EOF
# Weechat 内重载
/reload irc
6.2 IRC 全局域(irc.*,不含 server)
| 参数 | 默认值 | 类型 | 说明 |
|---|---|---|---|
irc.look.item_buffer_before | `" | "` | string |
irc.look.item_buffer_after | "" | string | Buffer 后缀 |
irc.look.nick_prefix | " | string | 频道用户模式前缀(@/+/~...) |
irc.network.default_port | 6667 | integer | 默认 IRC 端口 |
irc.network.default_ssl_port | 6697 | integer | 默认 SSL 端口 |
irc.network.dcc_get_speed_limit | 0 | integer | DCC 下载限速(KB/s,0=不限) |
irc.network.dcc_send_speed_limit | 0 | integer | DCC 上传限速(KB/s,0=不限) |
irc.msg_redirection_limit | 0 | integer | 消息重定向深度限制 |
irc.anti_flood_level | 1 | integer | 反 flood 等级(0-4) |
irc.anti_flood_max_messages | 4 | integer | 反 flood 阈值(最大消息数) |
反 flood 参数说明:
irc.anti_flood_level 控制 Weechat 向服务器发送消息时的 flood 保护策略:
0:关闭反 flood1:按服务器 RPL_ISUPPORT 中的FLOOD参数自适应2:固定速率限制3:保守模式(低频发送)4:激进模式(极低频,对抗严格的服务器)
# 设置为保守模式
/set irc.anti_flood_level 3
/set irc.anti_flood_max_messages 2
七、脚本与安全配置
7.1 脚本管理器(script.*)
| 参数 | 默认值 | 类型 | 说明 |
|---|---|---|---|
script.scripts.autoenable | on | boolean | 启动时自动启用已安装脚本 |
script.scripts.allow_disabled | on | boolean | 允许安装但不启用脚本 |
script.look.warn_remove | on | boolean | 卸载脚本前弹警告 |
script.network.https | on | boolean | 脚本下载走 HTTPS |
script.network.url | https://weechat.org/files/scripts | string | 脚本仓库 URL |
script.network.connect_timeout | 30 | integer | 脚本下载超时 |
script.lang.python.path | /usr/bin/python3 | string | Python 解释器路径 |
script.lang.perl.path | /usr/bin/perl | string | Perl 解释器路径 |
script.lang.ruby.path | /usr/bin/ruby | string | Ruby 解释器路径 |
script.lang.lua.path | /usr/bin/lua | string | Lua 解释器路径 |
# 自动更新脚本
/script update
# 回显(节选):Checking new versions of scripts...
# 安装脚本
/script install go.py
# 回显:Script "go.py" installed
# 查看已安装脚本列表
/script list
# 回显:
# Scripts:
# go.py 1.5 Go IRC bot
# notify.py 3.2 Desktop notifications
7.2 Relay 远程接口(relay.*)
relay 是 Weechat 内置的远程访问插件,支持 WebSocket + SSL:
| 参数 | 默认值 | 类型 | 说明 |
|---|---|---|---|
relay.port | 9000 | integer | WebSocket 监听端口 |
relay.ssl_port | 9001 | integer | SSL WebSocket 监听端口 |
relay.password | (空) | string | relay 密码(⚠️ 必须设置) |
relay.ssl | off | boolean | 启用 SSL |
relay.ssl_cert | (空) | string | SSL 证书路径 |
relay.ssl_key | (空) | string | SSL 私钥路径 |
relay.network.ipv6 | on | boolean | 同时监听 IPv6 |
relay.max_clients | 16 | integer | 最大同时连接客户端数 |
relay.notify | on | boolean | 新客户端连接时在 Weechat 内通知 |
启用 relay(安全加固示例):
# 设置 relay 密码
/set relay.password "ChangeMe_Str0ngP@ss"
# 回显:Option "relay.password" set to "***"
# 启动 relay 监听
/relay start
# 回显:Relay listening on port 9000 (password required)
# 查看 relay 状态
/relay list
# 回显:
# Relay "main" on port 9000 (SSL: no, clients: 0/16)
7.3 日志插件(logger.*)
| 参数 | 默认值 | 类型 | 说明 |
|---|---|---|---|
logger.file.path | ${weechat_home}/logs | string | 日志目录(支持变量展开) |
logger.file.name | ${server}.${channel}.log | string | 日志文件名模板 |
logger.file.auto_create | on | boolean | 新 Buffer 自动创建日志文件 |
logger.level | 0 | integer | 日志等级(0=所有消息,递减过滤) |
logger.file.mask | weechat.* | string | 匹配哪些 Buffer 记日志(glob) |
logger.file.size_max | 0 | integer | 日志文件单文件最大(MB,0=不限) |
logger.file.rotate | on | boolean | 超出大小自动 rotate |
变量占位符说明:${weechat_home} → Weechat 家目录,${server} → IRC 服务器名,${channel} → 频道名,${date} → 日期。
# 设置自定义日志路径
/set logger.file.path "/var/log/weechat"
# 只记录某些服务器
/set logger.file.mask "weechat.libera.*, weechat.oftc.*"
# 日志文件限 50MB + rotate
/set logger.file.size_max 50
/set logger.file.rotate on
八、生产配置模板
8.1 个人 24/7 IRC 常驻服务器模板(4GB 内存、NVMe SSD)
# ~/.weechat/weechat.conf 关键参数(其余保留默认)
[look]
buffer_time_format = "%Y-%m-%d %H:%M:%S"
scroll_amount = 3
nicklist_display = on
typing_status = on
[color]
chat_nick_op = "*yellow"
chat_nick_away = ",gray"
[network]
connection_timeout = 30
ssl_verify = on
dns_timeout = 5
[plugin]
autoload = *,!doc
# irc.conf
[server libera]
addresses = "irc.libera.chat/6697"
nicks = "my_irc_nick,altnick_"
autoconnect = on
autoreconnect = on
autoreconnect_delay = 15
ssl = on
ssl_verify = on
sasl_username = "my_irc_account"
sasl_password = "${IRC_PASS}" # 运行时注入
[irc]
anti_flood_level = 3
anti_flood_max_messages = 2
# relay.conf(启用远程访问)
[main]
port = 9001
ssl = on
ssl_cert = "/etc/letsencrypt/live/irc.example.com/fullchain.pem"
ssl_key = "/etc/letsencrypt/live/irc.example.com/privkey.pem"
password = "${RELAY_PASS}"
8.2 配置注入(systemd 环境变量)
# 在 systemd user 服务中注入敏感变量
mkdir -p ~/.config/environment.d
cat > ~/.config/environment.d/weechat.conf << 'EOF'
IRC_PASS=MySecureIrcPassword123!
RELAY_PASS=MyStrongRelayPassword456!
EOF
# 重加载 environment
systemctl --user daemon-reload
九、常见问题(FAQ)
问题 1:修改参数后不生效?
检查点:
- 参数名拼写(Weechat 参数名大小写敏感)
/reload是否执行- 是否属于特定 server 的参数(如
irc.server.libera.*需切换到对应 server)
# 检查当前参数值
/set irc.server.libera.ssl
# 确认修改
问题 2:/set 命令找不到参数?
原因:插件未加载。例如 relay.* 参数需要 relay 插件已加载。
# 检查插件是否加载
/help relay
# 手动加载缺失插件
/plugin load relay
问题 3:IRC 密码明文保存在配置文件中?
Weechat 配置文件是纯文本,不加密。解决方案:
- 设置文件权限:
chmod 600 ~/.weechat/irc.conf - 使用环境变量注入(见第八章)
- 密码在 Weechat 内通过
/set irc.server.libera.sasl_password设置后,内存中加密保存(但配置文件仍为明文)
问题 4:日志文件权限设置?
# 设置日志目录权限
chmod 700 ~/.weechat/logs
find ~/.weechat/logs -type f -exec chmod 600 {} \;
问题 5:如何导出/导入配置?
# 导出当前所有配置到文本(Weechat 内)
/helpall > ~/weechat-config-backup.txt
# 回显:Configuration dumped to ~/weechat-config-backup.txt
# 重新应用(逐条粘贴回 Weechat 内执行)
十、参考链接
- Weechat 用户手册(全量参数):https://weechat.org/files/doc/stable/weechat_user.en.html
- 官方配置示例:https://weechat.org/files/doc/stable/weechat_user.en.html#configuration_files
- IRC 插件参数详情:https://weechat.org/files/doc/stable/weechat_user.en.html#irc
- Relay 插件文档:https://weechat.org/files/doc/stable/weechat_user.en.html#relay
- Script 管理器文档:https://weechat.org/files/doc/stable/weechat_user.en.html#script
- 参数速查 Cheat Sheet(官方):https://weechat.org/files/doc/stable/weechat_quickstart.en.html
- 社区参数调优讨论:https://weechat.org/news/