mirror of
https://git.sr.ht/~emerson/reflectionircd
synced 2025-04-13 09:59:52 +00:00
32 lines
No EOL
1.1 KiB
JavaScript
32 lines
No EOL
1.1 KiB
JavaScript
import { readFileSync } from "fs";
|
|
import { connect } from "tls";
|
|
|
|
const config = JSON.parse(readFileSync(process.argv[2]));
|
|
|
|
const client = connect({
|
|
host: 'localhost',
|
|
port: config["port"],
|
|
rejectUnauthorized: false
|
|
}, () => {
|
|
client.write("CAP LS 302\r\n");
|
|
client.write("CAP REQ :account-tag batch draft/channel-rename echo-message reflectionircd.chat/edit-message reflectionircd.chat/extended-invite extended-join invite-notify labeled-response message-tags sasl server-time\r\n");
|
|
const saslPassword = Buffer.from(`\0user\0${config.SASLPassword}`).toString('base64');
|
|
client.write(`AUTHENTICATE ${saslPassword}\r\n`)
|
|
client.write("CAP END\r\n")
|
|
process.stdin.pipe(client);
|
|
process.stdin.resume();
|
|
})
|
|
|
|
client.setEncoding('utf8');
|
|
client.on('data', (data) => {
|
|
const dataArray = data.toString().split('\r\n');
|
|
dataArray.forEach(m => {
|
|
const trimmedMsg = m.replace('\r', '').replace('\n', '');
|
|
if (trimmedMsg !== '') {
|
|
console.log(`--> ${trimmedMsg}`);
|
|
}
|
|
});
|
|
});
|
|
client.on('end', () => {
|
|
console.log('server ends connection');
|
|
}); |