Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

two spaces indent

  • Loading branch information...
commit 2b34bc29540116bdb1ddc2364c7eaa67b004abb8 1 parent 136cbe0
@alaingilbert authored
View
8 README.md
@@ -18,10 +18,10 @@ var Bot = require('ttapi');
var bot = new Bot(AUTH, USERID, ROOMID);
bot.on('speak', function (data) {
- // Respond to "/hello" command
- if (data.text.match(/^\/hello$/)) {
- bot.speak('Hey! How are you @'+data.name+' ?');
- }
+ // Respond to "/hello" command
+ if (data.text.match(/^\/hello$/)) {
+ bot.speak('Hey! How are you @'+data.name+' ?');
+ }
});
```
View
2  examples/autofan.js
@@ -12,5 +12,5 @@ var bot = new Bot(AUTH, USERID, ROOMID);
bot.on('registered', function (data) {
var name = data.user[0].name;
var command = data.command;
- bot.becomeFan(data.user[0].userid);
+ bot.becomeFan(data.user[0].userid);
});
View
14 examples/blacklist.js
@@ -14,11 +14,11 @@ var blackList = ['xxxxxxxxxxxxxxxxxxxxxxxx', 'xxxxxxxxxxxxxxxxxxxxxxxx'];
// When someone enters the room, the bot checks whether or not that user is on blacklist.
bot.on('registered', function (data) {
- var user = data.user[0];
- for (var i=0; i<blackList.length; i++) {
- if (user.userid == blackList[i]) {
- bot.bootUser(user.userid, 'You are on the blacklist.');
- break;
- }
- }
+ var user = data.user[0];
+ for (var i=0; i<blackList.length; i++) {
+ if (user.userid == blackList[i]) {
+ bot.bootUser(user.userid, 'You are on the blacklist.');
+ break;
+ }
+ }
});
View
10 examples/bop.js
@@ -12,10 +12,10 @@ var ROOMID = 'xxxxxxxxxxxxxxxxxxxxxxxx';
var bot = new Bot(AUTH, USERID, ROOMID);
bot.on('speak', function (data) {
- var text = data.text;
+ var text = data.text;
- // Any command with "bop" in it will work (ex: "bop","bop i beg you!!!","lolbopbaby", etc.)
- if (text.match(/bop/)) {
- bot.vote('up');
- }
+ // Any command with "bop" in it will work (ex: "bop","bop i beg you!!!","lolbopbaby", etc.)
+ if (text.match(/bop/)) {
+ bot.vote('up');
+ }
});
View
20 examples/bopcount.js
@@ -14,20 +14,20 @@ var bot = new Bot(AUTH, USERID, ROOMID);
bopcount = 0;
bot.on('speak', function (data) {
- var text = data.text;
+ var text = data.text;
- // Any command with "bop" in it will work (ex: "bop","bop i beg you!!!","lolbopbaby", etc.)
- if (text.match(/bop/)) {
- bopcount += 1;
- }
+ // Any command with "bop" in it will work (ex: "bop","bop i beg you!!!","lolbopbaby", etc.)
+ if (text.match(/bop/)) {
+ bopcount += 1;
+ }
- // And when the bopcount reaches two...
- if (bopcount == 2) {
- bot.vote('up');
- }
+ // And when the bopcount reaches two...
+ if (bopcount == 2) {
+ bot.vote('up');
+ }
});
// Reset bopcount per new song
bot.on('newsong', function (data) {
- bopcount = 0;
+ bopcount = 0;
});
View
14 examples/chat_bot.js
@@ -6,12 +6,12 @@ var ROOMID = 'xxxxxxxxxxxxxxxxxxxxxxxx';
var bot = new Bot(AUTH, USERID, ROOMID);
bot.on('speak', function (data) {
- // Get the data
- var name = data.name;
- var text = data.text;
+ // Get the data
+ var name = data.name;
+ var text = data.text;
- // Respond to "/hello" command
- if (text.match(/^\/hello$/)) {
- bot.speak('Hey! How are you @'+name+'?');
- }
+ // Respond to "/hello" command
+ if (text.match(/^\/hello$/)) {
+ bot.speak('Hey! How are you @'+name+'?');
+ }
});
View
34 examples/http.js
@@ -9,21 +9,21 @@ bot.listen(8080, '127.0.0.1');
var myScriptVersion = '0.0.0';
bot.on('httpRequest', function (req, res) {
- var method = req.method;
- var url = req.url;
- switch (url) {
- case '/version/':
- if (method == 'GET') {
- res.writeHead(200, { 'Content-Type': 'application/json' });
- res.end('{"version":"'+myScriptVersion+'"}');
- } else {
- res.writeHead(500);
- res.end();
- }
- break;
- default:
- res.writeHead(500);
- res.end();
- break;
- }
+ var method = req.method;
+ var url = req.url;
+ switch (url) {
+ case '/version/':
+ if (method == 'GET') {
+ res.writeHead(200, { 'Content-Type': 'application/json' });
+ res.end('{"version":"'+myScriptVersion+'"}');
+ } else {
+ res.writeHead(500);
+ res.end();
+ }
+ break;
+ default:
+ res.writeHead(500);
+ res.end();
+ break;
+ }
});
View
25 examples/modlist.js
@@ -14,19 +14,18 @@ var modList = ['xxxxxxxxxxxxxxxxxxxxxxxx', 'xxxxxxxxxxxxxxxxxxxxxxxx'];
// When someone is a moderator in the array AND types in "/mod", the bot displays a message.
bot.on('speak', function (data) {
- var name = data.name;
- var text = data.text;
- var userid = data.userid;
+ var name = data.name;
+ var text = data.text;
+ var userid = data.userid;
- for (var i=0; i<modList.length; i++) {
- if (userid == modList[i]) {
- // Respond to "/mod" command
- if (data.text.match(/^\/mod$/)) {
- bot.speak('Yo @'+data.name+', it looks like you are a bot moderator!');
- }
- // ADD other moderator commands here!
- break;
+ for (var i=0; i<modList.length; i++) {
+ if (userid == modList[i]) {
+ // Respond to "/mod" command
+ if (data.text.match(/^\/mod$/)) {
+ bot.speak('Yo @'+data.name+', it looks like you are a bot moderator!');
}
- }
-
+ // ADD other moderator commands here!
+ break;
+ }
+ }
});
View
72 examples/switch.js
@@ -13,40 +13,40 @@ var bot = new Bot(AUTH, USERID, ROOMID);
var isOn = true;
bot.on('speak', function (data) {
- var name = data.name;
- var text = data.text;
-
- //If the bot is ON
- if (isOn) {
- if (text.match(/^\/status$/)) {
- bot.speak('The bot is currently turned on.');
- }
-
- if (text.match(/^\/off$/)) {
- bot.speak('The bot is turned now off.');
- // Set the status to off
- status = false;
- }
-
- // ADD other functions here for when the bot is turned on. Like, for example:
- // Respond to "/hello" command
- if (text.match(/^\/hello$/)) {
- bot.speak('Hey! How are you @'+name+' ?');
- }
- }
-
- //If the bot is OFF
- if (!isOn) {
- if (text.match(/^\/status$/)) {
- bot.speak('The bot is currently turned off.');
- }
-
- if (text.match(/^\/on$/)) {
- bot.speak('The bot is turned now on.');
- // Set the status to on
- status = true;
- }
-
- // ADD other functions here for when the bot is turned off.
- }
+ var name = data.name;
+ var text = data.text;
+
+ //If the bot is ON
+ if (isOn) {
+ if (text.match(/^\/status$/)) {
+ bot.speak('The bot is currently turned on.');
+ }
+
+ if (text.match(/^\/off$/)) {
+ bot.speak('The bot is turned now off.');
+ // Set the status to off
+ status = false;
+ }
+
+ // ADD other functions here for when the bot is turned on. Like, for example:
+ // Respond to "/hello" command
+ if (text.match(/^\/hello$/)) {
+ bot.speak('Hey! How are you @'+name+' ?');
+ }
+ }
+
+ //If the bot is OFF
+ if (!isOn) {
+ if (text.match(/^\/status$/)) {
+ bot.speak('The bot is currently turned off.');
+ }
+
+ if (text.match(/^\/on$/)) {
+ bot.speak('The bot is turned now on.');
+ // Set the status to on
+ status = true;
+ }
+
+ // ADD other functions here for when the bot is turned off.
+ }
});
View
6 examples/tcp.js
@@ -9,7 +9,7 @@ bot.tcpListen(8080, '127.0.0.1');
var myScriptVersion = 'V0.0.0';
bot.on('tcpMessage', function (socket, msg) {
- if (msg == 'version') {
- socket.write('>> '+myScriptVersion+'\n');
- }
+ if (msg == 'version') {
+ socket.write('>> '+myScriptVersion+'\n');
+ }
});
View
44 examples/time_afk_list.js
@@ -14,54 +14,54 @@ var usersList = { };
// Add everyone in the users list.
bot.on('roomChanged', function (data) {
- usersList = { };
- for (var i=0; i<data.users.length; i++) {
- var user = data.users[i];
- user.lastActivity = new Date();
- usersList[user.userid] = user;
- }
+ usersList = { };
+ for (var i=0; i<data.users.length; i++) {
+ var user = data.users[i];
+ user.lastActivity = Date.now();
+ usersList[user.userid] = user;
+ }
});
// Someone enter the room, add him.
bot.on('registered', function (data) {
- var user = data.user[0];
- user.lastActivity = new Date();
- usersList[user.userid] = user;
+ var user = data.user[0];
+ user.lastActivity = Date.now();
+ usersList[user.userid] = user;
});
// Someone left, remove him from the users list.
bot.on('deregistered', function (data) {
- delete usersList[data.user[0].userid];
+ delete usersList[data.user[0].userid];
});
// Someone talk, update his timestamp.
bot.on('speak', function (data) {
- usersList[data.userid].lastActivity = new Date();
+ usersList[data.userid].lastActivity = Date.now();
});
// Someone vote, update his timestamp.
bot.on('update_votes', function (data) {
- var votelog = data.room.metadata.votelog;
- for (var i=0; i<votelog.length; i++) {
- var userid = votelog[i][0];
- usersList[userid].lastActivity = new Date();
- }
+ var votelog = data.room.metadata.votelog;
+ for (var i=0; i<votelog.length; i++) {
+ var userid = votelog[i][0];
+ usersList[userid].lastActivity = Date.now();
+ }
});
// Someone step up, update his timestamp.
bot.on('add_dj', function (data) {
- var user = data.user[0];
- usersList[user.userid].lastActivity = new Date();
+ var user = data.user[0];
+ usersList[user.userid].lastActivity = Date.now();
});
// Someone step down, update his timestamp.
bot.on('rem_dj', function (data) {
- var user = data.user[0];
- usersList[user.userid].lastActivity = new Date();
+ var user = data.user[0];
+ usersList[user.userid].lastActivity = Date.now();
});
// Someone add the surrent song to his playlist.
bot.on('snagged', function (data) {
- var userid = data.userid;
- usersList[userid].lastActivity = new Date();
+ var userid = data.userid;
+ usersList[userid].lastActivity = Date.now();
});
View
22 examples/users_list.js
@@ -8,22 +8,22 @@ var bot = new Bot(AUTH, USERID, ROOMID);
var theUsersList = { };
bot.on('roomChanged', function (data) {
- // Reset the users list
- theUsersList = { };
+ // Reset the users list
+ theUsersList = { };
- var users = data.users;
- for (var i=0; i<users.length; i++) {
- var user = users[i];
- theUsersList[user.userid] = user;
- }
+ var users = data.users;
+ for (var i=0; i<users.length; i++) {
+ var user = users[i];
+ theUsersList[user.userid] = user;
+ }
});
bot.on('registered', function (data) {
- var user = data.user[0];
- theUsersList[user.userid] = user;
+ var user = data.user[0];
+ theUsersList[user.userid] = user;
});
bot.on('deregistered', function (data) {
- var user = data.user[0];
- delete theUsersList[user.userid];
+ var user = data.user[0];
+ delete theUsersList[user.userid];
});
Please sign in to comment.
Something went wrong with that request. Please try again.