INNER CODE UNIT · TypeScript

registerHandlers

Beever-AI/beever-atlas · bot/src/index.ts:84

function registerHandlers(bot: Chat): void {
  // Handler: user @mentions the bot in a not-yet-subscribed thread.
  bot.onNewMention(async (thread, message) => {
    // Log length, not content — message text can carry PII/secrets.
    console.log(`[@mention] (${(message.text || "").length} chars) from ${thread.id}`);
    // Never answer our own message or another bot — the latter prevents
    // bot-to-bot @mention loops (e.g. a workflow bot pinging Beever).
    if (message.author?.isMe === true || message.author?.isBot === true) return;
    await thread.subscribe();

    const platform = extractPlatform(thread.id);
    const question = stripMention(message.text || "", platform);
    // An image @mention ("@bot what is this?" + screenshot, or a bare image
    // ping) is a real question ABOUT the image. Detect it so the gate below
    // treats it as answerable instead of nudging on the thin text.
    const hasImage =
      VISION_ENABLED &&
      (message.attachments || []).some(isImageAttachment);

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…