MCPcopy
hub / github.com/ValueCell-ai/ClawX / fetchWeChatQrCode

Function fetchWeChatQrCode

electron/utils/wechat-login.ts:245–260  ·  view source on GitHub ↗
(apiBaseUrl: string, accountId?: string, botType = DEFAULT_ILINK_BOT_TYPE)

Source from the content-addressed store, hash-verified

243}
244
245async function fetchWeChatQrCode(apiBaseUrl: string, accountId?: string, botType = DEFAULT_ILINK_BOT_TYPE): Promise<QrCodeResponse> {
246 const base = apiBaseUrl.endsWith('/') ? apiBaseUrl : `${apiBaseUrl}/`;
247 const url = new URL(`ilink/bot/get_bot_qrcode?bot_type=${encodeURIComponent(botType)}`, base);
248 const headers: Record<string, string> = {};
249 const routeTag = loadWeChatRouteTag(accountId);
250 if (routeTag) {
251 headers.SKRouteTag = routeTag;
252 }
253
254 const response = await fetch(url.toString(), { headers });
255 if (!response.ok) {
256 const body = await response.text().catch(() => '(unreadable)');
257 throw new Error(`Failed to fetch QR code: ${response.status} ${response.statusText} ${body}`);
258 }
259 return await response.json() as QrCodeResponse;
260}
261
262async function pollWeChatQrStatus(apiBaseUrl: string, qrcode: string, accountId?: string): Promise<QrStatusResponse> {
263 const base = apiBaseUrl.endsWith('/') ? apiBaseUrl : `${apiBaseUrl}/`;

Callers 2

startWeChatLoginSessionFunction · 0.85

Calls 1

loadWeChatRouteTagFunction · 0.85

Tested by

no test coverage detected