Skip to content

Commit

Permalink
Merge pull request #1126 from kapoorkrish/master
Browse files Browse the repository at this point in the history
Fix: #1125 age plugin issue
  • Loading branch information
pnhofmann committed Aug 28, 2023
2 parents e13af5c + 79f5e67 commit 753dcf4
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions jarviscli/plugins/age.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import requests
from colorama import Fore
from plugin import plugin, require
import re

def fetch(route):
def fetch(name):

url = 'https://api.agify.io?name='
r = requests.get(url + route)
r = requests.get(url + name)
r = r.json()
if "errorCode" in r.keys():
return None
Expand All @@ -16,20 +17,20 @@ def fetch(route):
class Age():

def __call__(self, jarvis, s):
option = self.get_option(jarvis)
if option is None:
name = self.get_name(jarvis)
name = re.sub("[^A-Za-z]", "", name)

if name is None:
return

r = fetch((str(option)))
print("Your age is "+str(r["age"]))


def get_option(self, jarvis):
r = fetch((str(name)))
print("The average age for this name is "+str(r["age"]))
print()

# Ask for the option
jarvis.say("Give a name :", Fore.BLUE)
def get_name(self, jarvis):
# Ask for the name
print()
while True:
option = str(jarvis.input("Enter your choice: ", Fore.GREEN))
return option
name = str(jarvis.input("Give a name: ", Fore.BLUE))
return name

0 comments on commit 753dcf4

Please sign in to comment.