Add room-scoped Matrix plugins and bilingual configuration commands
This commit is contained in:
1 parent
061bfbd12a
commit
f4f30c3b5c
75 files changed
+2559
-1975
No files matched your search
@@ -4,5 +4,6 @@
|
||||
!.gitignore
|
||||
!cross-sign/
|
||||
!cross-sign/**
|
||||
!test-network-guard.cjs
|
||||
# 但 cross-sign 下的依赖仍不提交。
|
||||
cross-sign/node_modules/
|
||||
@@ -29,11 +29,11 @@ node ./cross-sign.mjs
|
||||
|
||||
然后按提示**交互式粘贴**即可(无需任何环境变量 / 配置文件):
|
||||
|
||||
1. 账号域名或 API 地址(回车用默认 `tchncs.de`)
|
||||
2. 账号 user id(回车用默认 `@eskimapro:tchncs.de`)
|
||||
1. 输入账号域名或 API 地址
|
||||
2. 输入完整的 Matrix 用户 ID,例如 `@bot:example.org`
|
||||
3. 账号密码 —— **粘贴时不回显**
|
||||
4. 安全密钥(base58,如 `EsTc ...`)—— 不回显;直接回车则改填安全短语
|
||||
5. 要签名的设备 ID(回车用默认 `ZHEAJZJMDZ`;留空则签名名下所有未验证设备)
|
||||
5. 输入要签名的设备 ID。留空后还需输入 `ALL` 才会签名所有未验证设备。
|
||||
|
||||
跑一次即可,之后无需再跑(除非 bot 重新登录产生了新设备)。
|
||||
|
||||
|
||||
@@ -60,8 +60,10 @@ let TARGET_DEVICE_ID = '';
|
||||
async function main() {
|
||||
console.log('=== bot 设备 cross-signing 工具 ===\n');
|
||||
|
||||
const homeserverInput = await ask('账号域名或 API 地址', 'tchncs.de');
|
||||
const userId = await ask('账号 user id', '@eskimapro:tchncs.de');
|
||||
const homeserverInput = await ask('账号域名或 API 地址');
|
||||
if (!homeserverInput) fail('必须输入账号域名或 API 地址。');
|
||||
const userId = await ask('账号 user id');
|
||||
if (!userId) fail('必须输入账号 ID。');
|
||||
PASSWORD = await askSecret('账号密码(粘贴,不回显)');
|
||||
if (!PASSWORD) fail('必须输入密码。');
|
||||
|
||||
@@ -80,10 +82,10 @@ async function main() {
|
||||
if (!SECURITY_PHRASE) fail('安全密钥和安全短语必须至少提供一个。');
|
||||
}
|
||||
|
||||
TARGET_DEVICE_ID = await ask(
|
||||
'要签名的设备 ID(留空=签名名下所有未验证设备)',
|
||||
'ZHEAJZJMDZ',
|
||||
);
|
||||
TARGET_DEVICE_ID = await ask('要签名的设备 ID');
|
||||
if (!TARGET_DEVICE_ID && await ask('签名所有未验证设备?输入 ALL 确认') !== 'ALL') {
|
||||
fail('未选择签名目标。');
|
||||
}
|
||||
|
||||
// 1) 解析真实 API 地址(支持裸域名 well-known 发现)
|
||||
const baseUrl = await resolveBaseUrl(homeserverInput);
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
const blocked = () => { throw new Error('Network access is disabled in test subprocesses'); };
|
||||
require('node:http').request = blocked;
|
||||
require('node:http').get = blocked;
|
||||
require('node:https').request = blocked;
|
||||
require('node:https').get = blocked;
|
||||
require('node:net').Socket.prototype.connect = blocked;
|
||||
require('node:tls').connect = blocked;
|
||||
global.fetch = blocked;
|
||||
const fs = require('node:fs');
|
||||
const exists = fs.existsSync.bind(fs);
|
||||
const read = fs.readFileSync.bind(fs);
|
||||
const privateConfiguration = path => typeof path === 'string' &&
|
||||
(/(^|\/)\.env(?:\..*)?$/.test(path) || /(^|\/)config\/bots\.yaml$/.test(path));
|
||||
fs.existsSync = path => privateConfiguration(path) ? false : exists(path);
|
||||
fs.readFileSync = (path, ...args) => {
|
||||
if (privateConfiguration(path)) throw new Error('Runtime configuration is unavailable in tests');
|
||||
return read(path, ...args);
|
||||
};
|
||||
Reference in new issue
Block a user