// Extensions cannot import core internals directly, so use node:crypto here. import { randomBytes } from "node:crypto"; import type { PendingApproval } from "../settings.js";
export type { PendingApproval };
export type ApprovalType = "dm" | "channel" | "group";
function normalizeLowercaseStringOrEmpty(value: unknown): string { returntypeof value === "string" ? value.trim().toLowerCase() : "";
}
// Match "approve", "deny", or "block" optionally followed by an ID const match = trimmed.match(/^(approve|deny|block)(?:\s+(.+))?$/); if (!match) { returnnull;
}
const action = match[1] as "approve" | "deny" | "block"; const id = match[2]?.trim();
/** *Formataconfirmationmessageafteranapprovalaction.
*/
export function formatApprovalConfirmation(
approval: PendingApproval,
action: "approve" | "deny" | "block",
): string { if (action === "block") { return `Blocked ${approval.requestingShip}. They will no longer be able to contact the bot.`;
}
switch (approval.type) { case"dm": if (action === "approve") { return `${actionText} DM access for ${approval.requestingShip}. They can now message the bot.`;
} return `${actionText} DM request from ${approval.requestingShip}.`;
case"channel": if (action === "approve") { return `${actionText} ${approval.requestingShip} for ${approval.channelNest}. They can now interact in this channel.`;
} return `${actionText} ${approval.requestingShip} for ${approval.channelNest}.`;
case"group": if (action === "approve") { return `${actionText} group invite from ${approval.requestingShip} to ${approval.groupFlag}. Joining group...`;
} return `${actionText} group invite from ${approval.requestingShip} to ${approval.groupFlag}.`;
} thrownew Error("Unsupported approval type");
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.