0% found this document useful (0 votes)
19 views6 pages

Auto Spam

Uploaded by

caonima2727
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)
19 views6 pages

Auto Spam

Uploaded by

caonima2727
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/ 6

import tkinter as tk

from tkinter import ttk, messagebox, simpledialog


import threading
import time
import requests
import json
import os
import sys
from ttkthemes import ThemedTk

class AutoSpamGUI:
def __init__(self, master):
self.master = master
master.title("Auto Spam by Murad")
master.geometry("600x750")

self.style = ttk.Style(master)
self.style.theme_use("arc")

self.stop_event = threading.Event()
self.config_file = self.get_config_path()
self.load_config()
self.create_widgets()
self.spam_threads = []

def get_config_path(self):
if getattr(sys, 'frozen', False):
# Jika dijalankan sebagai executable
application_path = os.path.dirname(sys.executable)
else:
# Jika dijalankan sebagai script
application_path = os.path.dirname(os.path.abspath(__file__))

config_path = os.path.join(application_path, 'config.json')

# Jika config.json tidak ada di lokasi aplikasi, coba cari di direktori


saat ini
if not os.path.exists(config_path):
current_dir_config = os.path.join(os.getcwd(), 'config.json')
if os.path.exists(current_dir_config):
return current_dir_config

return config_path

def load_config(self):
if not os.path.exists(self.config_file):
self.config = {
"token": "",
"webhook_url": "",
"webhook_channel_id": "",
"channels": []
}
self.save_config()
else:
with open(self.config_file, 'r') as f:
self.config = json.load(f)
# Ensure all required keys exist
for key in ["channels", "token", "webhook_url", "webhook_channel_id"]:
if key not in self.config:
self.config[key] = "" if key != "channels" else []

def save_config(self):
with open(self.config_file, 'w') as f:
json.dump(self.config, f, indent=4)

def create_widgets(self):
main_frame = ttk.Frame(self.master, padding="20 20 20 20")
main_frame.grid(column=0, row=0, sticky=(tk.W, tk.E, tk.N, tk.S))
main_frame.columnconfigure(0, weight=1)
main_frame.rowconfigure(0, weight=1)

# Title
title_label = ttk.Label(main_frame, text="Auto Spam by Murad",
font=("Helvetica", 16, "bold"))
title_label.grid(column=0, row=0, sticky=tk.W, pady=10)

