mirror of
https://git.waldn.net/git/knotteye/satyr.git
synced 2025-09-15 22:24:57 +00:00
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.
This commit is contained in:
@ -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
Block a user