diff --git a/.gitignore b/.gitignore index 684bf9d..f67c4be 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ node_modules -media +site build/** lib/inspircd-* diff --git a/src/chanbot.ts b/src/chanbot.ts index 4d5ecb4..7ee8abd 100644 --- a/src/chanbot.ts +++ b/src/chanbot.ts @@ -1,13 +1,13 @@ -import irc = require('irc'); +import * as irc from "irc"; function chanReg(channel: string, owner: string){ - var bot = new irc.Client('127.0.0.1', 'ChanReg', { - channels: ['#ChanReg'], + let bot = new irc.Client('127.0.0.1', 'ChanReg', { + channels: [''], userName: 'ChanReg', realName: 'Channel Registration Bot', floodProtection: false, }); - bot.addListener('registered', (message) => { + bot.once('registered', (message) => { bot.send('OPER', 'admin', 'test'); bot.join(channel); bot.send('MODE', channel, '+P'); @@ -17,17 +17,19 @@ function chanReg(channel: string, owner: string){ } function chanUnReg(channel: string){ - var bot = new irc.Client('127.0.0.1', 'ChanReg', { + let bot = new irc.Client('127.0.0.1', 'ChanReg', { channels: [''], userName: 'ChanReg', realName: 'Channel Registration Bot', floodProtection: false, debug: true }); - bot.addListener('registered', (message) => { + bot.once('registered', (message) => { bot.send('OPER', 'admin', 'test'); bot.join(channel); bot.send('MODE', channel, '-P'); bot.disconnect(); - }); -} \ No newline at end of file + }); +} + +export {chanReg, chanUnReg}; \ No newline at end of file diff --git a/src/controller.ts b/src/controller.ts index d9c8612..99c708e 100644 --- a/src/controller.ts +++ b/src/controller.ts @@ -1,4 +1,6 @@ import * as mediaserver from "./server"; +import * as ircd from "./ircd"; + function boot(): void{ const mediaconfig: any = { rtmp: { @@ -11,7 +13,7 @@ function boot(): void{ http: { port:8000, allow_origin: '*', - mediaroot: './media' + mediaroot: './site' }, trans: { ffmpeg: '/usr/bin/ffmpeg', @@ -25,5 +27,6 @@ function boot(): void{ } }; mediaserver.boot(mediaconfig); + ircd.boot(); } export { boot }; \ No newline at end of file diff --git a/src/ircd.ts b/src/ircd.ts new file mode 100644 index 0000000..ff1511b --- /dev/null +++ b/src/ircd.ts @@ -0,0 +1,20 @@ +import * as child from "child_process"; +var ircd: child.ChildProcess; +function boot():void{ + ircd = child.execFile("./lib/inspircd-3.3.0/run/inspircd", ["restart"], (error, stdout, stderr) => { + if (error){ + console.log("[IRCD] Failed to start Inspircd"); + console.log(stdout); + throw error; + } + else { + console.log("[IRCD] Started Inspircd"); + } + }); +} + +function reloadSSL():void{ + ircd.kill("SIGUSR1"); +} + +export { boot, reloadSSL }; \ No newline at end of file