tg_account_age/tg_account_age.py

56 lines
2.5 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# Tg user account age v3.15
# 05/09/2024
# https://t.me/ssleg © 2020 2024
from datetime import datetime, date
uid_dict = {1200000000: (date(2013, 8, 14), date(2020, 3, 30)),
1300000000: (date(2020, 3, 31), date(2020, 6, 25)),
1400000000: (date(2020, 6, 26), date(2020, 10, 29)),
1500000000: (date(2020, 10, 30), date(2021, 1, 3)),
1600000000: (date(2021, 1, 4), date(2021, 1, 25)),
1700000000: (date(2021, 1, 26), date(2021, 3, 16)),
1800000000: (date(2021, 3, 17), date(2021, 5, 6)),
1900000000: (date(2021, 5, 7), date(2021, 7, 15)),
2000000000: (date(2021, 7, 16), date(2021, 9, 21)),
2050000000: (date(2021, 9, 22), date(2021, 10, 3)),
2100000000: (date(2021, 10, 4), date(2021, 11, 3)),
5000000000: (date(2021, 11, 4), date(2021, 11, 30)),
5100000000: (date(2021, 12, 1), date(2022, 1, 18)),
5300000000: (date(2022, 1, 19), date(2022, 4, 11)),
5400000000: (date(2022, 4, 12), date(2022, 5, 26)),
5600000000: (date(2022, 5, 27), date(2022, 8, 13)),
5800000000: (date(2022, 8, 14), date(2022, 11, 16)),
6000000000: (date(2022, 11, 17), date(2023, 1, 27)),
6200000000: (date(2023, 1, 28), date(2023, 2, 7)),
6300000000: (date(2023, 2, 8), date(2023, 6, 28)),
6400000000: (date(2023, 6, 29), date(2023, 7, 21)),
6700000000: (date(2023, 7, 22), date(2023, 10, 18)),
7000000000: (date(2023, 10, 19), date(2024, 2, 19)),
7200000000: (date(2024, 2, 20), date(2024, 5, 29)),
7500000000: (date(2024, 5, 30), date(2024, 8, 20)),
}
def get_account_age(user_id):
for key in uid_dict:
if user_id < key:
return uid_dict[key]
return date(2024, 8, 21), datetime.now().date()
def get_account_age_txt(user_id):
month_names = {1: 'янв.', 2: 'фев.', 3: 'мар.', 4: 'апр.', 5: 'май', 6: 'июнь', 7: 'июль', 8: 'авг.', 9: 'сен.',
10: 'окт.', 11: 'ноя.', 12: 'дек.'}
from_date, to_date = get_account_age(user_id)
if from_date.year == to_date.year:
if from_date.month == to_date.month:
txt = f'{month_names[from_date.month]} {to_date.year}'
else:
txt = f'{month_names[from_date.month]} - {month_names[to_date.month]} {to_date.year}'
else:
txt = f'{month_names[from_date.month]} {from_date.year} - {month_names[to_date.month]} {to_date.year}'
return txt