Skip to content

Commit

Permalink
working well for demo
Browse files Browse the repository at this point in the history
  • Loading branch information
smtbos committed Sep 9, 2022
1 parent 820faa9 commit 7287409
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
12 changes: 7 additions & 5 deletions Jarvis.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,19 +114,21 @@ def startTask(self):
reply = random.choice(intent["responses"])
print(f"Reply:::=>{reply}")
if "time" in reply:
NonInputExecution(reply)
NonInputExecution(reply, self)
elif "date" in reply:
NonInputExecution(reply)
NonInputExecution(reply,self)
elif "day" in reply:
NonInputExecution(reply)
NonInputExecution(reply,self)
elif "wikipedia" in reply:
InputExecution(reply, sentence)
elif "google" in reply:
InputExecution(reply, result)
elif "youtube" in reply:
InputExecution(reply, result)
elif "joke" in reply:
NonInputExecution(reply)
NonInputExecution(reply, self)
elif "weather" in reply:
NonInputExecution(reply)
NonInputExecution(reply, self)
else:
self.gui.speaker.setText(reply)
Bol(reply)
Expand Down
13 changes: 7 additions & 6 deletions Task.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from Speak import Bol
import pyjokes
import weather
# import datetime
from datetime import datetime
import datetime
# from datetime import datetime
from PyQt5.QtCore import Qt, QTime, QDate

def Time():
Expand All @@ -25,9 +25,8 @@ def Joke():
Bol(funny)


def NonInputExecution(query):
def NonInputExecution(query, ref = None):
query = str(query)

if "time" in query:
Time()
elif "date" in query:
Expand All @@ -37,7 +36,7 @@ def NonInputExecution(query):
elif "joke" in query:
Joke()
elif "weather" in query:
weather.weathernews()
weather.weathernews(ref)


def wishMe():
Expand All @@ -64,6 +63,7 @@ def showTime(self):


def InputExecution(tag, query):
print("PU "+tag,query)
if "wikipedia" in tag:
name = str(query).replace("about", "").replace("wikipedia", "")
import wikipedia
Expand All @@ -76,7 +76,8 @@ def InputExecution(tag, query):
query = str(query).replace("youtube", "")
query = query.replace("on youtube", "")
import pywhatkit
pywhatkit.search(query)
pywhatkit.playonyt(query)


elif "google" in tag:
print("Googling...")
Expand Down
Binary file modified data.pth
Binary file not shown.
8 changes: 6 additions & 2 deletions weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import geocoder
g = geocoder.ip('me')

def weathernews():
def weathernews(ref = None):
api_url = "https://fcc-weather-api.glitch.me/api/current?lat=" + \
str(g.latlng[0]) + "&lon=" + str(g.latlng[1])

Expand All @@ -14,12 +14,16 @@ def weathernews():
main = data_json['main']
wind = data_json['wind']
weather_desc = data_json['weather'][0]
if ref is not None:
ref.gui.speaker.setText(
"The weather is " + weather_desc['description'] + " and the temperature is " + str(
main['temp']) + " degree celcius. The wind speed is " + str(wind['speed']) + " m/s")
Bol('Current location is ' + data_json['name'] + data_json['sys']['country'] + 'dia')
Bol('weather type ' + weather_desc['main'])
Bol('Wind speed is ' + str(wind['speed']) + ' metre per second')
Bol('Temperature: ' + str(main['temp']) + 'degree celcius')
Bol('Humidity is ' + str(main['humidity']))
Bol(str(data_json['coord']['lat']) + 'latitude' + str(data_json['coord']['lon']) + 'longitude')

if __name__ == '__main__':
weathernews()

0 comments on commit 7287409

Please sign in to comment.