-
Notifications
You must be signed in to change notification settings - Fork 2
/
reply_func.py
63 lines (51 loc) · 1.72 KB
/
reply_func.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
import datetime
import random
import smtplib
import webbrowser
import PySimpleGUI as sg
# voice initiation
import pyttsx3
engine = pyttsx3.init('sapi5', True)
engine.setProperty('rate', 225) # setting up new voice rate
voices = engine.getProperty('voices') # get system voice pack
engine.setProperty('voice', voices[2].id) # changing index, changes voices. 2 for male
def speak(msg, msg_show=0): # popup windows actually
engine.say(msg)
if msg_show != 0:
msg = msg_show
speak_layout = [[sg.Text(msg)]]
window = sg.Window('J.A.R.V.I.S.', speak_layout, auto_close=True, auto_close_duration=2)
event, values = window.read()
engine.runAndWait()
# print(msg)
def wiki(content): # search wikipedia
wiki_layout = [[sg.Text(content)], [sg.Button('Ok')]]
window = sg.Window('J.A.R.V.I.S.', wiki_layout)
while True:
event, values = window.read()
if event == sg.WIN_CLOSED or event == 'Ok':
break
window.close()
def wishMe():
hour = int(datetime.datetime.now().hour)
if 4 <= hour < 12:
t = "Good morning"
elif 12 <= hour < 18:
t = "Good afternoon"
else:
t = "Good evening"
greetinglist = ["How may I help you?", "How can I be of service today?", "Good to see you again.",
"Hope you are well?"]
speak(t + " sir. " + random.choice(greetinglist))
def sendEmail(to, content):
server = smtplib.SMTP('smtp.qq.com', 587)
server.ehlo()
server.starttls()
server.login('your_email@example.com', 'your_login_password')
server.sendmail('your_email@example.com', to, content)
server.close()
def net(url):
try:
webbrowser.open_new_tab(url)
except:
webbrowser.open(url)