update
This commit is contained in:
parent
9c8abb2b9c
commit
a176408990
|
@ -1,15 +1,13 @@
|
||||||
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 EventEmitter from "events";
|
import EventEmitter from "events";
|
||||||
|
|
||||||
const clients = [];
|
const clients = [];
|
||||||
|
|
||||||
const cuffeo = class cuffeo extends EventEmitter {
|
const cuffeo = class cuffeo extends EventEmitter {
|
||||||
constructor(cfg, _admins = []) {
|
constructor(cfg) {
|
||||||
super();
|
super();
|
||||||
admins.admins = _admins;
|
|
||||||
for (let srv in cfg) {
|
for (let srv in cfg) {
|
||||||
if(cfg[srv].enabled) {
|
if(cfg[srv].enabled) {
|
||||||
switch (cfg[srv].type) {
|
switch (cfg[srv].type) {
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import { getLevel } from "../inc/admin";
|
|
||||||
import modules from "./irc/index";
|
import modules from "./irc/index";
|
||||||
|
|
||||||
import net from "net";
|
import net from "net";
|
||||||
|
@ -100,12 +99,8 @@ export class irc extends EventEmitter {
|
||||||
channel: tmp.params[0],
|
channel: tmp.params[0],
|
||||||
channelid: tmp.params[0],
|
channelid: tmp.params[0],
|
||||||
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,
|
|
||||||
prefix: tmp.prefix.charAt(0) === ":" ? tmp.prefix.substring(1) : tmp.prefix,
|
|
||||||
level: 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
|
||||||
}))
|
|
||||||
}),
|
}),
|
||||||
message: tmp.params[1],
|
message: tmp.params[1],
|
||||||
time: ~~(Date.now() / 1000),
|
time: ~~(Date.now() / 1000),
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import { getLevel } from "../inc/admin";
|
|
||||||
import fetch from "../inc/fetch";
|
import fetch from "../inc/fetch";
|
||||||
import EventEmitter from "events";
|
import EventEmitter from "events";
|
||||||
|
|
||||||
|
@ -101,16 +100,10 @@ export class tg extends EventEmitter {
|
||||||
channel: tmp.chat.title,
|
channel: tmp.chat.title,
|
||||||
channelid: tmp.chat.id,
|
channelid: tmp.chat.id,
|
||||||
user: {
|
user: {
|
||||||
prefix: `${tmp.from.username}!${tmp.from.id}`,
|
|
||||||
nick: tmp.from.first_name,
|
|
||||||
username: tmp.from.username,
|
|
||||||
account: tmp.from.id.toString(),
|
|
||||||
level: 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,
|
||||||
account: tmp.from.id.toString()
|
account: tmp.from.id.toString()
|
||||||
})
|
|
||||||
},
|
},
|
||||||
self: this.server,
|
self: this.server,
|
||||||
message: tmp.text,
|
message: tmp.text,
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
export let admins = { 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;
|
|
||||||
for(let admin of admins.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