Commit 753dcf4 pnhofmann
authored
File tree 1 file changed +14
-13
lines changed
1 file changed +14
-13
lines changed Original file line number Diff line number Diff line change 1
1
import requests
2
2
from colorama import Fore
3
3
from plugin import plugin , require
4
+ import re
4
5
5
- def fetch (route ):
6
+ def fetch (name ):
6
7
7
8
url = 'https://api.agify.io?name='
8
- r = requests .get (url + route )
9
+ r = requests .get (url + name )
9
10
r = r .json ()
10
11
if "errorCode" in r .keys ():
11
12
return None
@@ -16,20 +17,20 @@ def fetch(route):
16
17
class Age ():
17
18
18
19
def __call__ (self , jarvis , s ):
19
- option = self .get_option (jarvis )
20
- if option is None :
20
+ name = self .get_name (jarvis )
21
+ name = re .sub ("[^A-Za-z]" , "" , name )
22
+
23
+ if name is None :
21
24
return
22
25
23
- r = fetch ((str (option )))
24
- print ("Your age is " + str (r ["age" ]))
25
-
26
-
27
- def get_option (self , jarvis ):
26
+ r = fetch ((str (name )))
27
+ print ("The average age for this name is " + str (r ["age" ]))
28
+ print ()
28
29
29
- # Ask for the option
30
- jarvis . say ( "Give a name :" , Fore . BLUE )
30
+ def get_name ( self , jarvis ):
31
+ # Ask for the name
31
32
print ()
32
33
while True :
33
- option = str (jarvis .input ("Enter your choice : " , Fore .GREEN ))
34
- return option
34
+ name = str (jarvis .input ("Give a name : " , Fore .BLUE ))
35
+ return name
35
36
You can’t perform that action at this time.
0 commit comments