Working on /nearby

This commit is contained in:
Profitroll 2022-12-27 18:49:02 +01:00
parent 082acc85cf
commit e59aa98fd5
1 changed files with 23 additions and 4 deletions

View File

@ -1,15 +1,34 @@
from app import app, isAnAdmin
from app import app
from pyrogram import filters
from pyrogram.types import Message
from pyrogram.client import Client
from classes.holo_user import HoloUser
from modules import custom_filters
from modules.utils import configGet, should_quote
from modules.database import col_applications
# Nearby command ===============================================================================================================
@app.on_message(~ filters.scheduled & (filters.private | (filters.chat(configGet("admin_group")) | filters.chat(configGet("destination_group")))) & filters.command(["nearby"], prefixes=["/"]))
@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=["/"]))
async def cmd_nearby(app: Client, msg: Message):
if (await isAnAdmin(msg) is True) or (col_applications.find_one({"user": msg.from_user.id}) is not None):
await msg.reply_text("Yes, I exist.", quote=should_quote(msg))
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))
# 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")