import { cfg, read } from './cfg.js'; import { loadEvents } from './lib.js'; let irclib = require('./irc/irc.js'); //const safeEval = require('safe-eval'); const util = require('util'); //const fs = require('fs'); //const ytdl = util.promisify(require('youtube-dl').getInfo); var EventEmitter = require('events').EventEmitter; let clients = []; const wrapper = function() { clients.push({ name: "n0xy", type: "irc", client: new irclib({ network: "n0xy", host: "31.172.14.83", port: 6669, //6669, ssl: true, selfSigned: true, nickname: "kbotv3", username: "kbotv2/n0xy", password: "blah", realname: "kbotv3", channels: [ "#kbot-dev" ] }) }); clients.push({ name: "tg", type: "tg", client: new (require('node-telegram-bot-api'))('381368731:AAFalG-LknIbtBDuOvRXcxHUEK9Jg_o1UCw', { polling: true }) }); clients.forEach(client => { client.client.on("message", e => { if(client.type === "tg") e = replytg(client.client, e); this.emit('message', e); }); }); }; const replytg = (bot, tmp) => { // muss noch hier raus return { type: "tg", channel: tmp.chat.title, channelid: tmp.chat.id, user: { nick: tmp.from.first_name, username: tmp.from.username }, message: tmp.text, time: tmp.date, reply: function(msg) { bot.sendMessage(tmp.chat.id, msg); }, replyAction: function(msg) { bot.sendMessage(tmp.chat.id, msg); }, replyNotice: function(msg) { bot.sendMessage(tmp.chat.id, msg); } }; }; util.inherits(wrapper, EventEmitter); export default { wrapper };