MCPcopy
hub / github.com/CodeWithHarry/The-Ultimate-Python-Course / processCommand

Function processCommand

Mega Project 1 - Jarvis/main.py:55–85  ·  view source on GitHub ↗
(c)

Source from the content-addressed store, hash-verified

53 return completion.choices[0].message.content
54
55def processCommand(c):
56 if "open google" in c.lower():
57 webbrowser.open("https://google.com")
58 elif "open facebook" in c.lower():
59 webbrowser.open("https://facebook.com")
60 elif "open youtube" in c.lower():
61 webbrowser.open("https://youtube.com")
62 elif "open linkedin" in c.lower():
63 webbrowser.open("https://linkedin.com")
64 elif c.lower().startswith("play"):
65 song = c.lower().split(" ")[1]
66 link = musicLibrary.music[song]
67 webbrowser.open(link)
68
69 elif "news" in c.lower():
70 r = requests.get(f"https://newsapi.org/v2/top-headlines?country=in&apiKey={newsapi}")
71 if r.status_code == 200:
72 # Parse the JSON response
73 data = r.json()
74
75 # Extract the articles
76 articles = data.get('articles', [])
77
78 # Print the headlines
79 for article in articles:
80 speak(article['title'])
81
82 else:
83 # Let OpenAI handle the request
84 output = aiProcess(c)
85 speak(output)
86
87
88

Callers 1

main.pyFile · 0.85

Calls 2

speakFunction · 0.85
aiProcessFunction · 0.85

Tested by

no test coverage detected