Add config template for chat integration and db schema
No other meaningfull changes (I think) It's been 7 months since last commit god I hope I didn't break anything.merge-requests/8/head
parent
97d4678a0a
commit
a9f1875234
|
@ -8,6 +8,9 @@ media:
|
|||
record: false
|
||||
ffmpeg: '<ffmpeg>'
|
||||
|
||||
rtmp:
|
||||
port: 1935
|
||||
|
||||
http:
|
||||
# uncomment to set HSTS when SSL is ready
|
||||
#hsts: true
|
||||
|
@ -22,3 +25,31 @@ transcode:
|
|||
adaptive: false
|
||||
format: dash
|
||||
variants: 3
|
||||
|
||||
chat:
|
||||
|
||||
irc:
|
||||
enabled: false
|
||||
server:
|
||||
port: 6667
|
||||
tls: false
|
||||
nickname: 'SatyrChat'
|
||||
username: 'SatyrChat'
|
||||
sasl: false
|
||||
password:
|
||||
|
||||
discord:
|
||||
enabled: false
|
||||
token:
|
||||
|
||||
xmpp:
|
||||
enabled: false
|
||||
server:
|
||||
port: 5222
|
||||
nickname: 'SatyrChat'
|
||||
username: 'SatyrChat'
|
||||
|
||||
twitch:
|
||||
enabled: false
|
||||
username:
|
||||
token:
|
|
@ -14,3 +14,10 @@ CREATE TABLE user_meta(
|
|||
about VARCHAR(5000),
|
||||
live TINYINT
|
||||
);
|
||||
CREATE TABLE chat_integration(
|
||||
username VARCHAR(25),
|
||||
irc VARCHAR(1000),
|
||||
xmpp VARCHAR(1000),
|
||||
twitch VARCHAR(1000),
|
||||
discord VARCHAR(1000)
|
||||
);
|
|
@ -501,14 +501,6 @@
|
|||
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
|
||||
"integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s="
|
||||
},
|
||||
"config": {
|
||||
"version": "3.2.2",
|
||||
"resolved": "https://registry.npmjs.org/config/-/config-3.2.2.tgz",
|
||||
"integrity": "sha512-rOsfIOAcG82AWouK4/vBS/OKz3UPl2T/kP0irExmXJJOoWg2CmdfPLdx56bCoMUMFNh+7soQkQWCUC8DyemiwQ==",
|
||||
"requires": {
|
||||
"json5": "^1.0.1"
|
||||
}
|
||||
},
|
||||
"console-control-strings": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz",
|
||||
|
@ -1684,6 +1676,15 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"iconv": {
|
||||
"version": "2.2.3",
|
||||
"resolved": "https://registry.npmjs.org/iconv/-/iconv-2.2.3.tgz",
|
||||
"integrity": "sha1-4ITWDut9c9p/CpwJbkyKvgkL+u0=",
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"nan": "^2.3.5"
|
||||
}
|
||||
},
|
||||
"iconv-lite": {
|
||||
"version": "0.4.24",
|
||||
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
|
||||
|
@ -1734,6 +1735,21 @@
|
|||
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.0.tgz",
|
||||
"integrity": "sha512-M4Sjn6N/+O6/IXSJseKqHoFc+5FdGJ22sXqnjTpdZweHK64MzEPAyQZyEU3R/KRv2GLoa7nNtg/C2Ev6m7z+eA=="
|
||||
},
|
||||
"irc": {
|
||||
"version": "0.5.2",
|
||||
"resolved": "https://registry.npmjs.org/irc/-/irc-0.5.2.tgz",
|
||||
"integrity": "sha1-NxT0doNlqW0LL3dryRFmvrJGS7w=",
|
||||
"requires": {
|
||||
"iconv": "~2.2.1",
|
||||
"irc-colors": "^1.1.0",
|
||||
"node-icu-charset-detector": "~0.2.0"
|
||||
}
|
||||
},
|
||||
"irc-colors": {
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/irc-colors/-/irc-colors-1.5.0.tgz",
|
||||
"integrity": "sha512-HtszKchBQTcqw1DC09uD7i7vvMayHGM1OCo6AHt5pkgZEyo99ClhHTMJdf+Ezc9ovuNNxcH89QfyclGthjZJOw=="
|
||||
},
|
||||
"is-accessor-descriptor": {
|
||||
"version": "0.1.6",
|
||||
"resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz",
|
||||
|
@ -1891,21 +1907,6 @@
|
|||
"asn1.js": "^5.2.0"
|
||||
}
|
||||
},
|
||||
"json5": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz",
|
||||
"integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==",
|
||||
"requires": {
|
||||
"minimist": "^1.2.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"minimist": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz",
|
||||
"integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ="
|
||||
}
|
||||
}
|
||||
},
|
||||
"kind-of": {
|
||||
"version": "6.0.2",
|
||||
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz",
|
||||
|
@ -2123,6 +2124,15 @@
|
|||
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz",
|
||||
"integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw=="
|
||||
},
|
||||
"node-icu-charset-detector": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/node-icu-charset-detector/-/node-icu-charset-detector-0.2.0.tgz",
|
||||
"integrity": "sha1-wjINo3Tdy2cfxUy0oOBB4Vb/1jk=",
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"nan": "^2.3.3"
|
||||
}
|
||||
},
|
||||
"node-media-server": {
|
||||
"version": "2.1.3",
|
||||
"resolved": "https://registry.npmjs.org/node-media-server/-/node-media-server-2.1.3.tgz",
|
||||
|
@ -3065,11 +3075,6 @@
|
|||
"resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz",
|
||||
"integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw=="
|
||||
},
|
||||
"toml": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/toml/-/toml-3.0.0.tgz",
|
||||
"integrity": "sha512-y/mWCZinnvxjTKYhJ+pYxwD0mRLVvOtdS2Awbgxln6iEnt4rk0yBxeSBHkGJcPucRiG0e55mwWp+g/05rsrd6w=="
|
||||
},
|
||||
"ts-node": {
|
||||
"version": "8.5.4",
|
||||
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-8.5.4.tgz",
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
"dirty": "^1.1.0",
|
||||
"express": "^4.17.1",
|
||||
"flags": "^0.1.3",
|
||||
"irc": "^0.5.2",
|
||||
"jose": "^1.15.1",
|
||||
"mysql": "^2.17.1",
|
||||
"node-media-server": ">=2.1.3 <3.0.0",
|
||||
|
|
|
@ -13,9 +13,6 @@ const config: Object = {
|
|||
rootredirect: '/users/live',
|
||||
version: process.env.npm_package_version,
|
||||
}, localconfig['satyr']),
|
||||
ircd: Object.assign({
|
||||
port: 6667,
|
||||
}, localconfig['ircd']),
|
||||
database: Object.assign({
|
||||
host: 'localhost',
|
||||
user: 'satyr',
|
||||
|
@ -44,6 +41,37 @@ const config: Object = {
|
|||
adapative: false,
|
||||
variants: 3,
|
||||
format: 'dash'
|
||||
}, localconfig['transcode'])
|
||||
}, localconfig['transcode']),
|
||||
chat: {
|
||||
irc: Object.assign({
|
||||
enabled: false,
|
||||
server: null,
|
||||
port: 6667,
|
||||
tls: false,
|
||||
nickname: 'SatyrChat',
|
||||
userName: 'SatyrChat',
|
||||
sasl: false,
|
||||
password: null
|
||||
}, localconfig['chat']['irc']),
|
||||
|
||||
discord: Object.assign({
|
||||
enabled: false,
|
||||
token: null
|
||||
}, localconfig['chat']['discord']),
|
||||
|
||||
xmpp: Object.assign({
|
||||
enabled: false,
|
||||
server: null,
|
||||
port: 5222,
|
||||
nickname: 'SatyrChat',
|
||||
username: 'SatyrChat'
|
||||
}, localconfig['chat']['xmpp']),
|
||||
|
||||
twitch: Object.assign({
|
||||
enabled: false,
|
||||
username: null,
|
||||
token: null
|
||||
}, localconfig['chat']['twitch'])
|
||||
}
|
||||
};
|
||||
export { config };
|
|
@ -20,6 +20,7 @@ async function addUser(name: string, password: string){
|
|||
if(dupe[0]) return false;
|
||||
await query('INSERT INTO users (username, password_hash, stream_key, record_flag) VALUES ('+raw.escape(name)+', '+raw.escape(hash)+', '+raw.escape(key)+', 0)');
|
||||
await query('INSERT INTO user_meta (username, title, about, live) VALUES ('+raw.escape(name)+',\'\',\'\',false)');
|
||||
await query('INSERT INTO chat_integration (username, irc, xmpp, twitch, discord) VALUES ('+raw.escape(name)+',\'\',\'\',\'\')');
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
10
src/http.ts
10
src/http.ts
|
@ -357,7 +357,7 @@ async function initChat() {
|
|||
}
|
||||
}
|
||||
socket.join(data);
|
||||
io.to(data).emit('JOINED', {nick: socket.nick});
|
||||
io.to(data).emit('JOINED', {nick: socket.nick, room: data});
|
||||
}
|
||||
else socket.emit('ALERT', 'Room does not exist');
|
||||
});
|
||||
|
@ -377,8 +377,8 @@ async function initChat() {
|
|||
});
|
||||
});
|
||||
socket.on('LEAVEROOM', (data) => {
|
||||
io.to(data).emit('LEFT', {nick: socket.nick, room: data});
|
||||
socket.leave(data);
|
||||
io.to(data).emit('LEFT', {nick: socket.nick});
|
||||
});
|
||||
socket.on('disconnecting', (reason) => {
|
||||
let rooms = Object.keys(socket.rooms);
|
||||
|
@ -413,9 +413,9 @@ async function initChat() {
|
|||
chgNick(socket, data.nick);
|
||||
}
|
||||
});
|
||||
socket.on('MSG', (data) => {
|
||||
if(data.msg === "" || !data.msg.replace(/\s/g, '').length) return;
|
||||
if(socket.rooms[data['room']]) io.to(data.room).emit('MSG', {nick: socket.nick, msg: data.msg});
|
||||
socket.on('MSG', (data: object) => {
|
||||
if(data['msg'] === "" || !data['msg'].replace(/\s/g, '').length) return;
|
||||
if(socket.rooms[data['room']]) io.to(data['room']).emit('MSG', {nick: socket.nick, msg: data['msg'], room: data['room']});
|
||||
});
|
||||
socket.on('KICK', (data) => {
|
||||
if(socket.nick === data.room){
|
||||
|
|
18
src/index.ts
18
src/index.ts
|
@ -1,14 +1,16 @@
|
|||
import * as mediaserver from "./server";
|
||||
import * as db from "./database";
|
||||
import * as http from "./http";
|
||||
import * as cleanup from "./cleanup";
|
||||
import {init as initRTMP} from "./server";
|
||||
import {init as initDB} from "./database";
|
||||
import {init as initHTTP} from "./http";
|
||||
import {init as clean} from "./cleanup";
|
||||
import {init as initChat} from "./chat";
|
||||
import { config } from "./config";
|
||||
|
||||
async function run() {
|
||||
await db.init();
|
||||
await cleanup.init();
|
||||
await http.init();
|
||||
await mediaserver.init();
|
||||
await initDB();
|
||||
await clean();
|
||||
await initHTTP();
|
||||
await initRTMP();
|
||||
await initChat();
|
||||
console.log(`Satyr v${config['satyr']['version']} ready`);
|
||||
}
|
||||
run();
|
||||
|
|
Reference in New Issue