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; const wrapper = function() { let irc = 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" ] }); //const tg = new (require('node-telegram-bot-api'))('381368731:AAFalG-LknIbtBDuOvRXcxHUEK9Jg_o1UCw', { polling: true }); irc.on("message", (msg) => { this.emit('message', msg); //if( msg.event[1] === "privmsg" ) { // let e = reply( msg ); // console.log( `IRC: (${e.time}) ${e.network} -> ${e.channel} -> ${e.user.nick}: ${e.message}` ); //} }); /*tg.on('message', msg => { this.emit('message', msg); //let e = replytg(tg, msg); //console.log( `TG: (${e.time}) ${e.channel} -> ${e.user.nick}: ${e.message}` ); });*/ }; const replytg = (bot, tmp) => { return { 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(this.channelid, msg); }.bind(this), replyAction: function(msg) { bot.sendMessage(this.channelid, msg); }, replyNotice: function(msg) { bot.sendMessage(this.channelid, msg); } }; }; const loadIRC = () => { for(let srv in cfg.irc) { rpc.emit('createClient', srv, cfg.irc[srv]); console.log('Loading server', srv); } console.log('All servers have been loaded successfully'); }; util.inherits(wrapper, EventEmitter); export default { wrapper };