forked from AadarshChaurasia/desktop_assistant_v1.1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
extra_func.py
84 lines (52 loc) · 1.75 KB
/
extra_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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import smtplib
import pyqrcode
from googletrans import Translator
import requests
import phonenumbers
from phonenumbers import carrier
from yahoo_fin import stock_info as si
import pyjokes
import random
def set_reminder(set_date,set_time,task):
data = str(set_time)+' '+str(set_date)+' '+ str(task)
with open('to-do-list', 'a') as f:
f.write(data)
speak('reminder is set now!')
# smtplib
def sendEmail(to, content):
''' send email '''
server = smtplib.SMTP('smtp.gmail.com', 587)
server.ehlo()
server.starttls()
server.login('[email protected]', 'your-password')
server.sendmail('[email protected]', to, content)
server.close()
# pyqrcode
def qenerate_qr_code_of(link):
''' generate QR code of link '''
url = pyqrcode.create(link_)
url.svg("Qrcode.svg", scale=10)
# Translator
def translate(data,language):
Translator = Translator()
Translated = Translator.translate(data,dest=language)
return Translated.text
# Instagram requests
def Instagram_followers_of(username):
url = 'https://www.instagram.com/'+username
result = requests.get(url).text
start = '"edge_followed_by":{"count":'
end = '},"followed_by_viewer"'
result = str(result[result.find(start)+len(start):result.rfind(end)])
return result
# phonenumbers
def get_service_provider_of(phonenumber):
service_provider = phonenumbers.parse(phonenumber)
return carrier.name_for_number(service_provider,"en")
def stock_price_of(company):
price = "$ "+si.get_live_price(company)
return price
def jokes():
number = random.randint(0, 96)
joke = pyjokes.get_jokes()
return joke[number]