MCPcopy Index your code
hub / github.com/TeleBoxOrg/TeleBox_Plugins / resolveUser

Function resolveUser

pmcaptcha/pmcaptcha.ts:1423–1439  ·  view source on GitHub ↗
(client: TelegramClient, arg: string)

Source from the content-addressed store, hash-verified

1421 if (/^\d+$/.test(arg)) {
1422 const id = parseInt(arg);
1423 fetchUserInfo(client, id).catch(() => {});
1424 return id > 0 ? id : null;
1425 }
1426 try {
1427 const username = arg.replace(/^@/, "");
1428 const res = await client.invoke(new Api.contacts.ResolveUsername({ username })) as any;
1429 const user = res?.users?.[0];
1430 if (user && !(user instanceof Api.UserEmpty)) {
1431 cacheUserFromSender(user);
1432 return Number(user.id);
1433 }
1434 return null;
1435 } catch { return null; }
1436}
1437
1438function fmtTime(iso: string): string {
1439 return new Date(iso).toLocaleString("zh-CN", { timeZone: "Asia/Shanghai" });
1440}
1441
1442// ─── 帮助文本 ─────────────────────────────────────────────────────────────────

Callers 1

pmcaptchaFunction · 0.85

Calls 2

fetchUserInfoFunction · 0.85
cacheUserFromSenderFunction · 0.85

Tested by

no test coverage detected