import { isCommandFlagEnabled, type CommandFlagKey } from "../../config/commands.flags.js"; import { logVerbose } from "../../globals.js"; import { redactIdentifier } from "../../logging/redact-identifier.js"; import { isInternalMessageChannel } from "../../utils/message-channel.js"; import type { ReplyPayload } from "../types.js"; import type { CommandHandlerResult, HandleCommandsParams } from "./commands-types.js";
function buildNativeCommandGateReply(text: string): CommandHandlerResult { return {
shouldContinue: false,
reply: { text },
};
}
export function rejectUnauthorizedCommand(
params: HandleCommandsParams,
commandLabel: string,
): CommandHandlerResult | null { if (params.command.isAuthorizedSender) { returnnull;
}
logVerbose(
`Ignoring ${commandLabel} from unauthorized sender: ${redactIdentifier(params.command.senderId)}`,
); if (params.ctx.CommandSource === "native") { return buildNativeCommandGateReply("You are not authorized to use this command.");
} return { shouldContinue: false };
}
export function rejectNonOwnerCommand(
params: HandleCommandsParams,
commandLabel: string,
): CommandHandlerResult | null { if (params.command.senderIsOwner) { returnnull;
}
logVerbose(
`Ignoring ${commandLabel} from non-owner sender: ${redactIdentifier(params.command.senderId)}`,
); if (params.ctx.CommandSource === "native") { return buildNativeCommandGateReply("You are not authorized to use this command.");
} return { shouldContinue: false };
}
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.