-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.js
55 lines (43 loc) · 1.17 KB
/
example.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
const irc = require('./index');
const config = new irc.Config({
nickname: 'nick',
username: 'user',
realname: 'the real name',
port: 6697,
host: '127.0.0.1',
tls: true,
saslUsername: 'username',
saslPassword: 'password',
});
const client = new irc.Client(config);
client.connect();
client.on('server::egistered', ({ server }) => {
console.log(`Connected to ${server}`);
client.join('#channel');
});
client.on('channel::topic', ({ channel, nick, topic }) => {
console.log(`${channel} -- "${topic}" by ${nick}`);
});
client.on('sasl::login', ({ account, error }) => {
if (error) {
console.log('SASL unsuccessful');
} else {
console.log(`I successfully negotiated SASL and logged in as ${account}`);
}
});
client.on('privmsg', () => {
console.log('I received a message!');
});
client.on('channel::join', data => {
const { channel, nick } = data;
client.privmsg(channel, `Hello there, ${nick}`);
});
client.on('channel::part', data => {
console.log(data);
});
client.on('server::motd', data => console.log(data));
client.on('error', data => console.log(data));
client.on('stream', data => {
console.log(data.type);
console.log(data);
});