Skip to content

Commit

Permalink
chore: Update .gitignore to ignore, update application and added MSI
Browse files Browse the repository at this point in the history
  • Loading branch information
wekesa360 committed Jul 8, 2024
1 parent 35a751a commit 1b985a7
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 15 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ __pycache__/
*/chrome-data
sample.csv
build/
whatsapp_user_data/
whatsapp_user_data/
output/
.vscode
Binary file not shown.
2 changes: 1 addition & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def create_widgets(self):

# Message Input
message_frame = ctk.CTkFrame(main_frame, fg_color="transparent")
message_frame.grid(row=2, column=0, columnspan=3, sticky="nsew", pady=(20, 0))
message_frame.grid(row=2, column=0, columnspan=3, sticky="nsew", pady=(20, 0), )
message_frame.grid_columnconfigure(0, weight=1)
message_frame.grid_rowconfigure(1, weight=1)

Expand Down
3 changes: 2 additions & 1 deletion build-installer.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ files = app.py
contact_converter.py
whatsapp_bot.py
browser_prompt.py
constants.py
constants.py
emoji_picker.py
pywin32

# Add other .py files your project needs, one per line

Expand Down
37 changes: 26 additions & 11 deletions emoji_picker.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import customtkinter as ctk # type: ignore
from tkinter import Label, font as tkfont
from constants import (
PRIMARY_COLOR,
)



class EmojiPicker(ctk.CTkToplevel):
def __init__(self, master, callback, theme):
super().__init__(master)
Expand All @@ -14,6 +13,7 @@ def __init__(self, master, callback, theme):
self.configure(fg_color=self.theme.bg)
self.callback = callback


self.emoji_list = [
"😀", "😃", "😄", "😁", "😆", "😅", "😂", "🤣", "😊", "😇", "🙂", "🙃", "😉", "😌", "😍", "🥰", "😘", "😗", "😙", "😚",
"😋", "😛", "😝", "😜", "🤪", "🤨", "🧐", "🤓", "😎", "🤩", "🥳", "😏", "😒", "😞", "😔", "😟", "😕", "🙁", "☹️", "😣",
Expand All @@ -30,24 +30,39 @@ def __init__(self, master, callback, theme):
self.create_emoji_buttons()

def create_emoji_buttons(self):
# Create a canvas with scrollbar
canvas = ctk.CTkCanvas(self, bg=self.theme.bg, highlightthickness=0)
scrollbar = ctk.CTkScrollbar(self, orientation="vertical", command=canvas.yview)
scrollable_frame = ctk.CTkFrame(canvas, fg_color=self.theme.bg)

scrollable_frame.bind(

# Create a frame inside the canvas
self.scrollable_frame = ctk.CTkFrame(canvas, fg_color=self.theme.bg)
self.scrollable_frame.bind(
"<Configure>",
lambda e: canvas.configure(scrollregion=canvas.bbox("all"))
)

canvas.create_window((0, 0), window=scrollable_frame, anchor="nw")
canvas.create_window((0, 0), window=self.scrollable_frame, anchor="nw")
canvas.configure(yscrollcommand=scrollbar.set)

# Try different fonts
emoji_fonts = ["Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", "Twitter Color Emoji", "EmojiOne Color"]
emoji_font = None
for font_name in emoji_fonts:
try:
emoji_font = tkfont.Font(family=font_name, size=24)
break
except:
continue

if emoji_font is None:
emoji_font = tkfont.nametofont("TkDefaultFont").copy()
emoji_font.config(size=24)

# Create labels for each emoji
for i, emoji_char in enumerate(self.emoji_list):
btn = ctk.CTkButton(scrollable_frame, text=emoji_char, font=("Segoe UI Emoji", 20),
command=lambda x=emoji_char: self.select_emoji(x),
fg_color=self.theme.accent, text_color=self.theme.text,
hover_color=PRIMARY_COLOR, width=40, height=40)
btn.grid(row=i // 8, column=i % 8, padx=2, pady=2)
label = Label(self.scrollable_frame, text=emoji_char, font=emoji_font, bg=self.theme.bg)
label.grid(row=i // 8, column=i % 8, padx=2, pady=2)
label.bind("<Button-1>", lambda e, emoji=emoji_char: self.select_emoji(emoji))

canvas.pack(side="left", fill="both", expand=True)
scrollbar.pack(side="right", fill="y")
Expand Down
1 change: 1 addition & 0 deletions geckodriver.log
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
1720183430752 geckodriver INFO Listening on 127.0.0.1:51948
1720374610746 geckodriver INFO Listening on 127.0.0.1:60988
Binary file added icons/chrome.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/edge.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/firefox.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 22 additions & 1 deletion whatsapp_bot.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import tempfile
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
Expand All @@ -12,6 +13,7 @@
import urllib.parse
import time
import os
import stat
from constants import (
MAX_RETRY_ATTEMPTS,
CHAT_LOAD_TIMEOUT,
Expand All @@ -22,10 +24,29 @@ class WhatsAppBot:
def __init__(self, browser_name, log_callback, headless=False):
self.driver = None
self.browser_name = browser_name
self.user_data_dir = os.path.join(os.getcwd(), "whatsapp_user_data")
self.user_data_dir = os.path.join(tempfile.gettempdir(), "whatsapp_user_data")
self.log_callback = log_callback
self.stop_flag = False
self.headless = headless
self.ensure_user_data_dir()

def ensure_user_data_dir(self):
try:
if not os.path.exists(self.user_data_dir):
os.makedirs(self.user_data_dir)
if os.name == "nt": # Windows
import win32api
import win32security
user_sid = win32security.LookupAccountName(None, win32api.GetUserName())[0]
security_descriptor = win32security.GetFileSecurity(self.user_data_dir, win32security.DACL_SECURITY_INFORMATION)
dacl = win32security.ACL()
dacl.AddAccessAllowedAce(win32security.ACL_REVISION, win32security.FILE_ALL_ACCESS, user_sid)
security_descriptor.SetSecurityDescriptorDacl(1, dacl, 0)
win32security.SetFileSecurity(self.user_data_dir, win32security.DACL_SECURITY_INFORMATION, security_descriptor)
else: # Unix-based systems and Linux
os.chmod(self.user_data_dir, stat.S_IRWXU)
except Exception as e:
raise Exception(f"Failed to create user data directory: {str(e)}")

def initialize_driver(self):
if not self.driver:
Expand Down

0 comments on commit 1b985a7

Please sign in to comment.