swindonmakers / AccessSystem

Swindon Makerspace access system
2 stars 3 forks source link

List group members who are not valid - /check_valid_members <months> #91

Closed castaway closed 5 months ago

castaway commented 5 months ago

Fixes #70

Intended for the Members Only chat, should work anywhere the bot is an admin. Only works for directors.

Banning / removing members from the chat can also be added, haven't yet

After trying several methods to get the Telegram API to give me the list of group members, I have up and resorted to the following:

Since it needs to obey API rate limiting (max 30 calls per sec) it will be quite slow if asked to do everybody, thus the time restriction.

SQL produced looks like:

SELECT person.id, person.telegram_chatid, person.name FROM (SELECT me.person_id, MAX( expires_on_date ) 
AS max_expires FROM dues me GROUP BY person_id) me  JOIN people person ON person.id = me.person_id WHERE
 ( ( ( me.max_expires BETWEEN ? AND ? ) AND person.telegram_chatid IS NOT NULL ) ): '2023-09-11 17:37:18
', '2024-03-11 17:37:18'