@wu529778790/open-im 0.3.11 → 0.3.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config.d.ts +1 -0
- package/dist/config.js +2 -0
- package/dist/setup.js +7 -0
- package/dist/telegram/client.js +16 -1
- package/package.json +2 -1
package/dist/config.d.ts
CHANGED
package/dist/config.js
CHANGED
|
@@ -91,6 +91,7 @@ export function loadConfig() {
|
|
|
91
91
|
}
|
|
92
92
|
const logDir = process.env.LOG_DIR ?? file.logDir ?? join(APP_HOME, 'logs');
|
|
93
93
|
const logLevel = (process.env.LOG_LEVEL?.toUpperCase() ?? file.logLevel ?? 'INFO');
|
|
94
|
+
const proxy = process.env.HTTP_PROXY ?? process.env.HTTPS_PROXY ?? process.env.ALL_PROXY ?? file.proxy;
|
|
94
95
|
return {
|
|
95
96
|
enabledPlatforms,
|
|
96
97
|
telegramBotToken,
|
|
@@ -104,5 +105,6 @@ export function loadConfig() {
|
|
|
104
105
|
claudeModel: process.env.CLAUDE_MODEL ?? file.claudeModel,
|
|
105
106
|
logDir,
|
|
106
107
|
logLevel,
|
|
108
|
+
proxy,
|
|
107
109
|
};
|
|
108
110
|
}
|
package/dist/setup.js
CHANGED
|
@@ -52,6 +52,12 @@ export async function runInteractiveSetup() {
|
|
|
52
52
|
message: '白名单用户 ID(可选,逗号分隔,留空=所有人可访问)',
|
|
53
53
|
initial: '',
|
|
54
54
|
},
|
|
55
|
+
{
|
|
56
|
+
type: 'text',
|
|
57
|
+
name: 'proxy',
|
|
58
|
+
message: '代理地址(可选,用于访问 Telegram,如: http://127.0.0.1:7890 或 socks5://127.0.0.1:1080)',
|
|
59
|
+
initial: '',
|
|
60
|
+
},
|
|
55
61
|
{
|
|
56
62
|
type: 'select',
|
|
57
63
|
name: 'aiCommand',
|
|
@@ -82,6 +88,7 @@ export async function runInteractiveSetup() {
|
|
|
82
88
|
.map((s) => s.trim())
|
|
83
89
|
.filter(Boolean)
|
|
84
90
|
: [],
|
|
91
|
+
proxy: response.proxy ? response.proxy.trim() : undefined,
|
|
85
92
|
claudeWorkDir: (response.workDir || process.cwd()).trim(),
|
|
86
93
|
claudeSkipPermissions: true,
|
|
87
94
|
aiCommand: response.aiCommand ?? 'claude',
|
package/dist/telegram/client.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Telegraf } from 'telegraf';
|
|
2
2
|
import { createLogger } from '../logger.js';
|
|
3
|
+
import { HttpsProxyAgent } from 'https-proxy-agent';
|
|
3
4
|
const log = createLogger('Telegram');
|
|
4
5
|
let bot;
|
|
5
6
|
let botUsername;
|
|
@@ -12,7 +13,21 @@ export function getBotUsername() {
|
|
|
12
13
|
return botUsername;
|
|
13
14
|
}
|
|
14
15
|
export async function initTelegram(config, setupHandlers) {
|
|
15
|
-
|
|
16
|
+
const telegrafOptions = {};
|
|
17
|
+
// 配置代理
|
|
18
|
+
if (config.proxy) {
|
|
19
|
+
try {
|
|
20
|
+
const agent = new HttpsProxyAgent(config.proxy);
|
|
21
|
+
telegrafOptions.telegram = {
|
|
22
|
+
agent,
|
|
23
|
+
};
|
|
24
|
+
log.info(`Using proxy: ${config.proxy}`);
|
|
25
|
+
}
|
|
26
|
+
catch (err) {
|
|
27
|
+
log.warn(`Failed to create proxy agent: ${err}. Continuing without proxy.`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
bot = new Telegraf(config.telegramBotToken, telegrafOptions);
|
|
16
31
|
setupHandlers(bot);
|
|
17
32
|
const me = (await bot.telegram.getMe());
|
|
18
33
|
botUsername = me.username;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wu529778790/open-im",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.12",
|
|
4
4
|
"description": "Multi-platform IM bridge for AI CLI tools (Claude, Codex, Cursor)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"url": "https://github.com/wu529778790/open-im/issues"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
+
"https-proxy-agent": "^7.0.6",
|
|
44
45
|
"prompts": "^2.4.2",
|
|
45
46
|
"telegraf": "^4.16.3"
|
|
46
47
|
},
|