Skip to content

fix: report the actual message count in the transcript header#158

Open
Rstarks07 wants to merge 1 commit into
mahtoid:masterfrom
Rstarks07:fix/actual-message-count
Open

fix: report the actual message count in the transcript header#158
Rstarks07 wants to merge 1 commit into
mahtoid:masterfrom
Rstarks07:fix/actual-message-count

Conversation

@Rstarks07

Copy link
Copy Markdown

Problem

The transcript header is built from the requested limit rather than the number of messages actually exported, so it can state something untrue.

Exporting a channel that holds 47 messages with limit=9999 renders:

This is the latest 9999 messages of the #general channel.

Fix

self.messages is already populated by export() before build_transcript() runs, and the very same value is used a few lines below for MESSAGE_COUNT. The header now agrees with the count the transcript already reports.

         limit = "start"
         if self.limit:
-            limit = f"latest {self.limit} messages"
+            limit = f"latest {len(self.messages)} messages"

Notes

  • No API or signature change.
  • raw_export() is unaffected: it passes limit=None, which still renders "start".
  • When the fetch does reach the limit, the output is identical to before.
  • python -m unittest discover -s tests -p "test_*.py" passes (30 tests), and ruff check --select S,E,F,I is clean.

The header was built from the requested limit rather than the number of
messages actually exported, so exporting a 47-message channel with
limit=9999 rendered "This is the latest 9999 messages of the #general
channel."

self.messages is already populated by export() before build_transcript()
runs, and the same value is used a few lines below for MESSAGE_COUNT, so
the header now agrees with the count the transcript already reports.

raw_export() is unaffected: it passes limit=None, which still renders
"start".
@Rstarks07
Rstarks07 requested review from doluk and mahtoid as code owners July 21, 2026 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant