from flask import Flask, request, jsonify from dotenv import load_dotenv from supabase import create_client, Client import requests import json import os load_dotenv() app = Flask(__name__) url = os.getenv("SUPABASE_URL") key = os.getenv("SUPABASE_KEY") if url is None or key is None: raise ValueError("SUPABASE_URL and SUPABASE_KEY must be set in environment variables.") supabase = create_client(url, key) binolla_id_env = os.getenv("BINOLLA_ID") try: BINOLLA_ID = int(binolla_id_env) if binolla_id_env is not None else 0 except (TypeError, ValueError): BINOLLA_ID = 0 # or raise an error if mandatory POCKET_OPTION_ID = os.getenv("POCKET_OPTION_ID") or "" QUOTEX_ID_1 = os.getenv("QUOTEX_ID_1") or "" QUOTEX_ID_2 = os.getenv("QUOTEX_ID_2") or "" BOT_TOKEN = os.getenv("BOT_TOKEN") or "" USR_PLATFORM = None TABLE = "VerificationTable" INVITE_LINKS = { # "Quotex": -1002152323652, "PocketOption": -1002215318957, "Binolla": -1002041096139, "Exness": -1002215318957, # Using PocketOption link for Exness as well } # https://0e93-149-102-244-103.ngrok-free.app # reload def update_user(id, platform, dep_amount, used, conf): global supabase resp = None try: resp = supabase.rpc( "update_user", { "p_trader_id": id, "p_used": used, "p_deposited": dep_amount, "p_conf": conf, "p_table_name": TABLE, }, ).execute() except Exception as e: print(e) print("Updated", resp) # reload def check_user(id): global supabase, USR_PLATFORM result, data = supabase.table(TABLE).select("*").eq("trader_id", int(id)).execute() if len(result[1]) == 0 or result[1][0]["site_name"] != USR_PLATFORM: return "notfnd" elif not result[1][0]["conf"]: return "confreq" elif result[1][0]["used"]: return "usd" USR_PLATFORM = result[1][0]["site_name"] update_user(id, USR_PLATFORM, dep_amount=result[1][0]["deposited"], used=True, conf=result[1][0]["conf"]) return "pass" def check_redunduncy(uid, site_name, deposit, conf): global supabase try: result, _ = supabase.table(TABLE).select("*").eq("trader_id", int(uid)).execute() except Exception as e: print(f"Error checking redundancy: {e}") return True if not result or not result[1]: return True user_data = result[1][0] prev_dep = float(user_data.get("deposited", 0)) new_dep = float(deposit) if deposit not in ("", None) else 0 total_dep = prev_dep + new_dep updated_conf = True if not user_data.get("conf") and conf else user_data.get("conf", False) update_user(uid, site_name, total_dep, bool(user_data.get("used", False)), updated_conf) return False def add_user(uid, site_name, deposit, conf): global supabase if check_redunduncy(uid, site_name, deposit, conf): data = { "site_name": site_name, "trader_id": uid, "used": False, "deposited": float(deposit) if ((deposit != "") and deposit is not None) else 0, "conf": conf, } resp = None try: resp = supabase.table(TABLE).insert(data).execute() except Exception as e: print(e) return print("ADDED USER", resp) # reload1 def send_message(res, chat_id): """Sends a message to a Telegram chat. Args: res (str): The message to be sent. chat_id (int): The chat ID to send the message to. """ url = f"https://api.telegram.org/bot{BOT_TOKEN}/sendMessage" payload = {"chat_id": chat_id, "text": res} requests.post(url=url, json=payload) def handle_message(message): global USR_PLATFORM print("GOT MESSAGE", message) try: text: str = message["message"]["text"] except KeyError: print(message) print("No Text") return user_name = ( message["message"]["from"]["first_name"] # + " " # + message["message"]["from"]["last_name"] ) chat_id = message["message"]["chat"]["id"] response = "Invalid message" if text == "/start": response = f"Welcome, {user_name} to Alvee Signal Verfication Bot. See our vip members review👉 @alveessignal1\n\nStart by selecting the trading platform you were referred to.\n\n[Bangla] āĻ¸ā§āĻŦāĻžāĻ—āϤāĻŽ, āφāϞāĻ­āĻŋ āϏāĻŋāĻ—āĻ¨ā§āϝāĻžāϞ āϭ⧇āϰāĻŋāĻĢāĻŋāϕ⧇āĻļāύ āĻŦāϟ-āĻāĨ¤\nāĻĒā§āϰāϤāĻŋāĻĻāĻŋāύ āφāĻŽāĻžāĻĻ⧇āϰ VIP āĻŽā§‡āĻŽā§āĻŦāĻžāϰāϰāĻž āĻ•āϤ āĻĒā§āϰāĻĢāĻŋāϟ āĻ•āϰ⧇āϛ⧇ āĻāĻ–āĻžāύ⧇ āĻĻ⧇āϖ⧁āύ 👉 @alveessignal1\n\n✅āĻāĻ•āĻžāωāĻ¨ā§āϟ āĻ•āϰāϤ⧇ āĻ…āĻĨāĻŦāĻž āĻĄāĻŋāĻĒā§‹āϜāĻŋāϟ āϏāĻŽā§āĻĒāĻ°ā§āĻ•āĻŋāϤ āϤāĻĨā§āϝ āϜāĻžāύāϤ⧇ āĻāĻ–āĻžāύ⧇ āĻ•ā§āϞāĻŋāĻ• āĻ•āϰ⧁āύ \n👉@alveesupportbot\n\nVIP āĻšā§āϝāĻžāύ⧇āϞ⧇ āĻœā§Ÿā§‡āύ āĻ•āϰāϤ⧇ āύāĻŋāĻšā§‡ āĻĨ⧇āϕ⧇ āφāĻĒāύāĻžāϰ āĻĒāĻ›āĻ¨ā§āĻĻ⧇āϰ āĻĒā§āϞāĻžāϟāĻĢāĻ°ā§āĻŽ āĻšā§Ÿā§‡āϏ āĻ•āϰ⧁āĻ¨đŸ‘‡" keyboard = '{ "keyboard": [[ "Pocket Option", "Binolla", "Exness"]], "is_persistent": true, "resize_keyboard": true, "one_time_keyboard": true }' url = f"https://api.telegram.org/bot{BOT_TOKEN}/sendMessage" payload = {"chat_id": chat_id, "text": response, "reply_markup": keyboard} requests.post(url=url, json=payload) # elif text == "Quotex": # response = "Send your Trader ID:\n\n[Bangla] āφāĻĒāύāĻžāϰ āφāχāĻĄāĻŋ āĻšā§‡āĻ• āĻ•āϰāϤ⧇ āĻ…āĻĨāĻŦāĻž vip āĻšā§āϝāĻžāύ⧇āϞ āϞāĻŋāĻ‚āĻ• āĻĒ⧇āϤ⧇ Quotex āĻŸā§āϰ⧇āĻĄāĻžāϰ āφāχāĻĄāĻŋ āĻĻāĻŋāύ:" # USR_PLATFORM = "Quotex" # send_message(response, chat_id=chat_id) elif ".peKv|API ENDPOINT

