Text
Text
import random
import string
import json
import requests
from telegram import Update, ReplyKeyboardMarkup, KeyboardButton,
InlineKeyboardButton, InlineKeyboardMarkup
from telegram.ext import Application, CommandHandler, MessageHandler,
CallbackQueryHandler, filters, ContextTypes
# Bot Token
TOKEN = "7867547186:AAFVcgTcn96kAEUmvZV36k9utBe73pb0FSo"
# API Endpoints
LOGIN_URL = "https://api.555mix.com/api/auth/agent/login"
CREATE_ACCOUNT_URL = "https://api.555mix.com/api/auth/member/signup"
MEMBERS_LIST_URL = "https://api.555mix.com/api/members"
DEPOSIT_URL = "https://api.555mix.com/api/transactions/members/"
WITHDRAW_URL = "https://api.555mix.com/api/transactions/members/" # Add correct
Withdraw URL if different
# Agent Credentials
AGENT_USERNAME = "c12noxMEG"
AGENT_PASSWORD = "Aabb7777"
# Bot Owner ID
OWNER_ID = 5670183911 # Only this user can approve deposits
# Logging
logging.basicConfig(format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
level=logging.INFO)
logger = logging.getLogger(name)
if response.status_code == 200:
members = response.json()
# Log the members list for debugging purposes
print("Fetched members:", members)
if member_username == username_lower:
print(f"Found matching member: {member}")
return member.get("id")
return None
# Start Command
async def start(update: Update, context: ContextTypes.DEFAULT_TYPE):
keyboard = [[KeyboardButton("Create Game Account")], [KeyboardButton("Unit
Deposit")], [KeyboardButton("Withdraw Unit")]]
reply_markup = ReplyKeyboardMarkup(keyboard, resize_keyboard=True)
await update.message.reply_text("Welcome! Choose an option below.",
reply_markup=reply_markup)
username = generate_username()
password = f"Mega{random.randint(1000, 9999)}"
payload = {
"name": "Megauser",
"username": username.replace("c12noxMEG", ""),
"password": password,
"mobile": "123456",
"twoThreeAllowed": True,
"betLimitation": {"maxForSingleBet": 500000, "maxForMixBet": 30000},
"commissions": [{"id": 30286497, "matchCount": 2, "betCommission": 0,
"winCommission": 15}],
"singleBetCommission": {"betCommission": 0, "highBetCommission": 0,
"winCommission": 5, "highWinCommission": 8},
"threeDCommission": 0,
"twoDCommission": 0
}
headers = {"Authorization": f"Bearer {token}", "Content-Type":
"application/json"}
response = requests.post(CREATE_ACCOUNT_URL, json=payload, headers=headers)
user_input = update.message.text.strip().split("\n")
if len(user_input) < 3:
await update.message.reply_text("❌ Invalid format. Send details in this
format:\n555mix Account\nPayment Method\nTransaction ID")
return
username = user_input[0].strip()
payment_method = user_input[1].strip()
transaction_id = user_input[2].strip()
await context.bot.send_message(
chat_id=OWNER_ID,
text=f"📩 **New Deposit Request**\n👤 Username: `{username}`\n💰 Payment
Method: {payment_method}\n📑 Transaction ID: {transaction_id}",
parse_mode="Markdown",
reply_markup=reply_markup
)
del context.user_data["awaiting_deposit_form"]
if not deposit_data:
await query.message.reply_text("❌ Deposit request not found in
pending_deposits.")
return
if action == "accept_deposit":
await query.message.reply_text(f"✅ Accepted deposit for {username}.")
context.user_data["pending_deposit"] = {
"request_id": request_id,
"username": username,
"payment_method": deposit_data["payment_method"],
"amount": deposit_data["amount"]
}
else:
await context.bot.send_message(chat_id=chat_id, text="❌ Your deposit
request has been declined.")
del pending_deposits[request_id]
request_id = context.user_data["pending_deposit"]["request_id"]
deposit_data = pending_deposits.get(request_id)
if not deposit_data:
await update.message.reply_text("❌ Deposit request not found.")
return
dynamic_id = get_dynamic_id(deposit_data["username"])
if not dynamic_id:
await update.message.reply_text("❌ Dynamic ID not found.")
return
payload = {
"command": "add",
"amount": deposit_data["amount"],
"credit": False
}
if response.status_code == 200:
await update.message.reply_text("✅ Deposit Successful!")
else:
await update.message.reply_text("❌ Deposit failed.")
del pending_deposits[request_id]
del context.user_data["pending_deposit"]
# Unit wd form
async def handle_withdraw_form(update: Update, context: ContextTypes.DEFAULT_TYPE):
if "awaiting_withdraw_form" not in context.user_data:
return
user_input = update.message.text.strip().split("\n")
if len(user_input) < 2:
await update.message.reply_text("❌ Invalid format. Send details in this
format:\nc12noxMEGxxx\nAmount")
return
username = user_input[0].strip()
try:
amount = float(user_input[1].strip())
except ValueError:
await update.message.reply_text("❌ Invalid amount. Please enter a valid
number.")
return
keyboard = [
[InlineKeyboardButton("✅ Accept",
callback_data=f"accept_withdraw_{request_id}")],
[InlineKeyboardButton("❌ Decline",
callback_data=f"decline_withdraw_{request_id}")]
]
reply_markup = InlineKeyboardMarkup(keyboard)
await context.bot.send_message(
chat_id=OWNER_ID,
text=f"📩 **New Withdraw Request**\n👤 Username: `{username}`\n💰 Amount:
{amount}",
parse_mode="Markdown",
reply_markup=reply_markup
)
del context.user_data["awaiting_withdraw_form"]
# Handle wd action
async def withdraw_action(update: Update, context: ContextTypes.DEFAULT_TYPE):
query = update.callback_query
await query.answer()
if not withdraw_data:
await query.message.reply_text("❌ Withdraw request not found in
pending_deposits.")
return
if action == "accept_withdraw":
await query.message.reply_text(f"✅ Accepted withdraw for {username}.
Withdraw amount: {withdraw_data['amount']}")
context.user_data["pending_withdraw"] = {"request_id": request_id,
"username": username, "amount": withdraw_data['amount']}
else:
await context.bot.send_message(chat_id=chat_id, text="❌ Your withdraw
request has been declined.")
del pending_deposits[request_id]
# Handle wd amount
async def handle_withdraw_amount(update: Update, context:
ContextTypes.DEFAULT_TYPE):
if "pending_withdraw" not in context.user_data:
await update.message.reply_text("❌ No pending withdraw request found.")
return
request_id = context.user_data["pending_withdraw"]["request_id"]
withdraw_data = pending_deposits.get(request_id)
if not withdraw_data:
await update.message.reply_text("❌ Withdraw request not found.")
return
dynamic_id = get_dynamic_id(withdraw_data["username"])
if not dynamic_id:
await update.message.reply_text("❌ Dynamic ID not found.")
return
payload = {
"command": "remove",
"amount": withdraw_data["amount"],
"credit": False
}
if response.status_code == 200:
await update.message.reply_text("✅ Withdraw Successful!")
else:
await update.message.reply_text("❌ Withdraw failed.")
del pending_deposits[request_id]
del context.user_data["pending_withdraw"]
# Main
async def main():
application = Application.builder().token(TOKEN).build()
application.add_handler(CommandHandler("start", start))
application.add_handler(CommandHandler("create_account", create_account))
application.add_handler(CommandHandler("unit_deposit", unit_deposit))
application.add_handler(CommandHandler("unit_withdraw", unit_withdraw))
application.add_handler(MessageHandler(filters.TEXT, handle_deposit_form))
application.add_handler(CallbackQueryHandler(deposit_action,
pattern=r"^accept_deposit_|decline_deposit_"))
application.add_handler(MessageHandler(filters.TEXT, handle_withdraw_form))
application.add_handler(CallbackQueryHandler(withdraw_action,
pattern=r"^accept_withdraw_|decline_withdraw_"))
application.add_handler(MessageHandler(filters.TEXT, handle_deposit_amount))
application.add_handler(MessageHandler(filters.TEXT, handle_withdraw_amount))
await application.run_polling()
if __name__ == "__main__":
import asyncio
asyncio.run(main())