The request sounded simple: stop new members of a private group from seeing old messages. Telegram has a setting for exactly that, “chat history for new members”. It took most of an evening, a rebuilt bot fleet and one embarrassing bug to find out what that switch really costs.
The switch that wouldn’t flip
The setting refused with an error naming the real reason: the group used topics (separate rooms inside one group), and Telegram does not let you hide history in a group like that. Not a permission, not a bug, a hard rule. The honest options were to turn topics off, to live with the history, or to build something around it.
In the meantime the owner flipped a different setting that looked like the answer: auto-delete after one week. Telegram’s admin log, which records who changed what and when, showed what had really been set. It is a good habit to read that log before guessing, because the names of settings are not a reliable guide to what they do. The auto-delete timer only applies to messages posted afterwards. Twenty thousand older messages were still sitting there, and any new pinned message would quietly vanish a week later.
What we built instead
- A one-time cleanup that deleted just over twenty thousand old messages, sparing pinned ones and the service messages that hold topics together.
- A nightly job that does the same thing every night, with a safety cap and a one-line report so a failure doesn’t go unnoticed.
- Profile cards moved out of the chat into a private channel, with a short vetting period before newcomers can see it. The group itself no longer holds anything a newcomer could dig up.
Then the owner turned topics off, which made the hidden-history setting available after all. That turned out to be the moment the real damage could happen.
The bug I wrote that nobody could see
Several bots posted into specific topics. With topics off, those posts fail. I added a small switch that clears the topic numbers while topics are off and restores them if they return. It worked in tests. Then I audited every place the bots post and found a quiet problem I had caused myself.
One feature, members sharing a card with the group, treated “no topic number” as “test mode: send this to the owner only”. For a long time that was true because nobody had ever left the number empty on purpose. Now “empty” also meant “topics are off”. Members tapping share would have seen a success message, and the card would have gone only to the owner.
The lesson is old and still easy to forget: do not let one value mean two things. The test mode now has its own switch.
Three smaller lessons
- Bots cannot delete messages older than 48 hours, even as admins. Every deletion needs a fallback that uses the owner’s own account.
- Bots cannot add people to a channel. Users with strict privacy settings cannot be added by anyone, so eight of twenty-seven members needed a link instead.
- A feature is only done when the flows around it are done: joining, leaving, being removed, asking to be forgotten. The first version put cards in the channel at approval time, before anyone had joined.
Tests used fake updates, not a real newcomer, so the first genuine join and the first scheduled post after the change are the real checks.