Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions bot/helper/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def __init__(self):
self.collection = self.db["playlist"]
self.config = self.db["config"]
self.files = self.db["files"]
self.verifications = self.db["verifications"]

async def create_folder(self, parent_id, folder_name, thumbnail):
folder = {"parent_folder": parent_id, "name": folder_name,
Expand Down Expand Up @@ -123,3 +124,18 @@ async def search_tgfiles(self, id, query, page=1, per_page=50):

async def add_btgfiles(self, data):
result = self.files.insert_many(data)

async def save_verification(self, visitor_id, ip_address, user_agent, verified_at, expires_at):
payload = {
"visitor_id": visitor_id,
"ip_address": ip_address,
"user_agent": user_agent,
"verified_at": verified_at,
"expires_at": expires_at,
}
result = self.verifications.update_one(
{"visitor_id": visitor_id},
{"$set": payload},
upsert=True
)
return result.acknowledged
4 changes: 4 additions & 0 deletions bot/server/render_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ async def render_page(
redirect_url="",
msg="",
chat_id="",
verify_nonce="",
verify_wait=0,
):
theme = await db.get_variable("theme")
if theme is None or theme == "":
Expand All @@ -51,6 +53,8 @@ async def render_page(
.replace("<!-- Error -->", msg or "")
.replace("<!-- Theme -->", theme.lower())
.replace("<!-- RedirectURL -->", redirect_url)
.replace("<!-- VerifyNonce -->", verify_nonce)
.replace("<!-- VerifyWait -->", str(verify_wait))
)
elif route == "home":
async with aiopen(ospath.join(tpath, "home.html"), "r") as f:
Expand Down
Loading