Advertisement
ayiemedia

sender.py

Nov 1st, 2023 (edited)
1,041
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.57 KB | None | 0 0
  1. import tkinter as tk
  2. import time
  3. from selenium import webdriver
  4. from selenium.webdriver.common.action_chains import ActionChains
  5. from selenium.webdriver.common.keys import Keys
  6. from selenium.webdriver.chrome.options import Options as ChromeOptions
  7. from selenium.webdriver.firefox.options import Options as FirefoxOptions
  8.  
  9. def send_data(driver_type):
  10.     target_numbers = entry1.get("1.0", "end-1c").strip().split('\n')
  11.     message = message_label1.get("1.0", "end-1c").strip()
  12.    
  13.     if driver_type == 'chrome':
  14.         options = ChromeOptions()
  15.         options.headless = False  # Set to True if you want it to run in the background (headless)
  16.         driver = webdriver.Chrome(options=options)
  17.     elif driver_type == 'firefox':
  18.         options = FirefoxOptions()
  19.         options.headless = False  # Set to True if you want it to run in the background (headless)
  20.         driver = webdriver.Firefox(options=options)
  21.  
  22.     login_time = 60
  23.     new_msg_time = 15
  24.     send_msg_time = 15
  25.  
  26.     link = 'https://web.whatsapp.com'
  27.     driver.get(link)
  28.     time.sleep(login_time)
  29.  
  30.     for target_number in target_numbers:
  31.         cleaned_number = target_number.strip()
  32.         if cleaned_number and message:
  33.             if not cleaned_number.startswith('+'):
  34.                 cleaned_number = '+' + cleaned_number
  35.             cleaned_number = cleaned_number.replace(" ", "").replace("-", "").replace("(", "").replace(")", "")
  36.             whatsapp_link = f"https://web.whatsapp.com/send/?phone={cleaned_number}&text={message}"
  37.            
  38.             driver.get(whatsapp_link)
  39.             time.sleep(new_msg_time)
  40.             actions = ActionChains(driver)
  41.             actions.send_keys(Keys.ENTER)
  42.             actions.perform()
  43.             time.sleep(send_msg_time)
  44.     driver.quit()
  45.  
  46. def marque_text():
  47.     text = mlabel.cget("text")
  48.     text = text[1:] + text[0]
  49.     mlabel.config(text=text)
  50.     app.after(1000, marque_text)
  51.  
  52. app = tk.Tk()
  53. app.title("SENDER")
  54. app.geometry("800x600")
  55. app.configure(bg="gray")
  56.  
  57. app = tk.Frame(app, bg="#47926e")
  58. app.pack(fill=tk.BOTH, expand=True)
  59.  
  60. mframe = tk.Frame(app, bg="#01e675")
  61. mframe.pack(fill=tk.BOTH)
  62.  
  63. mlabel = tk.Label(mframe, text="DAPATBELAJAR.COM - ", font=("MV Boli", 20, "bold"), bg="#01e675", underline=-1)
  64. mlabel.pack(side=tk.TOP)
  65.  
  66. marque_text()
  67.  
  68. frame1 = tk.Frame(app, bg="#47926e")
  69. frame1.pack(fill=tk.X, pady=20)
  70.  
  71. label1 = tk.Label(frame1, width=10, text="Target\nNumbers", font=("Copperplate", 15, "bold"), bg="#25d366", fg="black")
  72. label1.pack(side=tk.LEFT, padx=5)
  73.  
  74. entry1 = tk.Text(frame1, height=4, width=40, font=("Helvetica", 15, "bold"))
  75. entry1.pack(side=tk.LEFT, fill=tk.X, expand=True, padx=20)
  76.  
  77. frame1 = tk.Frame(app, bg="#47926e")
  78. frame1.pack(fill=tk.X, pady=20)
  79.  
  80. message_label = tk.Label(frame1, width=10, text="Your\nMessage", font=("Copperplate", 15, "bold"), bg="#25d366", fg="black")
  81. message_label.pack(side=tk.LEFT, padx=5)
  82.  
  83. message_label1 = tk.Text(frame1, height=4, width=40, font=("Helvetica", 15, "bold"))
  84. message_label1.pack(side=tk.LEFT, fill=tk.X, expand=True, padx=20)
  85.  
  86. button_frame = tk.Frame(app, bg="#47926e")
  87. button_frame.pack(fill=tk.X, pady=20)
  88.  
  89. # Send Button
  90. chrome_button = tk.Button(app, text="SEND using Chrome", font=("Copperplate", 25, "bold"), bg="#01e675", fg="black", command=lambda: send_data('chrome'))
  91. chrome_button.pack(side=tk.BOTTOM, fill=tk.BOTH)
  92.  
  93. firefox_button = tk.Button(app, text="SEND using Firefox", font=("Copperplate", 25, "bold"), bg="orange", fg="black", command=lambda: send_data('firefox'))
  94. firefox_button.pack(side=tk.BOTTOM, fill=tk.BOTH)
  95.  
  96. app.mainloop()
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement