-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchat_bot.js
More file actions
71 lines (60 loc) · 1.9 KB
/
chat_bot.js
File metadata and controls
71 lines (60 loc) · 1.9 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
var Bot = require('../index');
var AUTH = '';
var USERID = '';
var ROOMID = '';
var bot = new Bot(AUTH, USERID, ROOMID);
//bot.debug = true;
bot.on('speak', function (data) {
// Get the data
var name = data.name;
var userID = data.userid;
var text = data.text;
// Respond to "/hello" command
if (text.match(/^\/hello$/)) {
bot.speak('Hey! How are you @'+name+'?');
}
if (text.match(/^\/play$/)) {
console.log('I\'ve been asked to play music');
if(userID = '4f42adc4590ca27dbb004ade') {
bot.addDj();
}
}
if (text.match(/^\/stop$/)) {
console.log('My songs are bad, and I should feel bad');
if (userID = '4f42adc4590ca27dbb004ade') {
bot.remDj();
}
}
});
bot.on('registered', function(data) {
var user = data.user[0];
console.log(user.name+' just entered the room.');
if(user.userid != '50bc2750aaa5cd5f9938fc3b') {
bot.speak('Welcome to the machine @'+user.name+'!');
};
});
bot.on('speak', function (data) {
var text = data.text;
if (text.match(/^\/help$/)) {
console.log('Someone invoked the help command');
bot.speak('I am bot-A-tron, please insert music.');
}
});
bot.on('newsong', function (data) {
var userid = data.userid;
if(userid != '50bc2750aaa5cd5f9938fc3b'){
songID = data.room.metadata.current_song._id;
bot.playlistAdd(songID);
console.log('I just added a song to my queue.');
}
});
bot.on('add_dj', function (data) {
var dj = data.user[0].name;
console.log('DJ '+dj+ ' just got up on the decks');
});
/* Logger stuff below here
bot.on('ready', function (data) { bot.roomRegister(ROOMID); });
bot.on('roomChanged', function (data) { console.log('The bot has changed room.', data); });
bot.on('speak', function (data) { console.log('Someone has spoken', data); });
bot.on('update_votes', function (data) { console.log('Someone has voted', data); });
bot.on('registered', function (data) { console.log('Someone registered', data); }); */