MCPcopy Create free account
hub / github.com/QLHazyCoder/FlowPilot / getGroupByName

Function getGroupByName

content/sub2api-panel.js:169–189  ·  view source on GitHub ↗
(origin, token, groupName)

Source from the content-addressed store, hash-verified

167}
168
169async function getGroupByName(origin, token, groupName) {
170 const targetName = (groupName || SUB2API_DEFAULT_GROUP_NAME).trim() || SUB2API_DEFAULT_GROUP_NAME;
171 const groups = await requestJson(origin, '/api/v1/admin/groups/all', {
172 method: 'GET',
173 token,
174 });
175
176 const normalized = targetName.toLowerCase();
177 const group = (groups || []).find((item) => {
178 const itemName = String(item?.name || '').trim().toLowerCase();
179 if (!itemName) return false;
180 if (itemName !== normalized) return false;
181 return !item.platform || item.platform === 'openai';
182 });
183
184 if (!group) {
185 throw new Error(`SUB2API 中未找到名为“${targetName}”的 openai 分组。`);
186 }
187
188 return group;
189}
190
191function buildDraftAccountName(groupName) {
192 const prefix = (groupName || SUB2API_DEFAULT_GROUP_NAME)

Callers 2

Calls 1

requestJsonFunction · 0.85

Tested by

no test coverage detected