Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/JAVA/Openclaw/extensions/qqbot/src/engine/access/   (KI Agentensystem Version 22©)  Datei vom 26.3.2026 mit Größe 1 kB image not shown  

Quelle  sender-match.ts

  Sprache: JAVA
 

Spracherkennung für: .ts vermutete Sprache: Unknown {[0] [0] [0]} [Methode: Schwerpunktbildung, einfache Gewichte, sechs Dimensionen]

/**
 * QQBot sender normalization and allowlist matching.
 *
 * Keeps QQ-specific quirks (the `qqbot:` prefix, uppercase-insensitive
 * comparison) localized to this module so the policy engine itself can
 * stay channel-agnostic.
 */

/** Normalize a single entry (openid): strip `qqbot:` prefix, uppercase, trim. */
export function normalizeQQBotSenderId(raw: unknown): string {
  if (typeof raw !== "string" && typeof raw !== "number") {
    return "";
  }
  return String(raw)
    .trim()
    .replace(/^qqbot:/i, "")
    .toUpperCase();
}

/** Normalize an entire allowFrom list, dropping empty entries. */
export function normalizeQQBotAllowFrom(list: Array<string | number> | undefined | null): string[] {
  if (!list || list.length === 0) {
    return [];
  }
  const out: string[] = [];
  for (const entry of list) {
    const normalized = normalizeQQBotSenderId(entry);
    if (normalized) {
      out.push(normalized);
    }
  }
  return out;
}

/**
 * Build a matcher closure suitable for passing to the policy engine's
 * `isSenderAllowed` callback. The caller supplies the sender once, and
 * the returned function can be invoked against different allowlists
 * (DM allowlist vs group allowlist) without repeating normalization.
 */
export function createQQBotSenderMatcher(senderId: string): (allowFrom: string[]) => boolean {
  const normalizedSender = normalizeQQBotSenderId(senderId);
  return (allowFrom: string[]) => {
    if (allowFrom.length === 0) {
      return false;
    }
    if (allowFrom.includes("*")) {
      return true;
    }
    if (!normalizedSender) {
      return false;
    }
    return allowFrom.some((entry) => normalizeQQBotSenderId(entry) === normalizedSender);
  };
}

¤ Dauer der Verarbeitung: 0.22 Sekunden  (vorverarbeitet am  2026-04-27) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

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.