6

About

ChatExchange is a node.js API for talking to Stack Exchange chat (Largely based on ChatExchange for python). This is still very much in the works, but currently provides a working API for those who wish to connect to chat and send/receive basic messages.
Currently looking for interested developers who want to provide input and utilize this framework in their apps.

Code Snippet

const Client = require('chatexchange');

const main = async () => {
    const client = new Client('stackoverflow.com');

    await client.login('EMAIL', 'PASSWORD');

    const me = await client.getMe();

    const room = await client.joinRoom(167908);

    room.on('message', async msg => {
        console.log('Got Message', msg);

        // eventType 8 (Someone has messaged me)
        if (msg.eventType === 8 && msg.targetUserId === me.id) {
            await msg.reply('Hello World!');
        }
    });

    // Connect to the room, and listen for new events
    await room.watch();
}

main();

Download

Available through npm, you can simply download with:

$ npm i chatexchange

License

All code is licensed under GPL-3.0.

Code

You can find all the source code on GitHub.

Documentation can be found here.

0

You must log in to answer this question.

Browse other questions tagged .