[feature] set admin passcode

This commit is contained in:
方而静 2021-03-26 13:23:07 +08:00
parent be13a3a1f6
commit 817b00cc4a
No known key found for this signature in database
GPG Key ID: C4F2853BC3103681
2 changed files with 19 additions and 5 deletions

View File

@ -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 => {
write_message({
type: 'command-block',

View File

@ -40,8 +40,8 @@ function splite_toplevel_concat(filter_string: string) {
matched += 1;
} else if (c === ')') {
matched -= 1;
}
}
if (c === '+' && matched === 0) {
res.push(buf);
buf = '';
@ -56,9 +56,9 @@ function splite_toplevel_concat(filter_string: string) {
export function find_user(filter_string_raw: string, users: Map<string, User>, owner_id: string): string[] {
const parse_lower = (filter: string) => {
return find_user(filter, users, owner_id);
return find_user(filter, users, owner_id);
};
// trim spaces (start and end)
const filter_string = filter_string_raw.replace(/(^\s*)|(\s*$)/g, '');
@ -149,7 +149,12 @@ export function find_user(filter_string_raw: string, users: Map<string, User>, o
let admin_passcode: string;
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);
return admin_passcode;
}