remove getLevel

This commit is contained in:
Flummi 2018-09-07 20:03:32 +02:00
parent 3a9624e1c9
commit f7303c804d
5 changed files with 53 additions and 9 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
node_modules/
package-lock.json

View File

@ -11,5 +11,9 @@
"url": "git@gitfap.de:keinBot/cuffeo.git"
},
"author": "Flummi",
"license": "ISC"
"license": "ISC",
"dependencies": {
"request": "^2.88.0",
"request-promise-native": "^1.0.5"
}
}

View File

@ -1,5 +1,3 @@
import { getLevel } from "../inc/admin";
import modules from "./irc/index";
import net from "net";
@ -103,10 +101,10 @@ export class irc extends EventEmitter {
user: Object.assign(this.parsePrefix(tmp.prefix), {
account: this.server.user.geti(this.parsePrefix(tmp.prefix).nick).account,
prefix: tmp.prefix.charAt(0) === ":" ? tmp.prefix.substring(1) : tmp.prefix,
level: getLevel(this.network, Object.assign(this.parsePrefix(tmp.prefix), {
/*level: getLevel(this.network, Object.assign(this.parsePrefix(tmp.prefix), {
account: this.server.user.geti(this.parsePrefix(tmp.prefix).nick).account,
prefix: tmp.prefix.charAt(0) === ":" ? tmp.prefix.substring(1) : tmp.prefix
}))
}))*/
}),
message: tmp.params[1],
time: ~~(Date.now() / 1000),

View File

@ -1,5 +1,3 @@
import { getLevel } from "../inc/admin";
import rp from "request-promise-native";
import EventEmitter from "events";
@ -106,12 +104,12 @@ export class tg extends EventEmitter {
nick: tmp.from.first_name,
username: tmp.from.username,
account: tmp.from.id.toString(),
level: getLevel("Telegram", {
/*level: getLevel("Telegram", {
prefix: `${tmp.from.username}!${tmp.from.id}`,
nick: tmp.from.first_name,
username: tmp.from.username,
account: tmp.from.id.toString()
})
})*/
},
self: this.server,
message: tmp.text,

42
src/inc/admin.mjs Normal file
View File

@ -0,0 +1,42 @@
//import sql from "./sql";
/*export let admins = [];
export const loadAdmins = () => {
admins = [];
sql.exec(`select * from admins`)
.then(rows => {
rows.forEach(row => {
admins.push({
id: row.id,
prefix: row.prefix,
account: row.account,
network: row.network,
level: row.level
});
});
})
.catch(err => {
console.log("keine Admins vorhanden");
});
};
loadAdmins();*/
export const getLevel = (network, user) => {
let ret = {
level: 0,
verified: false
};
if (typeof user !== "object")
return "user has to be an object!";
if (!user.account || !user.prefix)
return ret;
for(let admin of admins) {
if (admin.account === user.account.toLowerCase() && admin.network === network.toLowerCase()) {
ret = {
level: admin.level,
verified: user.prefix.toLowerCase() === admin.prefix
};
}
};
return ret;
};