forked from GitHub/dbot
changed to literal notation
This commit is contained in:
parent
63d1256cae
commit
dc1a44b9cb
48
run.js
48
run.js
@ -5,7 +5,7 @@ jsbot = require('./jsbot');
|
|||||||
|
|
||||||
Array.prototype.random = function() {
|
Array.prototype.random = function() {
|
||||||
return this[Math.floor((Math.random()*this.length))];
|
return this[Math.floor((Math.random()*this.length))];
|
||||||
}
|
};
|
||||||
|
|
||||||
///////////////////////////
|
///////////////////////////
|
||||||
|
|
||||||
@ -20,25 +20,25 @@ var instance = jsbot.createJSBot(name, 'elara.ivixor.net', 6667, function() {
|
|||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
instance.addListener('JOIN', function(data) {
|
instance.addListener('JOIN', function(data) {
|
||||||
if(data['user'] == 'Lamp') {
|
if(data.user == 'Lamp') {
|
||||||
instance.say(data['channel'], db.lampPuns.random());
|
instance.say(data.channel, db.lampPuns.random());
|
||||||
} else if(instance.inChannel(data['channel'])) {
|
} else if(instance.inChannel(data.channel)) {
|
||||||
instance.say('aisbot', '.karma ' + data['user']);
|
instance.say('aisbot', '.karma ' + data.user);
|
||||||
waitingForKarma = data['channel'];
|
waitingForKarma = data.channel;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
instance.addListener('KICK', function(data) {
|
instance.addListener('KICK', function(data) {
|
||||||
if(data['kickee'] == name) {
|
if(data.kickee == name) {
|
||||||
instance.join(data['channel']);
|
instance.join(data.channel);
|
||||||
} else {
|
} else {
|
||||||
instance.say(data['channel'], data['kickee'] + '--');
|
instance.say(data.channel, data.kickee + '--');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
instance.addListener('PRIVMSG', function(data) {
|
instance.addListener('PRIVMSG', function(data) {
|
||||||
if(data['user'] == 'aisbot' && data['channel'] == name && waitingForKarma != false) {
|
if(data.user == 'aisbot' && data.channel == name && waitingForKarma != false) {
|
||||||
var split = data['message'].split(' ');
|
var split = data.message.split(' ');
|
||||||
var target = split[0];
|
var target = split[0];
|
||||||
var karma = split[3];
|
var karma = split[3];
|
||||||
|
|
||||||
@ -55,8 +55,8 @@ instance.addListener('PRIVMSG', function(data) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
instance.addListener('PRIVMSG', function(data) {
|
instance.addListener('PRIVMSG', function(data) {
|
||||||
if(data['user'] == admin && data['channel'] == name) {
|
if(data.user == admin && data.channel == name) {
|
||||||
params = data['message'].split(' ');
|
params = data.message.split(' ');
|
||||||
switch(params[0]) {
|
switch(params[0]) {
|
||||||
case 'join':
|
case 'join':
|
||||||
instance.join(params[1]);
|
instance.join(params[1]);
|
||||||
@ -84,32 +84,32 @@ instance.addListener('PRIVMSG', function(data) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
instance.addListener('PRIVMSG', function(data) {
|
instance.addListener('PRIVMSG', function(data) {
|
||||||
if(instance.inChannel(data['channel']) && data['message'].startsWith('~')) {
|
if(instance.inChannel(data.channel) && data.message.startsWith('~')) {
|
||||||
var params = data['message'].split(' ');
|
var params = data.message.split(' ');
|
||||||
switch(params[0]) {
|
switch(params[0]) {
|
||||||
case '~kc':
|
case '~kc':
|
||||||
instance.say('aisbot', '.karma ' + data['message'].split(' ')[1]);
|
instance.say('aisbot', '.karma ' + data.message.split(' ')[1]);
|
||||||
waitingForKarma = data['channel'];
|
waitingForKarma = data.channel;
|
||||||
break;
|
break;
|
||||||
case '~qset':
|
case '~qset':
|
||||||
var qset = data['message'].match(/~qset ([\d\w\s]*)=(.+)$/);
|
var qset = data.message.match(/~qset ([\d\w\s]*)=(.+)$/);
|
||||||
if(qset != null && qset.length >= 3) {
|
if(qset != null && qset.length >= 3) {
|
||||||
db.quotes[qset[1]] = qset[2];
|
db.quotes[qset[1]] = qset[2];
|
||||||
instance.say(data['channel'], 'Quote saved as \'' + qset[1] + '\'');
|
instance.say(data.channel, 'Quote saved as \'' + qset[1] + '\'');
|
||||||
fs.writeFile('db.json', JSON.stringify(db, null, ' '));
|
fs.writeFile('db.json', JSON.stringify(db, null, ' '));
|
||||||
} else {
|
} else {
|
||||||
instance.say(data['channel'], 'Burn the invalid syntax!');
|
instance.say(data.channel, 'Burn the invalid syntax!');
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '~q':
|
case '~q':
|
||||||
var q = data['message'].match(/~q ([\d\w\s]*)/)[1].trim();
|
var q = data.message.match(/~q ([\d\w\s]*)/)[1].trim();
|
||||||
instance.say(data['channel'], q + ': ' + db.quotes[q]);
|
instance.say(data.channel, q + ': ' + db.quotes[q]);
|
||||||
break;
|
break;
|
||||||
case '~lamp':
|
case '~lamp':
|
||||||
instance.say(data['channel'], db.lampPuns.random());
|
instance.say(data.channel, db.lampPuns.random());
|
||||||
break;
|
break;
|
||||||
case '~rq':
|
case '~rq':
|
||||||
instance.say(data['channel'], Object.values(db.quotes).random());
|
instance.say(data.channel, Object.values(db.quotes).random());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user