|
3 | 3 | * |
4 | 4 | * Run: bun run examples/quickstart-connect.ts |
5 | 5 | */ |
6 | | -import { Client } from '../src/index.js' |
| 6 | +import { Client } from "../src/index.js"; |
7 | 7 |
|
8 | | -const client = new Client() |
| 8 | +const client = new Client(); |
9 | 9 |
|
10 | | -client.on('qr', ({ qrString }) => console.log('Scan QR:', qrString)) |
11 | | -client.on('connect', ({ me }) => console.log('Connected as', me.id)) |
| 10 | +client.on("qr", ({ qrString }) => console.log("Scan QR:", qrString)); |
| 11 | +client.on("connect", ({ me }) => console.log("Connected as", me.id)); |
12 | 12 |
|
13 | | -client.on('text', async (msg) => { |
14 | | - console.log('Received:', msg.senderId, '|', msg.text) |
| 13 | +client.on("message", async (msg) => { |
| 14 | + const roomName = await msg.roomName(); |
| 15 | + console.log("Received text:", msg); |
| 16 | + console.log("Main Room Name", roomName); |
15 | 17 |
|
16 | | - const quoted = await msg.replied() |
17 | | - if (quoted) console.log('In reply to:', quoted.senderId, '|', quoted.text) |
| 18 | + const quoted = await msg.replied(); |
18 | 19 |
|
19 | | - await client.send(msg.senderId).text(`Halo ${msg.senderName ?? ''}! You said: ${msg.text}`) |
20 | | -}) |
| 20 | + if (quoted) { |
| 21 | + const quotedRoomName = await quoted.roomName(); |
| 22 | + console.log("Quoted Room Name", quotedRoomName); |
| 23 | + console.log("In reply to:", quoted); |
| 24 | + } |
| 25 | +}); |
0 commit comments