# Input fields
input_frame = ttk.LabelFrame(main_frame, text="Input Data", padding="10 10
10 10")
input_frame.grid(column=0, row=1, sticky=(tk.W, tk.E, tk.N, tk.S), pady=10)
input_frame.columnconfigure(0, weight=1)

ttk.Label(input_frame, text="Channel ID").grid(column=0, row=0,


sticky=tk.W, pady=5)
self.channel_id_entry = ttk.Entry(input_frame, width=50)
self.channel_id_entry.grid(column=0, row=1, sticky=(tk.W, tk.E), pady=2)

ttk.Label(input_frame, text="Text to Post").grid(column=0, row=2,


sticky=tk.W, pady=5)
self.message_text = tk.Text(input_frame, height=5, width=50)
self.message_text.grid(column=0, row=3, sticky=(tk.W, tk.E), pady=2)

ttk.Label(input_frame, text="Auth Token").grid(column=0, row=4,


sticky=tk.W, pady=5)
self.token_entry = ttk.Entry(input_frame, width=50)
self.token_entry.grid(column=0, row=5, sticky=(tk.W, tk.E), pady=2)
self.token_entry.insert(0, self.config.get("token", ""))

ttk.Label(input_frame, text="Jeda Waktu (detik)").grid(column=0, row=6,


sticky=tk.W, pady=5)
self.delay_entry = ttk.Entry(input_frame, width=50)
self.delay_entry.grid(column=0, row=7, sticky=(tk.W, tk.E), pady=2)

ttk.Label(input_frame, text="Ping User ID (untuk notifikasi


kegagalan)").grid(column=0, row=8, sticky=tk.W, pady=5)
self.ping_user_entry = ttk.Entry(input_frame, width=50)
self.ping_user_entry.grid(column=0, row=9, sticky=(tk.W, tk.E), pady=2)

ttk.Label(input_frame, text="Webhook URL").grid(column=0, row=10,


sticky=tk.W, pady=5)
self.webhook_url_entry = ttk.Entry(input_frame, width=50)
self.webhook_url_entry.grid(column=0, row=11, sticky=(tk.W, tk.E), pady=2)
self.webhook_url_entry.insert(0, self.config.get("webhook_url", ""))

ttk.Label(input_frame, text="Webhook Channel ID").grid(column=0, row=12,


sticky=tk.W, pady=5)
self.webhook_channel_id_entry = ttk.Entry(input_frame, width=50)
self.webhook_channel_id_entry.grid(column=0, row=13, sticky=(tk.W, tk.E),
pady=2)
self.webhook_channel_id_entry.insert(0,
self.config.get("webhook_channel_id", ""))

# Buttons
button_frame = ttk.Frame(main_frame)
button_frame.grid(column=0, row=2, sticky=(tk.W, tk.E), pady=10)
button_frame.columnconfigure(0, weight=1)
button_frame.columnconfigure(1, weight=1)

self.stop_button = ttk.Button(button_frame, text="Stop",


command=self.stop_spam)
self.stop_button.grid(column=1, row=0, sticky=(tk.W, tk.E), padx=5)

self.add_button = ttk.Button(button_frame, text="Tambah Konfigurasi",


command=self.add_config)
self.add_button.grid(column=0, row=1, sticky=(tk.W, tk.E), padx=5, pady=5)

self.delete_button = ttk.Button(button_frame, text="Hapus Konfigurasi",


command=self.show_delete_dialog)
self.delete_button.grid(column=1, row=1, sticky=(tk.W, tk.E), padx=5,
pady=5)

self.start_all_button = ttk.Button(button_frame, text="Start",


command=self.start_all_spam, style="Accent.TButton")
self.start_all_button.grid(column=0, row=0, sticky=(tk.W, tk.E), padx=5,
pady=5)

self.save_settings_button = ttk.Button(button_frame, text="Simpan


Pengaturan", command=self.save_settings)
self.save_settings_button.grid(column=0, row=3, columnspan=2, sticky=(tk.W,
tk.E), padx=5, pady=5)

def save_settings(self):
self.config["token"] = self.token_entry.get()
self.config["webhook_url"] = self.webhook_url_entry.get()
self.config["webhook_channel_id"] = self.webhook_channel_id_entry.get()

self.save_config()
messagebox.showinfo("Success", "Settings saved successfully")

def start_all_spam(self):
self.stop_event.clear() # Clear the stop event before starting
token = self.token_entry.get()
for channel in self.config["channels"]:
thread = threading.Thread(
target=self.spam_loop,
args=(
channel["channel_id"],
channel["message"],
token,
channel["delay"],
channel.get("ping_user")
)
)
self.spam_threads.append(thread)
thread.start()
messagebox.showinfo("Started", "Spam threads have been started for all
channels")
def stop_spam(self):
self.stop_event.set()
for thread in self.spam_threads:
thread.join()
self.spam_threads.clear()
messagebox.showinfo("Stopped", "All spam threads have been stopped")

def spam_loop(self, channel_id, message, token, delay, ping_user):


while not self.stop_event.is_set():
success, result = self.send_discord_message(token, channel_id, message)
print(result)
self.send_webhook(channel_id, message, success, delay, ping_user)
time.sleep(delay)

def send_discord_message(self, token, channel_id, message):


api_url = f"https://discord.com/api/v9/channels/{channel_id}/messages"
headers = {
'Authorization': token,
'Content-Type': 'application/json'
}
payload = {
'content': message
}
try:
response = requests.post(api_url, headers=headers, json=payload,
timeout=10)
response.raise_for_status()
return True, f'Message sent successfully to channel <#{channel_id}>!'
except requests.exceptions.RequestException as e:
return False, f'Failed to send message to channel <#{channel_id}>:
{str(e)}'

def send_webhook(self, channel_id, message, success, delay, ping_user=None):


webhook_url = self.config['webhook_url']
webhook_channel_id = self.config['webhook_channel_id']

embed = {
"title": "AUTO POST LOG",
"color": 0x00ff00 if success else 0xff0000,
"fields": [
{"name": "📺 Channel", "value": f"<#{channel_id}>", "inline": True},
{"name": "💌 Status", "value": "SENT SUCCESSFULLY" if success else
"FAILED TO SEND", "inline": True},
{"name": "📝 Message", "value": message[:1024], "inline": False},
{"name": " Delay", "value": f"{delay} seconds", "inline": True}
]
}

payload = {
"embeds": [embed]
}

if not success and ping_user:


payload["content"] = f"<@{ping_user}>"

try:
response = requests.post(webhook_url, json=payload, timeout=10)
response.raise_for_status()
print("Webhook sent successfully")
except requests.exceptions.RequestException as e:
print(f"Failed to send webhook: {str(e)}")

def add_config(self):
channel_id = self.channel_id_entry.get()
message = self.message_text.get("1.0", tk.END).strip()
delay = self.delay_entry.get()
ping_user = self.ping_user_entry.get()

if not channel_id or not message or not delay:


messagebox.showerror("Error", "Channel ID, Text to Post, and Delay must
be filled")
return

try:
delay = int(delay)
except ValueError:
messagebox.showerror("Error", "Delay must be a number")
return

new_config = {
"channel_id": channel_id,
"message": message,
"delay": delay,
"is_dm": False,
"ping_user": ping_user
}

self.config["channels"].append(new_config)
self.save_config()
messagebox.showinfo("Success", "Configuration added successfully")

# Clear fields after adding configuration


self.channel_id_entry.delete(0, tk.END)
self.message_text.delete("1.0", tk.END)
self.delay_entry.delete(0, tk.END)
self.ping_user_entry.delete(0, tk.END)

# Start the new configuration immediately


self.start_single_spam(new_config)

def start_single_spam(self, config):


token = self.token_entry.get()
thread = threading.Thread(
target=self.spam_loop,
args=(
config["channel_id"],
config["message"],
token,
config["delay"],
config.get("ping_user")
)
)
self.spam_threads.append(thread)
thread.start()
messagebox.showinfo("Started", f"Spam thread started for channel
{config['channel_id']}")
def show_delete_dialog(self):
if not self.config["channels"]:
messagebox.showinfo("Info", "No configurations to delete")
return

delete_window = tk.Toplevel(self.master)
delete_window.title("Delete Configuration")
delete_window.geometry("400x300")

listbox = tk.Listbox(delete_window, width=50)


listbox.pack(padx=10, pady=10, fill=tk.BOTH, expand=True)

for idx, channel in enumerate(self.config["channels"]):


listbox.insert(tk.END, f"{idx + 1}. Channel: {channel['channel_id']},
Message: {channel['message'][:30]}...")

def delete_selected():
selection = listbox.curselection()
if not selection:
messagebox.showerror("Error", "Select a configuration to delete")
return

idx = selection[0]
del self.config["channels"][idx]
self.save_config()
messagebox.showinfo("Success", "Configuration deleted successfully")
delete_window.destroy()

delete_button = ttk.Button(delete_window, text="Delete",


command=delete_selected)
delete_button.pack(pady=10)

def main():
root = ThemedTk(theme="arc")
gui = AutoSpamGUI(root)
root.mainloop()

if __name__ == "__main__":
main()

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy