-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
187 lines (138 loc) · 6.21 KB
/
main.py
File metadata and controls
187 lines (138 loc) · 6.21 KB
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#install bllow all libery
#python_project
#pip install pywhatkit
#pip install openai
#pip install geopy
#pip install twilio
#pip install folium
#pip install pyperclip
import os
import subprocess
import urllib.parse
import pywhatkit
import openai
import smtplib
from twilio.rest import Client
import folium
from geopy.geocoders import Nominatim
#############################################################################################################
#Email function#
def send_email():
print("Thanks for choosing email service...")
smtp_server = "smtp.gmail.com"
email = "Enter your email"
password = "Enter your password"
to_email = input("Enter recipient's email: ")
subject = input("Enter the email subject: ")
message = input("Enter the email message: ")
with smtplib.SMTP(smtp_server, 587) as server:
server.starttls()
server.login(email, password)
server.sendmail(email, to_email, f"Subject: {subject}\n\n{message}")
print("Email sent successfully.")
#################################################################################################################
#SMS function#
def send_sms(to_phone_number, message_body):
print("Thanks for choosing SMS service...")
account_sid = "Enter your sid acc"
auth_token = "Enter your auth_token"
from_phone_number = "+123456789" #twilio enter your number
client = Client(account_sid, auth_token)
message = client.messages.create(
body=message_body,
from_=from_phone_number,
to=to_phone_number
)
print(f"Message SID: {message.sid}")
print("Message has been sent successfully.")
################################################################################################################
#What's app function#
def send_whatsapp(to_phone_number, message_body, hour, minute):
print("Thanks for choosing WhatsApp service...")
try:
hour = int(hour)
minute = int(minute)
pywhatkit.sendwhatmsg(f"+{to_phone_number}", message_body, hour, minute)
print("WhatsApp message has been scheduled.")
except Exception as e:
print(f"Failed to schedule the WhatsApp message: {str(e)}")
##################################################################################################################
#Location function#
def find_location(location_name, output_file="location_map.html"):
print("Thanks for choosing location service...")
geolocator = Nominatim(user_agent="location_pinner")
location = geolocator.geocode(location_name)
if location:
m = folium.Map(location=[location.latitude, location.longitude], zoom_start=10)
folium.Marker([location.latitude, location.longitude], popup=location_name).add_to(m)
m.save(output_file)
print(f"Location map saved as {output_file}")
else:
print(f"Location not found: {location_name}")
####################################################################################################################
#chat_gpt#
# Set your OpenAI API key
openai.api_key = "Enter_your_openapi_key"
def chat_with_gpt(user_input):
print("Thanks for choosing ChatGPT service...")
try:
response = openai.Completion.create(
engine="davinci",
prompt=user_input,
max_tokens=50 # Adjust based on your needs
)
assistant_response = response.choices[0].text
print("ChatGPT Response:", assistant_response)
except Exception as e:
print(f"Failed to interact with ChatGPT: {str(e)}")
######################################################################################################
#chrome function#
def open_chrome_search(query):
try:
search_url = f"https://www.google.com/search?q={urllib.parse.quote(query)}"
chrome_path = "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" # Replace with the actual path
subprocess.Popen([chrome_path, search_url])
print(f"Searching for '{query}' in Chrome...")
except Exception as e:
print(f"Failed to open Chrome: {str(e)}")
##############################################################################################################
def main_menu():
while True:
print("\t\t\t\t\tMy Project")
print("********************************************************************************************************************")
print("""
\t\t\tpress 1: Send Email
\t\t\tpress 2: Send SMS
\t\t\tpress 3: Send WhatsApp
\t\t\tpress 4: Find Location
\t\t\tpress 5: Ask ChatGPT
\t\t\tpress 6: Open Browser
\t\t\tpress 0: Exit
""")
service = input("Enter your choice: ")
if service == '1':
send_email()
elif service == '2':
to_phone_number = input("Enter the recipient mobile number with country code: ")
message_body = input("Enter your message:")
send_sms(to_phone_number, message_body)
elif service == '3':
to_phone_number = input("Enter the recipient WhatsApp number (without '+' or '00'): ")
message_body = input("Enter your WhatsApp message: ")
hour = input("Enter the hour (24-hour format): ")
minute = input("Enter the minute: ")
send_whatsapp(to_phone_number, message_body, hour, minute)
elif service == '4':
location_name = input("Enter the location name: ")
find_location(location_name)
elif service == '5':
user_input = input("Enter your prompt for ChatGPT:")
chat_with_gpt(user_input)
elif service == '6':
search_query = input("Enter your search query: ")
open_chrome_search(search_query)
elif service == '0':
print("Exiting the program. Goodbye!")
break
else:
print("Invalid choice. Please select a valid option.")