Clean up commented out code
Discard messages with only whitespace in socket.iomerge-requests/5/head
parent
cf71e663de
commit
d9b3333f21
11
src/http.ts
11
src/http.ts
|
@ -50,21 +50,15 @@ async function init(satyr: any, port: number, ircconf: any){
|
||||||
app.get('/users/*', (req, res) => {
|
app.get('/users/*', (req, res) => {
|
||||||
db.query('select username,title,about from user_meta where username='+db.raw.escape(req.url.split('/')[2].toLowerCase())).then((result) => {
|
db.query('select username,title,about from user_meta where username='+db.raw.escape(req.url.split('/')[2].toLowerCase())).then((result) => {
|
||||||
if(result[0]){
|
if(result[0]){
|
||||||
/*njkconf.user = result[0].username;
|
|
||||||
njkconf.streamtitle = result[0].title;
|
|
||||||
njkconf.about = result[0].about;*/
|
|
||||||
res.render('user.njk', Object.assign(result[0], njkconf));
|
res.render('user.njk', Object.assign(result[0], njkconf));
|
||||||
}
|
}
|
||||||
else res.render('404.njk', njkconf);
|
else res.render('404.njk', njkconf);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
app.get('/vods/*', (req, res) => {
|
app.get('/vods/*', (req, res) => {
|
||||||
njkconf.user = req.url.split('/')[2].toLowerCase();
|
|
||||||
db.query('select username from user_meta where username='+db.raw.escape(req.url.split('/')[2].toLowerCase())).then((result) => {
|
db.query('select username from user_meta where username='+db.raw.escape(req.url.split('/')[2].toLowerCase())).then((result) => {
|
||||||
if(result[0]){
|
if(result[0]){
|
||||||
fs.readdir('./site/live/'+njkconf.user, {withFileTypes: true} , (err, files) => {
|
fs.readdir('./site/live/'+njkconf.user, {withFileTypes: true} , (err, files) => {
|
||||||
//if(files) njkconf.list = files.filter(fn => fn.name.endsWith('.mp4'));
|
|
||||||
//else njkconf.list = [];
|
|
||||||
res.render('vods.njk', Object.assign({user: result[0].username, list: files.filter(fn => fn.name.endsWith('.mp4'))}, njkconf));
|
res.render('vods.njk', Object.assign({user: result[0].username, list: files.filter(fn => fn.name.endsWith('.mp4'))}, njkconf));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -178,7 +172,7 @@ async function init(satyr: any, port: number, ircconf: any){
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
socket.on('MSG', (data) => {
|
socket.on('MSG', (data) => {
|
||||||
if(data.msg === "") return;
|
if(data.msg === "" || !data.msg.replace(/\s/g, '').length) return;
|
||||||
io.to(data.room).emit('MSG', {nick: socket.nick, msg: data.msg});
|
io.to(data.room).emit('MSG', {nick: socket.nick, msg: data.msg});
|
||||||
if(ircconf.enable) irc.send(socket.nick, data.room, data.msg);
|
if(ircconf.enable) irc.send(socket.nick, data.room, data.msg);
|
||||||
});
|
});
|
||||||
|
@ -200,7 +194,8 @@ async function init(satyr: any, port: number, ircconf: any){
|
||||||
}
|
}
|
||||||
|
|
||||||
async function newNick(socket) {
|
async function newNick(socket) {
|
||||||
let n: string = 'Guest'+Math.floor(Math.random() * Math.floor(100));
|
//i just realized how shitty of an idea this is
|
||||||
|
let n: string = 'Guest'+Math.floor(Math.random() * Math.floor(1000));
|
||||||
if(store.get(n)) return newNick(socket);
|
if(store.get(n)) return newNick(socket);
|
||||||
else {
|
else {
|
||||||
store.set(n, socket.id);
|
store.set(n, socket.id);
|
||||||
|
|
Reference in New Issue