Merge Beta with Stable releases #1
@ -22,10 +22,15 @@ scheduler = AsyncIOScheduler()
|
||||
if configGet("enabled", "scheduler", "birthdays"):
|
||||
@scheduler.scheduled_job(trigger="cron", hour=configGet("time", "scheduler", "birthdays"))
|
||||
async def check_birthdays():
|
||||
for entry in col_applications.find({"2": datetime.now().strftime("%d.%m.%Y")}):
|
||||
for entry in col_applications.find():
|
||||
if entry["application"]["2"].strftime("%d.%m") == datetime.now().strftime("%d.%m"):
|
||||
try:
|
||||
tg_user = await app.get_users(entry["user"])
|
||||
await app.send_message( configGet("admin_group"), locale("birthday", "message").format(str(tg_user.first_name), str(tg_user.username), str(relativedelta(datetime.now(), datetime.strptime(entry["2"], '%d.%m.%Y')).years)) ) # type: ignore
|
||||
await app.send_message( configGet("admin_group"), locale("birthday", "message").format(str(tg_user.first_name), str(tg_user.username), str(relativedelta(datetime.now(), entry["application"]["2"], '%d.%m.%Y').years)) ) # type: ignore
|
||||
logWrite(f"Notified admins about {entry['user']}'s birthday")
|
||||
except Exception as exp:
|
||||
logWrite(f"Could not find user {entry['user']} to send a message about birthday due to '{exp}'")
|
||||
continue
|
||||
logWrite("Birthdays check performed")
|
||||
|
||||
if configGet("enabled", "scheduler", "sponsorships"):
|
||||
|
Reference in New Issue
Block a user