add !myfloppy command

This commit is contained in:
Elijah R 2024-06-23 21:33:54 -04:00
parent ed7c6eeec5
commit 459a315143
2 changed files with 28 additions and 4 deletions

1
.gitignore vendored
View file

@ -4,3 +4,4 @@ yarn.lock
config.js config.js
config.json config.json
dist/ dist/
media/

View file

@ -1,8 +1,13 @@
import { readFileSync } from "fs"; import * as fs from "fs";
import * as path from 'path';
import CollabVMClient from "./client.js"; import CollabVMClient from "./client.js";
import Config from "./config.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[]) { function Log(...args: string[]) {
console.log("[AnyOSBot]", args.join(" ")); console.log("[AnyOSBot]", args.join(" "));
@ -292,6 +297,11 @@ class HelperBot extends CollabVMClient {
help: "Change Floppy image to Dartz IMG/flp image", help: "Change Floppy image to Dartz IMG/flp image",
usesFloppy: true, usesFloppy: true,
}, },
{
command: "myfloppy",
help: "Insert and/or create your personal floppy disk",
usesFloppy: true
},
{ {
command: "lilyflp [path]", command: "lilyflp [path]",
help: "Change Floppy image to Lily IMG/flp image", help: "Change Floppy image to Lily IMG/flp image",
@ -517,7 +527,20 @@ class HelperBot extends CollabVMClient {
`boot_set ${message.slice(message.indexOf(" ") + 1)}`, `boot_set ${message.slice(message.indexOf(" ") + 1)}`,
); );
break; 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: default:
this.Chat(`Unknown command ${command}. See !help?`); this.Chat(`Unknown command ${command}. See !help?`);
break; break;