Spaces:
Sleeping
Sleeping
| 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|<L9^5Ur.8:v`B@G<}zE!k{" in text: | |
| send_message("Admin Authenticated", chat_id=chat_id) | |
| elif text == "Pocket Option": | |
| response = "Send your Trader ID:\n\n[Bangla] আপনার আইডি চেক করতে অথবা vip চ্যানেল লিংক পেতে Pocket Option ট্রেডার আইডি দিন:" | |
| USR_PLATFORM = "PocketOption" | |
| send_message(response, chat_id=chat_id) | |
| elif text == "Binolla": | |
| response = "Send your Trader ID:\n\n[Bangla] আপনার আইডি চেক করতে অথবা vip চ্যানেল লিংক পেতে Binolla ট্রেডার আইডি দিন:" | |
| USR_PLATFORM = "Binolla" | |
| send_message(response, chat_id=chat_id) | |
| elif text == "Exness": | |
| response = "Send your Client ID:\n\n[Bangla] আপনার আইডি চেক করতে অথবা vip চ্যানেল লিংক পেতে Exness Client ID দিন:" | |
| USR_PLATFORM = "Exness" | |
| send_message(response, chat_id=chat_id) | |
| elif text.isnumeric(): | |
| if USR_PLATFORM == None: | |
| send_message("Select Platform First", chat_id=chat_id) | |
| return | |
| checkUser = check_user(text) | |
| if checkUser == "confreq": | |
| # if USR_PLATFORM == "Quotex": | |
| # send_message( | |
| # "Your account created from our link. Now deposit $30 and Get our vip Channel Link.\n\n[Bangla] আপনার একাউন্ট খোলা সফল হয়েছে এখন $৩০ ডিপোজিট করুন তাহলে আপনাকে VIP চ্যানেলের লিংক দেওয়া হবে।\n\n📊ডিপোজিট বোনাস পেতে নিচের Promo code ব্যাবহার করুন📊👇👇\n\n➡️Special Promo Code: Alvee\n\n➡️Monthly Promo Code : 8gLK9ldJTy\n\n➡️150$ Promo Code: RLR50", | |
| # chat_id=chat_id, | |
| # ) | |
| # if USR_PLATFORM == "PocketOption": | |
| send_message( | |
| "Your account created from our link. Now Verify your account and Get our vip Channel Link.\n\n[Bangla] আপনার একাউন্ট খোলা সফল হয়েছে এখন ভেরিফাই করুন তাহলে আপনাকে Private চ্যানেলের লিংক দেওয়া হবে।\n\n📊ডিপোজিট বোনাস পেতে নিচের Promo code ব্যাবহার করুন📊👇👇\n\n➡Special Promo Code: TTQ438\n\n👆এই প্রমোকোড টি ব্যাবহার করার জন্য সর্বনিম্ন $৫০ ডিপোজিট করতে হবে।", | |
| chat_id=chat_id, | |
| ) | |
| # else: | |
| # send_message( | |
| # "Your account created from our link. Now deposit $30 and Get our vip Channel Link.\n\n[Bangla] আপনার একাউন্ট খোলা সফল হয়েছে এখন $৩০ ডিপোজিট করুন তাহলে আপনাকে VIP চ্যানেলের লিংক দেওয়া হবে।\n\n📊ডিপোজিট বোনাস পেতে নিচের Promo code ব্যাবহার করুন📊👇👇\n\n➡️Special Promo Code: mqf895", | |
| # chat_id=chat_id, | |
| # ) | |
| elif checkUser == "notfnd": | |
| message = ( | |
| f"❌ this account ({text}) not created with my link\n\n" | |
| "[Bangla] আপনার একাউন্ট আমাদের রেফার লিংক থেকে খোলা হয়নি নিচের লিংক থেকে একাউন্ট করে আবার ট্রাই করুন।\n\n" | |
| "Create account and deposit minimum $30👇🔥📈\n\n" | |
| "Create`Pocket Option` or `Binolla` With The Link -👇\n\n" | |
| " https://cutt.ly/LeW1XNDQ\n\n" | |
| "https://cutt.ly/9w3EC0i0\n\n" | |
| "Deposit Minimum = $30 or more\n\n" | |
| " Pocket Option [ 50% Bonus = Aokcipbs ]\n\n" | |
| "Binolla [ 50% Bonus = a7ukwp ]\n\n" | |
| "Then Send TRADER ID (Only ID NO)" | |
| ) | |
| send_message( | |
| message, | |
| chat_id=chat_id, | |
| ) | |
| elif checkUser == "pass": | |
| url = f"https://api.telegram.org/bot{BOT_TOKEN}/createChatInviteLink" | |
| payload = { | |
| "chat_id": INVITE_LINKS[USR_PLATFORM], | |
| "name": f"Created by {user_name} for {USR_PLATFORM}", | |
| "member_limit": 1, | |
| } | |
| response = requests.post(url=url, json=payload) | |
| send_message( | |
| f"Hey {user_name} congratulations you've successfully completed everything. Now join here for VIP Signal.", | |
| chat_id, | |
| ) | |
| try: | |
| send_message(response.json()["result"]["invite_link"], chat_id) | |
| except: | |
| print("Couldnt send invite link") | |
| elif checkUser == "usd": | |
| send_message( | |
| "Invite link already claimed.\n\n[Bangla] এই ট্রেডার আইডি দিয়ে অলরেডি VIP চ্যানেলে জয়েন করা হয়েছে", | |
| chat_id=chat_id, | |
| ) | |
| else: | |
| send_message( | |
| "Invalid message. Type `/start` to start verification process", | |
| chat_id=chat_id, | |
| ) | |
| # abc | |
| def bot_messages(): | |
| if request.method == "POST": | |
| message = request.get_json() | |
| handle_message(message) | |
| return "OK", 200 | |
| return "<h1>API ENDPOINT<h1>" | |
| 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 "<h1>This is an API Endpoint<h1>" | |
| 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 "<h1>This is an API Endpoint<h1>" | |
| 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 "<h1>This is an API Endpoint<h1>" | |
| 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 "<h1>This is an Exness Registration Postback Endpoint<h1>" | |
| 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 "<h1>This is an Exness Deposit Postback Endpoint<h1>" | |
| 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 "<h1>This is an Exness Qualification Postback Endpoint<h1>" | |
| 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 "<h1>This is an Exness Loyal Client Postback Endpoint<h1>" | |
| 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 "<h1>This is an Exness KYC Postback Endpoint<h1>" | |
| 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) | |