added channel records
This commit is contained in:
parent
edd5031a3e
commit
4920ce213c
@ -3,19 +3,25 @@ module.exports = (lib) => {
|
||||
lib.bot.whois(e.user.getNick(), e.network, (err, data) => {
|
||||
if(data.account !== null) {
|
||||
lib.getUserlevel(e.user.getNick(), e.network, e.channel, (cb) => {
|
||||
var modes = false;
|
||||
if(cb.level >= 70)
|
||||
modes = "+ao";
|
||||
else if(cb.level >= 60)
|
||||
modes = "+o";
|
||||
else if(cb.level >= 50)
|
||||
modes = "+h";
|
||||
else if(cb.level >= 10)
|
||||
modes = "+v";
|
||||
if(modes !== false)
|
||||
var modes = lib.levelToModes(cb.level);
|
||||
modes = '+' + modes;
|
||||
if(modes !== "")
|
||||
lib.bot.mode(e.channel, modes + (' '+e.user.getNick()).repeat(modes.length-1), e.network);
|
||||
});
|
||||
}
|
||||
});
|
||||
if(e.channel.names && e.user.nick !== lib.bot.me.nick) {
|
||||
var userCount = Object.keys(e.channel.names).length;
|
||||
lib.sql.query('select value from `f0ck`.`vars` where `key` = "highest_user_count" AND `channel` = ? AND `network` = ? limit 1', [e.channel.getName(), e.network], (err, rows) => {
|
||||
if(!rows.length) {
|
||||
lib.sql.query('insert into `f0ck`.`vars` (`key`,`value`,`channel`,`network`) values ("highest_user_count",?,?,?)', [userCount, e.channel.getName(), e.network]);
|
||||
e.reply('New user record for ' + e.channel.getName() + ': ' + userCount);
|
||||
}
|
||||
else if(parseInt(rows[0].value) < userCount) {
|
||||
lib.sql.query('update `f0ck`.`vars` set `value` = ? where `key` = "highest_user_count" AND `channel` = ? AND `network` = ? limit 1', [userCount, e.channel.getName(), e.network]);
|
||||
e.reply('New user record for ' + e.channel.getName() + ': ' + userCount);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
18
src/trigger/record.js
Normal file
18
src/trigger/record.js
Normal file
@ -0,0 +1,18 @@
|
||||
module.exports = (lib) => {
|
||||
lib.trigger.add({
|
||||
name: 'record',
|
||||
call: /^\!record$/i,
|
||||
level: 0,
|
||||
active: 1,
|
||||
func: (e) => {
|
||||
lib.sql.query('select value from `f0ck`.`vars` where `key` = "highest_user_count" AND `channel` = ? AND `network` = ? limit 1', [e.channel.getName(), e.network], (err, rows) => {
|
||||
if(rows.length) {
|
||||
e.reply('Channel record for ' + e.channel.getName() + ': ' + rows[0].value);
|
||||
}
|
||||
else
|
||||
e.reply('No channel record yet.');
|
||||
});
|
||||
},
|
||||
desc: 'get current channel record'
|
||||
});
|
||||
};
|
Loading…
Reference in New Issue
Block a user