Telegram Group Member Join Time Tool with Sorted Output

Preface

In the previous blog post, we added a feature to our join verification bot that allows manual initiation of the join verification for a specific group member.

This solves the problem that when the bot leaves the group (or experiences an anomaly), new members join the group, but these new members did not go through the join verification process.

So a new question arises: how do I know which members joined the group during the time period when the bot was away from the group?

Requirement

Output the join time of group members.

Implementation

I recalled that we had a tool for querying group member information

We just need to do some GPT-based programming and describe our requirements.
Based on the code above, add the feature: 
Save the time when group members joined the group
The modifications are very small.

I found that in the result obtained, the join times are out of order.
Adding a follow-up requirement to GPT
Query results need to be sorted by join time
The result given by GPT is basically functionally correct, but I have a specific requirement for the format saved in the file.
Originally, this project was meant to generate a user list for the message verification bot to serve as the verified user list valid.yaml
So the format saved in the file needs to be:
6617181826:
  username: atefatman
  full_name: 子 肥
7919966027:
  username: crazypeace_anti_bot_bot
  full_name: CZ_antibot_bot
I tried several approaches.
If I use list, the format saved in the file is
- 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 format saved in the file is
!!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 learned that in Python 3.7+, dict is ordered (maintaining insertion order)
So, ultimately, I used a new dict to store the sorted data, then wrote it to the file

Submit to Github


========

Related Recommendations


Comments