-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path03_bot.py
65 lines (49 loc) · 2.22 KB
/
03_bot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import pyautogui
import time
import pyperclip
from openai import OpenAI
client = OpenAI(
api_key="<Your Key Here>",
)
def is_last_message_from_sender(chat_log, sender_name="Rohan Das"):
# Split the chat log into individual messages
messages = chat_log.strip().split("/2024] ")[-1]
if sender_name in messages:
return True
return False
# Step 1: Click on the chrome icon at coordinates (1639, 1412)
pyautogui.click(1639, 1412)
time.sleep(1) # Wait for 1 second to ensure the click is registered
while True:
time.sleep(5)
# Step 2: Drag the mouse from (1003, 237) to (2187, 1258) to select the text
pyautogui.moveTo(972,202)
pyautogui.dragTo(2213, 1278, duration=2.0, button='left') # Drag for 2 second
# Step 3: Copy the selected text to the clipboard
pyautogui.hotkey('ctrl', 'c')
time.sleep(2) # Wait for 1 second to ensure the copy command is completed
pyautogui.click(1994, 281)
# Step 4: Retrieve the text from the clipboard and store it in a variable
chat_history = pyperclip.paste()
# Print the copied text to verify
print(chat_history)
print(is_last_message_from_sender(chat_history))
if is_last_message_from_sender(chat_history):
completion = client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "You are a person named Naruto who speaks hindi as well as english. You are from India and you are a coder. You analyze chat history and roast people in a funny way. Output should be the next chat response (text message only)"},
{"role": "system", "content": "Do not start like this [21:02, 12/6/2024] Rohan Das: "},
{"role": "user", "content": chat_history}
]
)
response = completion.choices[0].message.content
pyperclip.copy(response)
# Step 5: Click at coordinates (1808, 1328)
pyautogui.click(1808, 1328)
time.sleep(1) # Wait for 1 second to ensure the click is registered
# Step 6: Paste the text
pyautogui.hotkey('ctrl', 'v')
time.sleep(1) # Wait for 1 second to ensure the paste command is completed
# Step 7: Press Enter
pyautogui.press('enter')