File size: 1,300 Bytes
e7c953d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
// Simple example of using the DubAPI library
const DubAPI = require('./index.js');

console.log('Starting DubAPI example...');

// Replace with your queup.net credentials
const username = 'kuber';
const password = 'cookTV12';

// Replace with the room you want to connect to
const roomName = 'nononono'; 

console.log('Attempting to create DubAPI instance with username:', username);
console.log('Connecting to room:', roomName);

new DubAPI({username: username, password: password}, function(err, bot) {
    if (err) return console.error('Error connecting:', err);

    console.log('Running DubAPI v' + bot.version);

    function connect() {
        console.log('Attempting to connect to room:', roomName);
        bot.connect(roomName);
    }

    bot.on('connected', function(name) {
        console.log('Connected to ' + name);
    });

    bot.on('disconnected', function(name) {
        console.log('Disconnected from ' + name);
        console.log('Attempting to reconnect in 15 seconds...');
        setTimeout(connect, 15000);
    });

    bot.on('error', function(err) {
        console.error('Error:', err);
    });

    bot.on(bot.events.chatMessage, function(data) {
        console.log(data.user.username + ': ' + data.message);
    });

    // Connect to the room
    connect();
});