add !myfloppy command
This commit is contained in:
parent
ed7c6eeec5
commit
459a315143
2 changed files with 28 additions and 4 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -3,4 +3,5 @@ package-lock.json
|
|||
yarn.lock
|
||||
config.js
|
||||
config.json
|
||||
dist/
|
||||
dist/
|
||||
media/
|
29
src/index.ts
29
src/index.ts
|
@ -1,8 +1,13 @@
|
|||
import { readFileSync } from "fs";
|
||||
import * as fs from "fs";
|
||||
import * as path from 'path';
|
||||
import CollabVMClient from "./client.js";
|
||||
import Config from "./config.js";
|
||||
|
||||
let config: Config = JSON.parse(readFileSync("config.json", "utf-8"));
|
||||
let config: Config = JSON.parse(fs.readFileSync("config.json", "utf-8"));
|
||||
|
||||
const blankflp = Buffer.alloc(1440000);
|
||||
if (!fs.existsSync("media/flp/"))
|
||||
fs.mkdirSync("media/flp/", {recursive: true});
|
||||
|
||||
function Log(...args: string[]) {
|
||||
console.log("[AnyOSBot]", args.join(" "));
|
||||
|
@ -292,6 +297,11 @@ class HelperBot extends CollabVMClient {
|
|||
help: "Change Floppy image to Dartz IMG/flp image",
|
||||
usesFloppy: true,
|
||||
},
|
||||
{
|
||||
command: "myfloppy",
|
||||
help: "Insert and/or create your personal floppy disk",
|
||||
usesFloppy: true
|
||||
},
|
||||
{
|
||||
command: "lilyflp [path]",
|
||||
help: "Change Floppy image to Lily IMG/flp image",
|
||||
|
@ -517,7 +527,20 @@ class HelperBot extends CollabVMClient {
|
|||
`boot_set ${message.slice(message.indexOf(" ") + 1)}`,
|
||||
);
|
||||
break;
|
||||
|
||||
case "myfloppy":
|
||||
{
|
||||
if (!DoLimit(this.GeneralCmdLimit!)) return;
|
||||
if (!this._hasFloppy) {
|
||||
this.Chat("This VM does not have a floppy drive.");
|
||||
return;
|
||||
}
|
||||
let flppath = path.resolve(`media/flp/${username}.img`)
|
||||
if (!fs.existsSync(flppath)) {
|
||||
fs.writeFileSync(flppath, blankflp);
|
||||
}
|
||||
this.QemuChangeFloppy(flppath);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
this.Chat(`Unknown command ${command}. See !help?`);
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue