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

Function handleConfig

banana/banana.ts:208–289  ·  view source on GitHub ↗
(
  msg: Api.Message,
  subcommand: string,
  subValue: string,
)

Source from the content-addressed store, hash-verified

206 });
207 return;
208 }
209 await setConfigValue("apiKey", subValue.trim());
210 await msg.edit({ text: "✅ 已更新 Gemini API Key" });
211 return;
212 }
213 case "limit": {
214 if (!subValue) {
215 const current = await resolveMaxImageBytes();
216 await msg.edit({
217 text: `当前图片大小上限:${formatBytes(current)}(范围 ${formatBytes(MIN_ALLOWED_IMAGE_BYTES)} - ${formatBytes(MAX_ALLOWED_IMAGE_BYTES)})\n使用 <code>${mainPrefix}banana limit default</code> 可恢复默认值`,
218 parseMode: "html",
219 });
220 return;
221 }
222
223 const lowered = subValue.trim().toLowerCase();
224 if (lowered === "default" || lowered === "reset") {
225 await setConfigValue("maxBytes", DEFAULT_MAX_IMAGE_BYTES);
226 await msg.edit({
227 text: `✅ 已恢复默认图片大小上限 ${formatBytes(DEFAULT_MAX_IMAGE_BYTES)}`,
228 });
229 return;
230 }
231
232 const parsed = parseSizeInput(subValue);
233 if (parsed === null) {
234 await msg.edit({
235 text: "❌ 无法识别的大小,请使用如 `8`, `8MB`, `2048KB`、`0.5GB` 等格式。",
236 });
237 return;
238 }
239
240 if (parsed < MIN_ALLOWED_IMAGE_BYTES) {
241 await msg.edit({
242 text: `❌ 数值过小,最小支持 ${formatBytes(MIN_ALLOWED_IMAGE_BYTES)}`,
243 });
244 return;
245 }
246
247 if (parsed > MAX_ALLOWED_IMAGE_BYTES) {
248 await msg.edit({
249 text: `❌ 数值过大,最大支持 ${formatBytes(MAX_ALLOWED_IMAGE_BYTES)}`,
250 });
251 return;
252 }
253
254 await setConfigValue("maxBytes", parsed);
255 await msg.edit({
256 text: `✅ 已将图片大小上限设置为 ${formatBytes(parsed)}`,
257 });
258 return;
259 }
260 case "config": {
261 const [apiKey, maxBytes] = await Promise.all([
262 getConfigValue("apiKey"),
263 resolveMaxImageBytes(),
264 ]);
265 await msg.edit({

Callers 1

handleBananaCommandFunction · 0.85

Calls 7

setConfigValueFunction · 0.85
resolveMaxImageBytesFunction · 0.85
parseSizeInputFunction · 0.85
getConfigValueFunction · 0.85
maskKeyFunction · 0.85
formatBytesFunction · 0.70
editMethod · 0.45

Tested by

no test coverage detected