chore: cmd

This commit is contained in:
Saahil 2025-01-26 13:25:56 -05:00
parent f471b6f727
commit c53d8bd0fe
No known key found for this signature in database
GPG key ID: 8A8B64515254CFC6
2 changed files with 18 additions and 1 deletions

View file

@ -6,6 +6,7 @@ import * as Sentry from "@sentry/node";
import { ModifiedApp } from "../modules/slackapp";
import { compareSync } from "bcrypt";
import { EncryptedJsonDb } from "../modules/encrypted-db";
import { sendSchedule } from "../modules/robotics";
const clean = async (text) => {
// If our input is a promise, await it before continuing
if (text && text.constructor?.name == "Promise") text = await text;
@ -186,6 +187,21 @@ export default class Message implements Command {
app.ws.on("connect", () => {
console.log("Connected to WS server");
});
} else if (cmd == "robotics") {
const out = await sendSchedule(args.join(" "), app, `C07R8DYAZMM`)
if(out) {
await app.client.chat.postEphemeral({
channel: event.channel,
text: `Robotics schedule sent!`,
user: event.user,
});
} else {
await app.client.chat.postEphemeral({
channel: event.channel,
text: `Robotics schedule not sent!`,
user: event.user,
});
}
}
console.debug(`#message-`);

View file

@ -52,7 +52,7 @@ export async function sendSchedule(
channel: string,
) {
const schedule = extractText(text);
if (schedule.length == 0) return;
if (schedule.length == 0) return 0;
const msg = await app.client.chat.postMessage({
channel,
text: `Oh whats this? a schedule? for .. Robotics?? :robot:`,
@ -65,4 +65,5 @@ export async function sendSchedule(
});
await new Promise((r) => setTimeout(r, 100));
}
return 1;
}