Spaces:
Sleeping
Sleeping
File size: 17,191 Bytes
324c9ba | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 | 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
@app.route("/", methods=["GET", "POST"])
def bot_messages():
if request.method == "POST":
message = request.get_json()
handle_message(message)
return "OK", 200
return "<h1>API ENDPOINT<h1>"
@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 "<h1>This is an API Endpoint<h1>"
@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 "<h1>This is an API Endpoint<h1>"
@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 "<h1>This is an API Endpoint<h1>"
@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 "<h1>This is an Exness Registration Postback Endpoint<h1>"
@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 "<h1>This is an Exness Deposit Postback Endpoint<h1>"
@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 "<h1>This is an Exness Qualification Postback Endpoint<h1>"
@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 "<h1>This is an Exness Loyal Client Postback Endpoint<h1>"
@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 "<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)
|