Merge branch 'master' of https://github.com/szdytom/wschat-ng
This commit is contained in:
commit
ffa722a312
21
LICENSE
Normal file
21
LICENSE
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2021 szdytom
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
3
README.md
Normal file
3
README.md
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# wschat-ng
|
||||||
|
Another online realtime chatting system.
|
||||||
|
Wrote in typescript.
|
@ -109,6 +109,15 @@ async function init() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ws.on('private message', evt => {
|
||||||
|
write_message({
|
||||||
|
type: 'normal',
|
||||||
|
from: evt.sender,
|
||||||
|
msg: evt.data,
|
||||||
|
is_private: true,
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
ws.on('command-block-reply', data => {
|
ws.on('command-block-reply', data => {
|
||||||
write_message({
|
write_message({
|
||||||
type: 'command-block',
|
type: 'command-block',
|
||||||
|
@ -60,6 +60,7 @@ export function run_command(cmd_raw: string, uid: string, users: Map<string, Use
|
|||||||
};
|
};
|
||||||
|
|
||||||
const cmd_set = cmd.split(/\s+/);
|
const cmd_set = cmd.split(/\s+/);
|
||||||
|
const msg = cmd.replace(/^[^\n]+\n/m, '');
|
||||||
|
|
||||||
if (cmd.startsWith('/disconnect')) {
|
if (cmd.startsWith('/disconnect')) {
|
||||||
command_reply('Diconnecting. Bye!',);
|
command_reply('Diconnecting. Bye!',);
|
||||||
@ -178,4 +179,12 @@ export function run_command(cmd_raw: string, uid: string, users: Map<string, Use
|
|||||||
|
|
||||||
command_reply(JSON.stringify(checked_user));
|
command_reply(JSON.stringify(checked_user));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cmd.startsWith('/anon')) {
|
||||||
|
io.in(Array.from(socket.rooms)).emit('new message', {
|
||||||
|
type: 'text-message',
|
||||||
|
data: msg,
|
||||||
|
sender: 'Anonymous User',
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
@ -149,7 +149,12 @@ export function find_user(filter_string_raw: string, users: Map<string, User>, o
|
|||||||
|
|
||||||
let admin_passcode: string;
|
let admin_passcode: string;
|
||||||
function refreash_admin_passcode() {
|
function refreash_admin_passcode() {
|
||||||
admin_passcode = Math.random().toString();
|
if (process.env.PASSCODE) {
|
||||||
|
admin_passcode = process.env.PASSCODE.toString();
|
||||||
|
} else {
|
||||||
|
admin_passcode = Math.random().toString();
|
||||||
|
}
|
||||||
|
|
||||||
console.log('Admin passcode is:', admin_passcode);
|
console.log('Admin passcode is:', admin_passcode);
|
||||||
return admin_passcode;
|
return admin_passcode;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user