Skip to content

Commit f90cc9f

Browse files
committed
new build soon
1 parent f93b350 commit f90cc9f

File tree

5 files changed

+17
-377
lines changed

5 files changed

+17
-377
lines changed

log.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Opened
2+
Opened
3+
Opened
4+
Opened
5+
Opened
6+
Opened
7+
Opened

main.py

Lines changed: 8 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import time
2-
import keyboard
2+
import pyautogui
33
from TikTokLive import TikTokLiveClient
44
from TikTokLive.types.events import CommentEvent
5-
from colorama import Fore, Style
6-
from datetime import datetime, timedelta
75

86
# Define the key mapping in English
97
key_mapping_english = {
@@ -54,46 +52,14 @@ def detect_language(comment):
5452
return "english"
5553
for key in key_mapping_spanish.keys():
5654
if comment in key:
57-
return "english"
55+
return "spanish"
5856
for key in key_mapping_portuguese.keys():
5957
if comment in key:
60-
return "english"
58+
return "portuguese"
6159
else:
6260
return "english" # Use english <3 as the default if no language is detected
6361

6462

65-
# Function to get the current date and time in the desired format
66-
def get_current_datetime():
67-
now = datetime.now()
68-
formatted_datetime = now.strftime("[%d/%m/%Y %H:%M]")
69-
return formatted_datetime
70-
71-
72-
# Function to get the date in the desired format
73-
def get_date_string(date):
74-
return date.strftime("%d/%m/%Y")
75-
76-
77-
# Function to save the key mapping usage record to log2.txt
78-
def save_key_mapping_usage(key_mapping_usage):
79-
global first_record_date # Access the global variable
80-
81-
# If it's the first time saving the record, store the current date
82-
if first_record_date is None:
83-
first_record_date = datetime.now()
84-
85-
current_date = datetime.now()
86-
87-
# Calculate the difference in days between the current date and the first record date
88-
days_difference = (current_date - first_record_date).days
89-
90-
with open("log2.txt", "w") as log2_file:
91-
log2_file.write(
92-
f"Key Mapping Usage Record from {get_date_string(first_record_date)} - {get_date_string(current_date)}\n")
93-
for keyword, count in key_mapping_usage.items():
94-
log2_file.write(f"{keyword}: {count} times\n")
95-
96-
9763
# Function to handle TikTok comments
9864
async def on_ttcomment(event: CommentEvent):
9965
try:
@@ -104,36 +70,13 @@ async def on_ttcomment(event: CommentEvent):
10470
selected_key_mapping = key_mapping_english
10571
elif detected_language == "spanish":
10672
selected_key_mapping = key_mapping_spanish
107-
elif detected_language == "portuguese":
73+
else:
10874
selected_key_mapping = key_mapping_portuguese
109-
else: # not possible to get to this else statement
110-
selected_key_mapping = key_mapping_english # Use English as the default
111-
112-
keypress = comment.lower() # Convert to lowercase
113-
formatted_username = Fore.GREEN + event.user.nickname + Style.RESET_ALL # colorama is cool.
114-
formatted_comment = Fore.WHITE + comment + Style.RESET_ALL
115-
116-
# Initialize a dictionary for key mapping usage record
117-
key_mapping_usage = {keyword: 0 for keyword in selected_key_mapping}
118-
119-
# Find keywords in the comment and format them in red
120-
for keyword, key_action in selected_key_mapping.items():
121-
if keyword in keypress:
122-
formatted_comment = formatted_comment.replace(keyword, Fore.RED + keyword + Style.RESET_ALL)
123-
key_mapping_usage[keyword] += 1
124-
125-
if keypress in selected_key_mapping:
126-
mapped_key = selected_key_mapping[keypress]
127-
keyboard.press(mapped_key) # press the key
128-
time.sleep(0.3)
129-
keyboard.release(mapped_key) # release the key
130-
formatted_datetime = get_current_datetime()
131-
log_file.write(f"{formatted_datetime} {formatted_username} -> {formatted_comment}\n")
13275

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

136-
print(f"{formatted_datetime} {formatted_username} -> {formatted_comment}")
13780
except Exception as err:
13881
print(f"{err}\n Quitting now")
13982
time.sleep(4)
@@ -147,5 +90,4 @@ async def on_ttcomment(event: CommentEvent):
14790
tiktok_username = input("TikTok username: ") # Modified the prompt message
14891
tiktok_client = TikTokLiveClient(unique_id="@" + tiktok_username)
14992
on_ttcomment = tiktok_client.on("comment")(on_ttcomment)
150-
print("Connected")
151-
tiktok_client.run()
93+
tiktok_client.run() # Start the client

main_espanol.py

Lines changed: 0 additions & 154 deletions
This file was deleted.

0 commit comments

Comments
 (0)