Skip to content

Commit

Permalink
new build soon
Browse files Browse the repository at this point in the history
  • Loading branch information
maddox05 committed Dec 1, 2023
1 parent f93b350 commit f90cc9f
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 377 deletions.
7 changes: 7 additions & 0 deletions log.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Opened
Opened
Opened
Opened
Opened
Opened
Opened
74 changes: 8 additions & 66 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import time
import keyboard
import pyautogui
from TikTokLive import TikTokLiveClient
from TikTokLive.types.events import CommentEvent
from colorama import Fore, Style
from datetime import datetime, timedelta

# Define the key mapping in English
key_mapping_english = {
Expand Down Expand Up @@ -54,46 +52,14 @@ def detect_language(comment):
return "english"
for key in key_mapping_spanish.keys():
if comment in key:
return "english"
return "spanish"
for key in key_mapping_portuguese.keys():
if comment in key:
return "english"
return "portuguese"
else:
return "english" # Use english <3 as the default if no language is detected


# Function to get the current date and time in the desired format
def get_current_datetime():
now = datetime.now()
formatted_datetime = now.strftime("[%d/%m/%Y %H:%M]")
return formatted_datetime


# Function to get the date in the desired format
def get_date_string(date):
return date.strftime("%d/%m/%Y")


# Function to save the key mapping usage record to log2.txt
def save_key_mapping_usage(key_mapping_usage):
global first_record_date # Access the global variable

# If it's the first time saving the record, store the current date
if first_record_date is None:
first_record_date = datetime.now()

current_date = datetime.now()

# Calculate the difference in days between the current date and the first record date
days_difference = (current_date - first_record_date).days

with open("log2.txt", "w") as log2_file:
log2_file.write(
f"Key Mapping Usage Record from {get_date_string(first_record_date)} - {get_date_string(current_date)}\n")
for keyword, count in key_mapping_usage.items():
log2_file.write(f"{keyword}: {count} times\n")


# Function to handle TikTok comments
async def on_ttcomment(event: CommentEvent):
try:
Expand All @@ -104,36 +70,13 @@ async def on_ttcomment(event: CommentEvent):
selected_key_mapping = key_mapping_english
elif detected_language == "spanish":
selected_key_mapping = key_mapping_spanish
elif detected_language == "portuguese":
else:
selected_key_mapping = key_mapping_portuguese
else: # not possible to get to this else statement
selected_key_mapping = key_mapping_english # Use English as the default

keypress = comment.lower() # Convert to lowercase
formatted_username = Fore.GREEN + event.user.nickname + Style.RESET_ALL # colorama is cool.
formatted_comment = Fore.WHITE + comment + Style.RESET_ALL

# Initialize a dictionary for key mapping usage record
key_mapping_usage = {keyword: 0 for keyword in selected_key_mapping}

# Find keywords in the comment and format them in red
for keyword, key_action in selected_key_mapping.items():
if keyword in keypress:
formatted_comment = formatted_comment.replace(keyword, Fore.RED + keyword + Style.RESET_ALL)
key_mapping_usage[keyword] += 1

if keypress in selected_key_mapping:
mapped_key = selected_key_mapping[keypress]
keyboard.press(mapped_key) # press the key
time.sleep(0.3)
keyboard.release(mapped_key) # release the key
formatted_datetime = get_current_datetime()
log_file.write(f"{formatted_datetime} {formatted_username} -> {formatted_comment}\n")

# Save the key mapping usage record to log2.txt
save_key_mapping_usage(key_mapping_usage)
if comment in selected_key_mapping:
pyautogui.press(selected_key_mapping[comment])
print("pressed: " + selected_key_mapping[comment])

print(f"{formatted_datetime} {formatted_username} -> {formatted_comment}")
except Exception as err:
print(f"{err}\n Quitting now")
time.sleep(4)
Expand All @@ -147,5 +90,4 @@ async def on_ttcomment(event: CommentEvent):
tiktok_username = input("TikTok username: ") # Modified the prompt message
tiktok_client = TikTokLiveClient(unique_id="@" + tiktok_username)
on_ttcomment = tiktok_client.on("comment")(on_ttcomment)
print("Connected")
tiktok_client.run()
tiktok_client.run() # Start the client
154 changes: 0 additions & 154 deletions main_espanol.py

This file was deleted.

Loading

0 comments on commit f90cc9f

Please sign in to comment.