Now ignoring bdays of users that left
This commit is contained in:
parent
05e3916478
commit
8beb33b7c3
@ -12,7 +12,7 @@ from pyrogram.types import BotCommand, BotCommandScopeChat, BotCommandScopeChatA
|
|||||||
from pyrogram.errors import bad_request_400
|
from pyrogram.errors import bad_request_400
|
||||||
from pyrogram.enums.chat_members_filter import ChatMembersFilter
|
from pyrogram.enums.chat_members_filter import ChatMembersFilter
|
||||||
from classes.holo_user import HoloUser
|
from classes.holo_user import HoloUser
|
||||||
from modules.utils import configGet, jsonSave, locale, logWrite
|
from modules.utils import configGet, jsonLoad, jsonSave, locale, logWrite
|
||||||
from dateutil.relativedelta import relativedelta
|
from dateutil.relativedelta import relativedelta
|
||||||
from modules.database import col_applications, col_sponsorships, col_youtube
|
from modules.database import col_applications, col_sponsorships, col_youtube
|
||||||
from xmltodict import parse
|
from xmltodict import parse
|
||||||
@ -66,6 +66,8 @@ if configGet("enabled", "features", "applications") is True:
|
|||||||
for entry in col_applications.find():
|
for entry in col_applications.find():
|
||||||
if entry["application"]["2"].strftime("%d.%m") == datetime.now().strftime("%d.%m"):
|
if entry["application"]["2"].strftime("%d.%m") == datetime.now().strftime("%d.%m"):
|
||||||
try:
|
try:
|
||||||
|
if entry["user"] not in jsonLoad(path.join(configGet("cache", "locations"), "group_members")):
|
||||||
|
continue
|
||||||
tg_user = await app.get_users(entry["user"])
|
tg_user = await app.get_users(entry["user"])
|
||||||
await app.send_message( configGet("admin", "groups"), 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
|
await app.send_message( configGet("admin", "groups"), 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")
|
logWrite(f"Notified admins about {entry['user']}'s birthday")
|
||||||
@ -82,6 +84,8 @@ if configGet("enabled", "features", "sponsorships") is True:
|
|||||||
async def check_sponsors():
|
async def check_sponsors():
|
||||||
for entry in col_sponsorships.find({"sponsorship.expires": {"$lt": datetime.now()+timedelta(days=2)}}):
|
for entry in col_sponsorships.find({"sponsorship.expires": {"$lt": datetime.now()+timedelta(days=2)}}):
|
||||||
try:
|
try:
|
||||||
|
if entry["user"] not in jsonLoad(path.join(configGet("cache", "locations"), "group_members")):
|
||||||
|
continue
|
||||||
tg_user = await app.get_users(entry["user"])
|
tg_user = await app.get_users(entry["user"])
|
||||||
until_expiry = relativedelta(datetime.now(), entry["sponsorship"]["expires"]).days
|
until_expiry = relativedelta(datetime.now(), entry["sponsorship"]["expires"]).days
|
||||||
await app.send_message( tg_user.id, locale("sponsorships_expires", "message").format(until_expiry) ) # type: ignore
|
await app.send_message( tg_user.id, locale("sponsorships_expires", "message").format(until_expiry) ) # type: ignore
|
||||||
@ -92,9 +96,11 @@ if configGet("enabled", "features", "sponsorships") is True:
|
|||||||
for entry in col_sponsorships.find({"sponsorship.expires": {"$lt": datetime.now()}}):
|
for entry in col_sponsorships.find({"sponsorship.expires": {"$lt": datetime.now()}}):
|
||||||
try:
|
try:
|
||||||
holo_user = HoloUser(entry["user"])
|
holo_user = HoloUser(entry["user"])
|
||||||
|
col_sponsorships.find_one_and_delete({"user": holo_user.id})
|
||||||
|
if entry["user"] not in jsonLoad(path.join(configGet("cache", "locations"), "group_members")):
|
||||||
|
continue
|
||||||
await app.send_message( entry["user"], locale("sponsorships_expired", "message") ) # type: ignore
|
await app.send_message( entry["user"], locale("sponsorships_expired", "message") ) # type: ignore
|
||||||
await holo_user.label_reset(configGet("users", "groups"))
|
await holo_user.label_reset(configGet("users", "groups"))
|
||||||
col_sponsorships.find_one_and_delete({"user": holo_user.id})
|
|
||||||
try:
|
try:
|
||||||
tg_user = await app.get_users(entry["user"])
|
tg_user = await app.get_users(entry["user"])
|
||||||
logWrite(f"Notified user that sponsorship expired")
|
logWrite(f"Notified user that sponsorship expired")
|
||||||
|
Reference in New Issue
Block a user