2022-12-27 19:49:02 +02:00
|
|
|
from app import app
|
2022-12-15 16:00:38 +02:00
|
|
|
from pyrogram import filters
|
2022-12-27 14:36:54 +02:00
|
|
|
from pyrogram.types import Message
|
|
|
|
from pyrogram.client import Client
|
2022-12-27 19:49:02 +02:00
|
|
|
from classes.holo_user import HoloUser
|
|
|
|
from modules import custom_filters
|
2022-12-15 16:00:38 +02:00
|
|
|
from modules.utils import configGet, should_quote
|
2022-12-15 16:12:52 +02:00
|
|
|
from modules.database import col_applications
|
2022-12-15 16:00:38 +02:00
|
|
|
|
|
|
|
# Nearby command ===============================================================================================================
|
2022-12-27 19:49:02 +02:00
|
|
|
@app.on_message(~ filters.scheduled & (custom_filters.allowed | custom_filters.admin) & (filters.private | (filters.chat(configGet("admin_group")) | filters.chat(configGet("destination_group")))) & filters.command(["nearby"], prefixes=["/"]))
|
2022-12-27 14:36:54 +02:00
|
|
|
async def cmd_nearby(app: Client, msg: Message):
|
2022-12-27 19:49:02 +02:00
|
|
|
|
|
|
|
if len(msg.command) < 1:
|
|
|
|
application = col_applications.find_one({"user": msg.from_user})
|
|
|
|
if application is None:
|
|
|
|
await msg.reply_text("You have no application")
|
|
|
|
return
|
|
|
|
location = application["application"]["3"]["loc"][0], application["application"]["3"]["loc"][1]
|
|
|
|
else:
|
|
|
|
# find location
|
|
|
|
location = "result"
|
|
|
|
|
|
|
|
output = []
|
|
|
|
users_nearby = col_applications.find( {"application": {"loc": { "$within": { "$center": [[location], 5] } }}} )
|
|
|
|
|
|
|
|
for user in users_nearby:
|
|
|
|
output.append(user)
|
|
|
|
|
|
|
|
await msg.reply_text("Yes, I exist.", quote=should_quote(msg))
|
|
|
|
|
2022-12-15 16:00:38 +02:00
|
|
|
# if not path.exists(f"{configGet('data', 'locations')}{sep}sponsors{sep}{msg.from_user.id}.json"):
|
|
|
|
# jsonSave(jsonLoad(f"{configGet('data', 'locations')}{sep}sponsor_default.json"), f"{configGet('data', 'locations')}{sep}sponsors{sep}{msg.from_user.id}.json")
|
|
|
|
# sponsor = jsonLoad(f"{configGet('data', 'locations')}{sep}sponsors{sep}{msg.from_user.id}.json")
|
|
|
|
# if sponsor["approved"]:
|
|
|
|
# if sponsor["expires"] is not None:
|
|
|
|
# if datetime.strptime(sponsor["expires"], "%d.%m.%Y") > datetime.now():
|
|
|
|
# await msg.reply_text(f"You have an active sub til **{sponsor['expires']}**.")
|
|
|
|
# else:
|
|
|
|
# await msg.reply_text(f"Your sub expired {int((datetime.now()-datetime.strptime(sponsor['expires'], '%d.%m.%Y')).days)} days ago.")
|
|
|
|
# elif sponsor["approved"]:
|
|
|
|
# await msg.reply_text(f"Your sub expiration date is not valid.")
|
|
|
|
# else:
|
|
|
|
# await msg.reply_text(f"You have no active subscription.")
|
|
|
|
# ==============================================================================================================================
|