Telegram Group Member Join Time Tool with Sorted Output
Preface
In a previous blog post, our join-group verification bot got a new feature that lets us manually trigger the join-group verification for any group member.The problem it solved was this: when the bot leaves the group (or goes offline abnormally), new members join the group, but those new members never went through the join-group verification.
Then a new question pops up — how do I know which members joined during the period when the bot was absent from the group?
Requirements
Output each group member's join time.
Implementation
I recalled that we already had a tool for querying group member info
We just need to do some GPT-driven coding and describe our requirements.
Based on the code above, add a feature:Save each group member's join time
The amount of modification is very small.
I found that the join times in the result were unsorted.
So I added another requirement to GPT
Sort the query results by join time
The result GPT gave me was basically correct, but I had a particular requirement about the format saved to the file.
This project was originally designed to generate a user list for the speaking verification bot to use as the verified user list, valid.yaml
So the format saved to the file needs to be:
6617181826:
username: atefatman
full_name: 子 肥
7919966027:
username: crazypeace_anti_bot_bot
full_name: CZ_antibot_bot
I tried several options.
If I use a list, the file looks like this
- id: 399932510
username: crazypeace
full_name: ǝɔ∀ǝdʎz∀ɹɔ 👽
joined_at: '2025-10-06T17:47:39.202290'
- id: 661519101
username: testuser
full_name: 测试 用户
joined_at: '2025-10-07T12:11:22.501119'
If I use OrderedDict, the file looks like this
!!python/object/apply:collections.OrderedDict
- - - 1716213463
- username: 8lojbk
full_name: 系统安装 处理 搭建网络环境
joined_at: '2022-03-31T07:01:32+00:00'
- - 1215996169
- username: ''
full_name: z 8zz
joined_at: '2022-03-31T07:07:10+00:00'
Finally I found out that in Python 3.7+, the dict is ordered (it preserves insertion order).
So ultimately I used a new dict to hold the sorted data, then wrote it to the file

