channel ownership base, part 1

Fleshing out the new channel ownership feature, along with a typo fix and small syntax updates.

A claim can now be staked with /claimchannel, a channel owner may change a trip's level using /setlevel

To do: unclaimchannel, setmotd, makeprivate, makepublic, renewclaim, garbage keeping, update mod commands to accept channelOwner and channelModerator, etc
This commit is contained in:
marzavec
2024-01-05 00:30:28 -08:00
parent a3bca6d000
commit 7ecb31c46c
117 changed files with 811 additions and 258 deletions
+16 -10
View File
@@ -1,8 +1,14 @@
import fs from 'fs';
import { join, dirname } from 'path';
import { Low, JSONFile } from 'lowdb';
import { fileURLToPath } from 'url';
import { CoreApp } from 'hackchat-server';
import {
existsSync,
readFileSync,
} from 'node:fs';
import {
Low,
JSONFile,
} from 'lowdb';
import {
CoreApp,
} from 'hackchat-server';
// required file paths
const SessionLocation = './session.key';
@@ -10,15 +16,15 @@ const SaltLocation = './salt.key';
const AppConfigLocation = './config.json';
// verify required files exist
if (fs.existsSync(SessionLocation) === false) {
if (existsSync(SessionLocation) === false) {
throw Error('Missing session key, you may need to run: npm run config');
}
if (fs.existsSync(SaltLocation) === false) {
if (existsSync(SaltLocation) === false) {
throw Error('Missing salt key, you may need to run: npm run config');
}
if (fs.existsSync(AppConfigLocation) === false) {
if (existsSync(AppConfigLocation) === false) {
throw Error('Missing config, you may need to run: npm run config');
}
@@ -30,10 +36,10 @@ const server = new CoreApp({
});
// load sessoin key data
server.sessionKey = fs.readFileSync(SessionLocation);
server.sessionKey = readFileSync(SessionLocation);
// load salt key data
server.saltKey = fs.readFileSync(SaltLocation);
server.saltKey = readFileSync(SaltLocation);
// load the configuration data
const adapter = new JSONFile(AppConfigLocation);