Untitled
unknown
plain_text
2 years ago
4.3 kB
17
Indexable
import requests
import tkinter as tk
from tkinter import messagebox
class SMMServiceApp:
def __init__(self, api_key):
self.api_key = api_key
self.root = tk.Tk()
self.root.title("SMM Service App")
self.balance_label = tk.Label(self.root, text="Current Balance: $0.00")
self.balance_label.pack()
self.services_label = tk.Label(self.root, text="Available Services:")
self.services_label.pack()
self.services_listbox = tk.Listbox(self.root, selectmode=tk.SINGLE)
self.services_listbox.pack()
self.quantity_var = tk.StringVar()
self.link_var = tk.StringVar()
quantity_label = tk.Label(self.root, text="Quantity:")
quantity_label.pack()
quantity_entry = tk.Entry(self.root, textvariable=self.quantity_var)
quantity_entry.pack()
link_label = tk.Label(self.root, text="Link:")
link_label.pack()
link_entry = tk.Entry(self.root, textvariable=self.link_var)
link_entry.pack()
confirm_button = tk.Button(self.root, text="Confirm and Process", command=self.confirm_order)
confirm_button.pack()
self.update_services()
self.update_balance()
self.root.mainloop()
def update_services(self):
try:
services = self.get_services()
for service in services:
self.services_listbox.insert(tk.END, f"{service['name']} - ${service['rate']} per unit")
except Exception as e:
self.show_error(f"Error getting services: {e}")
def get_services(self):
try:
response = self.make_api_request(action="services")
return response.json()
except Exception as e:
self.show_error(f"Error getting services: {e}")
return []
def update_balance(self):
balance_info = self.get_balance()
if balance_info:
balance = float(balance_info.get("balance", 0))
currency = balance_info.get("currency", "USD")
self.balance_label.config(text=f"Current Balance: ${balance:.2f} {currency}")
self.root.after(5000, self.update_balance) # Update balance every 5 seconds
def get_balance(self):
try:
response = self.make_api_request(action="balance")
return response.json()
except Exception as e:
self.show_error(f"Error getting balance: {e}")
return None
def confirm_order(self):
selected_index = self.services_listbox.curselection()
if not selected_index:
self.show_error("Please select a service.")
return
service = self.services_listbox.get(selected_index)
service_id = int(service.split('-')[0].strip())
quantity = self.quantity_var.get()
link = self.link_var.get()
if not quantity or not link:
self.show_error("Please fill in all fields.")
return
try:
quantity = int(quantity)
except ValueError:
self.show_error("Please enter a valid numeric value for Quantity.")
return
try:
response = self.make_api_request(
action="add",
service=service_id,
link=link,
quantity=quantity
)
order_id = response.json().get("order")
charge = response.json().get("charge")
confirmation_message = f"Order ID: {order_id}\nCharge: ${charge:.5f}"
messagebox.showinfo("Order Confirmation", confirmation_message)
except Exception as e:
self.show_error(f"Error processing order: {e}")
def make_api_request(self, **params):
try:
url = "https://smmfollows.com/api/v2"
params["key"] = self.api_key
response = requests.post(url, data=params)
response.raise_for_status()
return response
except requests.exceptions.RequestException as e:
self.show_error(f"API Request Error: {e}")
raise
def show_error(self, message):
messagebox.showerror("Error", message)
# Example Usage
api_key = 'ddce6233f5792cf86de317a2bda6d3b3'
app = SMMServiceApp(api_key)Editor is loading...