mhm
This commit is contained in:
parent
31be08bed5
commit
7da5f9c653
|
@ -1,6 +1,6 @@
|
||||||
import { irc as irclib } from "./src/clients/irc";
|
import { irc as irclib } from "./src/clients/irc";
|
||||||
import { tg as tglib } from "./src/clients/tg";
|
import { tg as tglib } from "./src/clients/tg";
|
||||||
import { admins } from "./src/inc/admin";
|
import admins from "./src/inc/admin";
|
||||||
|
|
||||||
import EventEmitter from "events";
|
import EventEmitter from "events";
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ const clients = [];
|
||||||
const cuffeo = class wrapper extends EventEmitter {
|
const cuffeo = class wrapper extends EventEmitter {
|
||||||
constructor(cfg, _admins = []) {
|
constructor(cfg, _admins = []) {
|
||||||
super();
|
super();
|
||||||
admins = _admins;
|
admins.admins = _admins;
|
||||||
for (let srv in cfg) {
|
for (let srv in cfg) {
|
||||||
if(cfg[srv].val.enabled) {
|
if(cfg[srv].val.enabled) {
|
||||||
switch (cfg[srv].val.type) {
|
switch (cfg[srv].val.type) {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { getLevel } from "../inc/admin";
|
import admins from "../inc/admin";
|
||||||
import modules from "./irc/index";
|
import modules from "./irc/index";
|
||||||
|
|
||||||
import net from "net";
|
import net from "net";
|
||||||
|
@ -102,7 +102,7 @@ export class irc extends EventEmitter {
|
||||||
user: Object.assign(this.parsePrefix(tmp.prefix), {
|
user: Object.assign(this.parsePrefix(tmp.prefix), {
|
||||||
account: this.server.user.geti(this.parsePrefix(tmp.prefix).nick).account,
|
account: this.server.user.geti(this.parsePrefix(tmp.prefix).nick).account,
|
||||||
prefix: tmp.prefix.charAt(0) === ":" ? tmp.prefix.substring(1) : tmp.prefix,
|
prefix: tmp.prefix.charAt(0) === ":" ? tmp.prefix.substring(1) : tmp.prefix,
|
||||||
level: getLevel(this.network, Object.assign(this.parsePrefix(tmp.prefix), {
|
level: admins.getLevel(this.network, Object.assign(this.parsePrefix(tmp.prefix), {
|
||||||
account: this.server.user.geti(this.parsePrefix(tmp.prefix).nick).account,
|
account: this.server.user.geti(this.parsePrefix(tmp.prefix).nick).account,
|
||||||
prefix: tmp.prefix.charAt(0) === ":" ? tmp.prefix.substring(1) : tmp.prefix
|
prefix: tmp.prefix.charAt(0) === ":" ? tmp.prefix.substring(1) : tmp.prefix
|
||||||
}))
|
}))
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { getLevel } from "../inc/admin";
|
import admins from "../inc/admin";
|
||||||
import fetch from "../inc/fetch";
|
import fetch from "../inc/fetch";
|
||||||
import EventEmitter from "events";
|
import EventEmitter from "events";
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ export class tg extends EventEmitter {
|
||||||
nick: tmp.from.first_name,
|
nick: tmp.from.first_name,
|
||||||
username: tmp.from.username,
|
username: tmp.from.username,
|
||||||
account: tmp.from.id.toString(),
|
account: tmp.from.id.toString(),
|
||||||
level: getLevel("Telegram", {
|
level: admins.getLevel("Telegram", {
|
||||||
prefix: `${tmp.from.username}!${tmp.from.id}`,
|
prefix: `${tmp.from.username}!${tmp.from.id}`,
|
||||||
nick: tmp.from.first_name,
|
nick: tmp.from.first_name,
|
||||||
username: tmp.from.username,
|
username: tmp.from.username,
|
||||||
|
|
|
@ -1,44 +1,22 @@
|
||||||
//import sql from "./sql";
|
export default {
|
||||||
|
admins: [],
|
||||||
/*export let admins = [];
|
getLevel: (network, user) => {
|
||||||
export const loadAdmins = () => {
|
let ret = {
|
||||||
admins = [];
|
level: 0,
|
||||||
sql.exec(`select * from admins`)
|
verified: false
|
||||||
.then(rows => {
|
};
|
||||||
rows.forEach(row => {
|
if (typeof user !== "object")
|
||||||
admins.push({
|
return "user has to be an object!";
|
||||||
id: row.id,
|
if (!user.account || !user.prefix)
|
||||||
prefix: row.prefix,
|
return ret;
|
||||||
account: row.account,
|
for(let admin of admins) {
|
||||||
network: row.network,
|
if (admin.account === user.account.toLowerCase() && admin.network === network.toLowerCase()) {
|
||||||
level: row.level
|
ret = {
|
||||||
});
|
level: admin.level,
|
||||||
});
|
verified: user.prefix.toLowerCase() === admin.prefix
|
||||||
})
|
};
|
||||||
.catch(err => {
|
}
|
||||||
console.log("keine Admins vorhanden");
|
};
|
||||||
});
|
|
||||||
};
|
|
||||||
loadAdmins();*/
|
|
||||||
|
|
||||||
export let admins = [];
|
|
||||||
|
|
||||||
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;
|
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;
|
|
||||||
};
|
};
|
Loading…
Reference in New Issue
Block a user