0% found this document useful (0 votes)
27 views7 pages

Text

This document outlines a Telegram bot for managing user accounts and transactions on the 555mix platform. It includes functionalities for creating game accounts, processing deposits and withdrawals, and handling user interactions through commands and inline buttons. The bot uses API endpoints for authentication and transaction management, and it logs actions for debugging purposes.

Uploaded by

robbanamk
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views7 pages

Text

This document outlines a Telegram bot for managing user accounts and transactions on the 555mix platform. It includes functionalities for creating game accounts, processing deposits and withdrawals, and handling user interactions through commands and inline buttons. The bot uses API endpoints for authentication and transaction management, and it logs actions for debugging purposes.

Uploaded by

robbanamk
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 7

import logging

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)

# Store dynamic IDs in JSON


DYNAMIC_ID_FILE = "dynamic_ids.json"

# Dictionary to store deposit requests


pending_deposits = {}

# Function to get auth token


def get_auth_token():
payload = {"username": AGENT_USERNAME, "password": AGENT_PASSWORD}
response = requests.post(LOGIN_URL, json=payload)
if response.status_code == 200:
return response.json().get("accessToken")
return None

# Fetch Member ID (Dynamic ID)


def get_dynamic_id(username):
token = get_auth_token()
if not token:
return None

headers = {"Authorization": f"Bearer {token}"}


response = requests.get(MEMBERS_LIST_URL, headers=headers)

if response.status_code == 200:
members = response.json()
# Log the members list for debugging purposes
print("Fetched members:", members)

# Ensure we're comparing the full username (without stripping)


for member in members:
member_username = member.get("username", "").strip().lower()
username_lower = username.strip().lower() # Keep the full input
username for comparison

# Log the comparison for debugging


print(f"Comparing: '{member_username}' with '{username_lower}'")

if member_username == username_lower:
print(f"Found matching member: {member}")
return member.get("id")

print(f"No matching member found for username: {username}")


else:
print("Failed to fetch members list. Status code:", response.status_code)

return None

# Generate Unique 3-Letter Username


def generate_username():
return f"c12noxMEG{''.join(random.choices(string.ascii_lowercase, k=3))}"

# 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)

# Create Game Account


async def create_account(update: Update, context: ContextTypes.DEFAULT_TYPE):
token = get_auth_token()
if not token:
await update.message.reply_text("❌ Authentication failed. Please try again
later.")
return

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)

if response.status_code == 201 and response.json().get("success"):


await update.message.reply_text(
f"✅ **Game Account Created!**\n👤 Username: {username}\n🔑 Password:
{password}\n\n"
f"🔗 [555mix App
Download](https://www.bet555mix.com/android/555Mix_v10.0.0.apk)\n"
f"🌐 [Login Here](https://m.bet555mix.com)", parse_mode="Markdown"
)
else:
await update.message.reply_text("❌ Failed to create an account. Try again
later.")

# Unit Deposit Request


async def unit_deposit(update: Update, context: ContextTypes.DEFAULT_TYPE):
keyboard = [
[InlineKeyboardButton("WavePay: 09761992788 (Ei Mon Aung)",
callback_data="deposit_wavepay")],
[InlineKeyboardButton("KPay: 09788887696 (Ei Mon Aung)",
callback_data="deposit_kpay")]
]
reply_markup = InlineKeyboardMarkup(keyboard)
await update.message.reply_text("Please choose your payment method.",
reply_markup=reply_markup)

# Handle Deposit Information Form


async def handle_deposit_form(update: Update, context: ContextTypes.DEFAULT_TYPE):
if "awaiting_deposit_form" not in context.user_data:
return

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()

if not username.startswith("c12noxMEG") or len(username) != 12:


await update.message.reply_text("❌ Invalid username format. It must start
with 'c12noxMEG' and be exactly 12 characters long.")
return

await update.message.reply_text("📋 Reviewing Information... Please wait.",


parse_mode="Markdown")

request_id = f"{update.message.chat_id}_{random.randint(1000, 9999)}"


pending_deposits[request_id] = {
"username": username,
"payment_method": payment_method,
"transaction_id": transaction_id,
"chat_id": update.message.chat_id
}
keyboard = [
[InlineKeyboardButton("✅ Accept",
callback_data=f"accept_deposit_{request_id}")],
[InlineKeyboardButton("❌ Decline",
callback_data=f"decline_deposit_{request_id}")]
]
reply_markup = InlineKeyboardMarkup(keyboard)

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"]

# Handle Deposit Action


async def deposit_action(update: Update, context: ContextTypes.DEFAULT_TYPE):
query = update.callback_query
await query.answer()

action, request_id = query.data.split("_", 1)


deposit_data = pending_deposits.get(request_id)

if not deposit_data:
await query.message.reply_text("❌ Deposit request not found in
pending_deposits.")
return

username, chat_id = deposit_data["username"], deposit_data["chat_id"]

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]

# Handle Deposit Amount


async def handle_deposit_amount(update: Update, context:
ContextTypes.DEFAULT_TYPE):
if "pending_deposit" not in context.user_data:
await update.message.reply_text("❌ No pending deposit request found.")
return

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
}

headers = {"Authorization": f"Bearer {get_auth_token()}"}


response = requests.post(f"{DEPOSIT_URL}/{dynamic_id}", json=payload,
headers=headers)

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 Withdraw Request


async def unit_withdraw(update: Update, context: ContextTypes.DEFAULT_TYPE):
await update.message.reply_text(
"📌 Please fill out the form:\n1. 555mix Account Username\n2. Withdraw
Amount",
parse_mode="Markdown"
)
context.user_data["awaiting_withdraw_form"] = True

# 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

if not username.startswith("c12noxMEG") or len(username) != 12:


await update.message.reply_text("❌ Invalid username format. It must start
with 'c12noxMEG' and be exactly 12 characters long.")
return

await update.message.reply_text("📋 Reviewing Information... Please wait.",


parse_mode="Markdown")

request_id = f"{update.message.chat_id}_{random.randint(1000, 9999)}"


pending_deposits[request_id] = {
"username": username,
"amount": amount,
"chat_id": update.message.chat_id
}

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()

action, request_id = query.data.split("_", 1)


withdraw_data = pending_deposits.get(request_id)

if not withdraw_data:
await query.message.reply_text("❌ Withdraw request not found in
pending_deposits.")
return

username, chat_id = withdraw_data["username"], withdraw_data["chat_id"]

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
}

headers = {"Authorization": f"Bearer {get_auth_token()}"}


response = requests.post(f"{WITHDRAW_URL}/{dynamic_id}", json=payload,
headers=headers)

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())

You might also like