Skip to content

Commit

Permalink
a
Browse files Browse the repository at this point in the history
  • Loading branch information
rojvv committed Aug 8, 2022
1 parent 8fdd796 commit b9a4ab8
Showing 1 changed file with 0 additions and 39 deletions.
39 changes: 0 additions & 39 deletions module_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,45 +13,6 @@ export function managerModule(manager: ModuleManager): Module {
name: "manager",
handlers: [
new CommandHandler("install", async ({ client, event }) => {
const reply = await event.message.getReplyMessage();
if (!reply) {
return;
}
const { media } = reply;
if (
!(media instanceof Api.MessageMediaDocument) ||
!(media.document instanceof Api.Document) ||
!(media.document.attributes[0] instanceof
Api.DocumentAttributeFilename) ||
!media.document.attributes[0].fileName.endsWith(".ts") ||
media.document.size.gt(5000)
) {
return;
}
const result = await client.downloadMedia(media, {});
if (!result) {
await updateMessage(event, "Could not download the module.");
return;
}
const spec = join(externals, `.${media.document.id}.ts`);
await Deno.writeTextFile(
spec,
typeof result === "string" ? result : result.toString(),
);
let module;
try {
module = await ModuleManager.file(spec);
} catch (_err) {
await updateMessage(event, "The replied file is not a valid module.");
return;
}
if (manager.modules.has(module.name)) {
await updateMessage(event, "Module already installed.");
return;
}
await Deno.rename(spec, join(externals, `${module.name}.ts`));
manager.install(module, true);
await updateMessage(event, "Module installed.");
}),
new CommandHandler("uninstall", async ({ event, args }) => {
let uninstalled = 0;
Expand Down

0 comments on commit b9a4ab8

Please sign in to comment.