-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathhandle-query.ts
More file actions
35 lines (26 loc) · 1.19 KB
/
handle-query.ts
File metadata and controls
35 lines (26 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { createSDK, handleError } from "./utils";
const ADDRESS = process.env.ADDRESS || "+1234567890";
async function main() {
const sdk = createSDK();
sdk.on("ready", async () => {
try {
// Get handle count
const totalCount = await sdk.handles.getHandleCount();
console.log(`Total handles: ${totalCount}\n`);
// Check service availability
console.log(`Service availability for ${ADDRESS}:\n`);
const hasIMessage = await sdk.handles.getHandleAvailability(ADDRESS, "imessage");
const hasFaceTime = await sdk.handles.getHandleAvailability(ADDRESS, "facetime");
console.log(`iMessage: ${hasIMessage ? "available" : "not available"}`);
console.log(`FaceTime: ${hasFaceTime ? "available" : "not available"}`);
const recommendedGuid = hasIMessage ? `iMessage;-;${ADDRESS}` : `SMS;-;${ADDRESS}`;
console.log(`\nRecommended chatGuid: ${recommendedGuid}`);
} catch (error) {
handleError(error, "Failed to query handles");
}
await sdk.close();
process.exit(0);
});
await sdk.connect();
}
main().catch(console.error);