(client: TelegramClient, arg: string)
| 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 | |
| 1438 | function fmtTime(iso: string): string { |
| 1439 | return new Date(iso).toLocaleString("zh-CN", { timeZone: "Asia/Shanghai" }); |
| 1440 | } |
| 1441 | |
| 1442 | // ─── 帮助文本 ───────────────────────────────────────────────────────────────── |
no test coverage detected