-
-
Notifications
You must be signed in to change notification settings - Fork 58
/
Copy pathsend.js
37 lines (31 loc) · 866 Bytes
/
send.js
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
36
37
import zulip from '../../lib';
const recipient = Number(process.env.ZULIP_TYPING_RECIPIENT);
const config = {
username: process.env.ZULIP_USERNAME,
apiKey: process.env.ZULIP_API_KEY,
realm: process.env.ZULIP_REALM,
};
(async () => {
const z = await zulip(config);
// Register queue to receive typing notification events
const res = await z.queues.register({
event_types: ['typing'],
});
console.log('registered queue');
const queueID = res.queue_id;
// Send typing started notification
await z.typing.send({
to: [recipient],
op: 'start',
});
console.log('sent typing params');
// Retrieve typing events from a queue,
// blocking until there is an event (or the request times out)
console.log(
await z.events.retrieve({
queue_id: queueID,
last_event_id: -1,
dont_block: false,
})
);
})();