MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / setProxyHost

Method setProxyHost

zpr/zpr.ts:205–240  ·  view source on GitHub ↗
(host: string)

Source from the content-addressed store, hash-verified

203 if (!this.db) {
204 console.error("[zpr] 数据库未初始化");
205 return false;
206 }
207
208 // 防止并发写入
209 if (this.isWriting) {
210 console.log("[zpr] 配置正在写入中,请稍后");
211 return false;
212 }
213
214 this.isWriting = true;
215 try {
216 // 验证输入参数
217 if (!host || typeof host !== 'string') {
218 console.error("[zpr] 无效的代理地址");
219 return false;
220 }
221
222 // 创建备份
223 await this.createBackup();
224
225 // 更新配置数据
226 this.db.data[CONFIG_KEYS.PROXY_HOST] = host;
227
228 // 写入配置,增强重试机制
229 return await this.writeConfigWithRetry();
230 } catch (error) {
231 console.error("[zpr] 设置代理失败:", error);
232 return false;
233 } finally {
234 this.isWriting = false;
235 }
236 }
237}
238
239// 帮助文本定义
240const help_text = `🎨 <b>随机纸片人插件</b>
241
242<b>命令格式:</b>
243<code>${mainPrefix}zpr [参数]</code>

Callers 2

getResultFunction · 0.80
ZprPluginClass · 0.80

Calls 4

ensureInitializedMethod · 0.95
createBackupMethod · 0.95
writeConfigWithRetryMethod · 0.95
errorMethod · 0.80

Tested by

no test coverage detected