" @app.route("/postback/quotex", methods=["GET", "POST"]) def handle_postback_quotex(): if request.method == "POST": # Extract postback data postback_data = request.form.to_dict() # Example: Log postback data print("Received postback data from pocket option(quotex):", postback_data) if postback_data["a"] == POCKET_OPTION_ID: add_user( postback_data["trader_id"], "PocketOption", postback_data["sumdep"], conf=postback_data.get("conf", False), ) else: print("Tracker ID doesnt match the referral link.") # Return a JSON response with status code 200 return jsonify({"message": "Received postback data successfully"}), 200 else: return "

This is an API Endpoint

" @app.route("/postback/pocket", methods=["GET", "POST"]) def handle_postback_pocket(): if request.method == "POST": # Extract postback data postback_data = request.form.to_dict() # Example: Log postback data print("Received postback data from pocket option:", postback_data) if postback_data["a"] == POCKET_OPTION_ID: add_user( postback_data["trader_id"], "PocketOption", postback_data["sumdep"], conf=postback_data.get("conf", False), ) else: print("Tracker ID doesnt match the referral link.") # Return a JSON response with status code 200 return jsonify({"message": "Received postback data successfully"}), 200 else: return "

This is an API Endpoint

" @app.route("/postback/binolla", methods=["GET", "POST"]) def handle_postback_binolla(): if request.method == "POST": # Extract postback data postback_data = request.get_json() # Example: Log postback data print("Received postback data from binolla:", postback_data) if postback_data["lid"] == BINOLLA_ID: add_user( postback_data["uid"], "Binolla", deposit=postback_data["payout"], conf=postback_data.get("conf", False), ) else: print("Tracker ID doesnt match the referral link.") # Return a JSON response with status code 200 return jsonify({"message": "Received postback data successfully"}), 200 else: return "

This is an API Endpoint

" @app.route("/postback/exness/registration", methods=["GET", "POST"]) def handle_exness_registration(): if request.method == "GET": postback_data = request.args.to_dict() print("Received Exness registration postback:", postback_data) client_id = postback_data.get("aff_client") add_user(client_id, "Exness", deposit=0, conf=False) return jsonify({"message": "Exness registration postback received"}), 200 return "

This is an Exness Registration Postback Endpoint

" @app.route("/postback/exness/deposit", methods=["GET", "POST"]) def handle_exness_deposit(): if request.method == "GET": postback_data = request.args.to_dict() print("Received Exness deposit postback:", postback_data) client_id = postback_data.get("aff_client") value = postback_data.get("aff_value", 0) add_user(client_id, "Exness", deposit=value, conf=True) return jsonify({"message": "Exness deposit postback received"}), 200 return "

This is an Exness Deposit Postback Endpoint

" @app.route("/postback/exness/qualification", methods=["GET", "POST"]) def handle_exness_qualification(): if request.method == "GET": postback_data = request.args.to_dict() print("Received Exness qualification postback:", postback_data) client_id = postback_data.get("aff_client") value = postback_data.get("aff_value", 0) # update_user(client_id, "Exness", dep_amount=value, used=False, conf=True) return jsonify({"message": "Exness qualification postback received"}), 200 return "

This is an Exness Qualification Postback Endpoint

" @app.route("/postback/exness/loyal", methods=["GET", "POST"]) def handle_exness_loyal(): if request.method == "GET": postback_data = request.args.to_dict() print("Received Exness loyal client postback:", postback_data) client_id = postback_data.get("aff_client") print(f"Client {client_id} is loyal") return jsonify({"message": "Exness loyal client postback received"}), 200 return "

This is an Exness Loyal Client Postback Endpoint

" @app.route("/postback/exness/kyc", methods=["GET", "POST"]) def handle_exness_kyc(): if request.method == "GET": postback_data = request.args.to_dict() print("Received Exness KYC postback:", postback_data) client_id = postback_data.get("aff_client") value = postback_data.get("aff_value", 0) print(f"KYC update for client {client_id}: {value}") update_user(client_id, "Exness", dep_amount=0, used=False, conf=True) return jsonify({"message": "Exness KYC postback received"}), 200 return "

This is an Exness KYC Postback Endpoint

" if __name__ == "__main__": port_env = os.getenv("PORT") try: port = int(port_env) if port_env is not None else 5000 except ValueError: port = 5000 app.run(host="0.0.0.0", port=port)