modified: package.json

modified:   src/main.js
	new file:   src/trigger/stats.js
This commit is contained in:
Flummi 2016-08-25 00:28:40 +02:00
parent 2fbffc0574
commit 68249b6af2
3 changed files with 25 additions and 10 deletions

View File

@ -7,6 +7,7 @@
}, },
"dependencies": { "dependencies": {
"coffea": "^0.4.24", "coffea": "^0.4.24",
"du": "^0.1.0",
"fs-extra": "^0.30.0", "fs-extra": "^0.30.0",
"mime": "^1.3.4", "mime": "^1.3.4",
"mysql": "^2.11.1", "mysql": "^2.11.1",

View File

@ -42,18 +42,13 @@ bot.on('motd', (e) => {
bot.on('message', (e) => { bot.on('message', (e) => {
trigger.trigger.forEach((entry,i,a) => { trigger.trigger.forEach((entry,i,a) => {
//if(entry.call.test(e.message) && entry.active == 1) {
//if(e.message.match(new RegExp(entry.call, entry.flags)) && entry.active == 1) {
if(e.message.match(entry.call) && entry.active == 1) { if(e.message.match(entry.call) && entry.active == 1) {
lib.log('trigger: '+entry.name); lib.log('trigger: '+entry.name);
lib.getUserlevel(e, (cb) => { lib.getUserlevel(e, (cb) => {
//setTimeout(()=>{ if(cb.level >= entry.level)
if(cb.level >= entry.level) { entry.func(e);
entry.func(e); else
} e.reply('no permission, min level '+entry.level+' required');
else
e.reply('no permission, min level '+entry.level+' required');
//}, 200);
}); });
} }
}); });
@ -70,7 +65,6 @@ var trigger = {
trigger.trigger.push({ trigger.trigger.push({
name: args.name, name: args.name,
call: args.call, call: args.call,
//flags: args.flags,
func: args.func, func: args.func,
desc: args.desc, desc: args.desc,
level: args.level, level: args.level,

20
src/trigger/stats.js Normal file
View File

@ -0,0 +1,20 @@
var du = require('du');
module.exports = (bot, trigger, lib) => {
trigger.add({
name: 'stats',
call: /^\!stats$/i,
level: 10,
active: 1,
func: (e) => {
lib.sql.query("select count(`id`) as anzahl from `f0ck`.`items`", (err, rows, fields) => {
var ret = "f0cked "+String(rows[0].anzahl);
du('./b/', function (err, size) {
ret += " f0cks ("+lib.formatSize(size)+")";
e.reply(ret);
})
});
},
desc: 'stats'
});
};