-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBard.py
84 lines (69 loc) · 2.21 KB
/
Bard.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import datetime
from bardapi import BardCookies
from JARVIS import takecommand
from JARVIS import Speak
import pyperclip
import pyautogui
import webbrowser
from time import sleep
import json
import keyboard
def CookieScrapper():
webbrowser.open("https://bard.google.com")
sleep(2)
pyautogui.click(x=1247, y=49)
sleep(1)
pyautogui.click(x=1045, y=197)
sleep(1)
pyautogui.click(x=1017, y=86)
sleep(1)
keyboard.press_and_release('ctrl + w')
data = pyperclip.paste()
try:
json_data = json.loads(data)
pass
except json.JSONDecodeError as e:
print(f"Error parsing JSON data: {e}")
SID = "__Secure-1PSID"
TS = "__Secure-1PSIDTS"
CC = "__Secure-1PSIDCC"
SIDValue = next((item for item in json_data if item["name"] == SID), None)
TSValue = next((item for item in json_data if item["name"] == TS), None)
CCValue = next((item for item in json_data if item["name"] == CC), None)
if SIDValue is not None:
SIDValue = SIDValue["value"]
else:
print(f"{SIDValue} not found in the JSON data.")
if TSValue is not None:
TSValue = TSValue["value"]
else:
print(f"{TSValue} not found in the JSON data.")
if CCValue is not None:
CCValue = CCValue["value"]
else:
print(f"{CCValue} not found in the JSON data.")
cookie_dict = {
"__Secure-1PSID": SIDValue ,
"__Secure-1PSIDTS": TSValue,
"__Secure-1PSIDCC": CCValue,
}
return cookie_dict
cookie_dict = CookieScrapper()
bard = BardCookies(cookie_dict=cookie_dict)
def split_and_save_paragraphs(data, filename):
paragraphs = data.split('\n\n')
with open(filename, 'w') as file:
file.write(data)
data = paragraphs[:2]
separator = ', '
joined_string = separator.join(data)
return joined_string
while True:
Question = takecommand()
RealQuestion = str(Question)
results = bard.get_answer(RealQuestion)['content']
current_datetime = datetime.datetime.now()
formatted_time = current_datetime.strftime("%H%M%S")
filenamedate = str(formatted_time) + str(".txt")
filenamedate = "DataBase" + filenamedate
Speak(split_and_save_paragraphs(results, filename=filenamedate))