[feature] set admin passcode
This commit is contained in:
parent
be13a3a1f6
commit
817b00cc4a
@ -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',
|
||||||
|
15
src/user.ts
15
src/user.ts
@ -40,8 +40,8 @@ function splite_toplevel_concat(filter_string: string) {
|
|||||||
matched += 1;
|
matched += 1;
|
||||||
} else if (c === ')') {
|
} else if (c === ')') {
|
||||||
matched -= 1;
|
matched -= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c === '+' && matched === 0) {
|
if (c === '+' && matched === 0) {
|
||||||
res.push(buf);
|
res.push(buf);
|
||||||
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[] {
|
export function find_user(filter_string_raw: string, users: Map<string, User>, owner_id: string): string[] {
|
||||||
const parse_lower = (filter: 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)
|
// trim spaces (start and end)
|
||||||
const filter_string = filter_string_raw.replace(/(^\s*)|(\s*$)/g, '');
|
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;
|
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